Interact with Resources with Viam's Client SDKs

Every Viam resource exposes an Application Programming Interface (API) described through protocol buffers. You can think of this as a description of how you can interact with that resource. Different models of resources implement the same API, which Viam SDKs expose, allowing you to control different models of resource types with a consistent interface.

The API methods provided by the SDKs for each of these resource APIs wrap gRPC client requests to the machine when you execute your program, providing you a convenient interface for accessing information about and controlling the resources you have configured on your machine.

Robot management APIs

Robot API

All machines support the following methods through the robot API:

Method NameDescription
GetOperationsGet the list of operations currently running on the machine.
ResourceNamesGet a list of all known resource names connected to this machine.
CancelOperationCancel the specified operation on the machine.
BlockForOperationBlocks on the specified operation on the machine.
DiscoverComponentsGet a list of discovered component configurations.
FrameSystemConfigGet the configuration of the frame system of a given machine.
TransformPoseTransform a given source Pose from the original reference frame to a new destination reference frame.
TransformPCDTransforms the pointcloud to the desired frame in the robot’s frame system.
GetStatusGet the status of the resources on the machine.
StopAllCancel all current and outstanding operations for the machine and stop all actuators and movement.
LogCreate a LogEntry object from the log to send to the RDK over gRPC.
GetCloudMetadataGet app-related information about the robot.
Options.with_api_keyCreate a RobotClient.Options using an API key as credentials.
AtAddressCreate a RobotClient that is connected to the machine at the provided address.
WithChannelCreate a RobotClient that is connected to a machine over the given channel.
RefreshManually refresh the underlying parts of this machine.
ShutdownShutdown shuts down the machine.
CloseClose the underlying connections and stop any periodic tasks across all constituent parts of the machine.

Fleet management API

The fleet management API supports the following methods:

Method NameDescription
ListOrganizationsList the organizations the user is an authorized user of.
GetOrganizationReturn details about the requested organization.
GetOrganizationNamespaceAvailabilityCheck the availability of an organization namespace.
UpdateOrganizationUpdates organization details.
ListOrganizationMembersList the members and invites of the organization that you are currently authenticated to.
CreateOrganizationInviteCreate an organization invite and send it by email.
UpdateOrganizationInviteAuthorizationsUpdate (add or remove) the authorizations attached to an organization invite that has already been created.
DeleteOrganizationMemberRemove a member from the organization you are currently authenticated to.
DeleteOrganizationInviteDelete a pending organization invite to the organization you are currently authenticated to.
ResendOrganizationInviteResend a pending organization invite email.
CreateLocationCreate and name a location under the organization you are currently authenticated to.
GetLocationGet a location by its location ID.
UpdateLocationChange the name of a parent location and/or assign it a new location.
DeleteLocationDelete a location.
ListLocationsGet a list of all locations under the organization you are currently authenticated to.
LocationAuthGet a location’s LocationAuth (location secret or secrets).
GetRobotGet a machine by its ID.
GetRobotPartsGet a list of all the parts under a specific machine.
GetRobotPartGet a specific machine part.
GetRobotPartLogsGet the logs associated with a specific machine part.
TailRobotPartLogsGet an asynchronous iterator that receives live machine part logs.
GetRobotPartHistoryGet a list containing the history of a machine part.
UpdateRobotPartChange the name of and assign an optional new configuration to a machine part.
NewRobotPartCreate a new machine part.
DeleteRobotPartDelete the specified machine part.
MarkPartAsMainMark a machine part as the main part of a machine.
MarkPartForRestartMark a specified machine part for restart.
CreateRobotPartSecretCreate a machine part secret.
DeleteRobotPartSecretDelete a machine part secret.
ListRobotsGet a list of all machines in a specified location.
NewRobotCreate a new machine.
UpdateRobotChange the name of an existing machine.
DeleteRobotDelete a specified machine.
ListFragmentsGet a list of fragments in the organization you are currently authenticated to.
GetFragmentGet a fragment by ID.
CreateFragmentCreate a new private fragment.
UpdateFragmentUpdate a fragment name and its config and/or visibility.
DeleteFragmentDelete a fragment.
AddRoleAdd a role under the organization you are currently authenticated to.
RemoveRoleRemove a role under the organization you are currently authenticated to.
ListAuthorizationsList all authorizations (owners and operators) of a specific resource (or resources) within the organization you are currently authenticated to.
CheckPermissionsCheck if the organization, location, or robot your ViamClient is authenticated to is permitted to perform some action or set of actions on the resource you pass to the method.
CreateModuleCreate a module under the organization you are currently authenticated to.
UpdateModuleUpdate the documentation URL, description, models, entrypoint, and/or the visibility of a module.
UploadModuleFileUpload a module file.
GetModuleGet a module by its ID.
ListModulesList the modules under the organization you are currently authenticated to.
CreateKeyCreate a new API key.
ListKeysList all keys for the organization that you are currently authenticated to.
CreateKeyFromExistingKeyAuthorizationsCreate a new API key with an existing key’s authorizations.

Data client API

The data client API supports the following methods:

Methods to upload data like images or sensor readings directly to the Viam app:

Method NameDescription
BinaryDataCaptureUploadUpload binary data collected on your machine through a specific component and the relevant metadata to the Viam app.
TabularDataCaptureUploadUpload tabular data collected on your machine through a specific component to the Viam app.
FileUploadUpload arbitrary files stored on your machine to the Viam app by file name.
FileUploadFromPathUpload files stored on your machine to the Viam app by filepath.
StreamingDataCaptureUploadUpload the contents of streaming binary data and the relevant metadata to the Viam app.

Methods to download, filter, tag, or perform other tasks on data like images or sensor readings:

Method NameDescription
TabularDataByFilterRetrieve optionally filtered tabular data from the Viam app.
TabularDataBySQLObtain unified tabular data and metadata, queried with SQL.
TabularDataByMQLObtain unified tabular data and metadata, queried with MQL.
BinaryDataByFilterRetrieve optionally filtered binary data from the Viam app.
BinaryDataByIDsRetrieve binary data from the Viam app by BinaryID.
DeleteTabularDataDelete tabular data older than a specified number of days.
DeleteBinaryDataByFilterFilter and delete binary data.
DeleteBinaryDataByIDsFilter and delete binary data by ids.
AddTagsToBinaryDataByIDsAdd tags to binary data by ids.
AddTagsToBinaryDataByFilterAdd tags to binary data by filter.
RemoveTagsFromBinaryDataByIDsRemove tags from binary by ids.
RemoveTagsFromBinaryDataByFilterRemove tags from binary data by filter.
TagsByFilterGet a list of tags using a filter.
AddBoundingBoxToImageByIDAdd a bounding box to an image specified by its BinaryID.
RemoveBoundingBoxFromImageByIDRemoves a bounding box from an image specified by its BinaryID.
BoundingBoxLabelsByFilterGet a list of bounding box labels using a Filter.
GetDatabaseConnectionGet a connection to access a MongoDB Atlas Data federation instance.
AddBinaryDataToDatasetByIDsAdd the BinaryData to the provided dataset.
RemoveBinaryDataFromDatasetByIDsRemove the BinaryData from the provided dataset.

Methods to work with datasets:

Method NameDescription
CreateDatasetCreate a new dataset.
DeleteDatasetDelete a dataset.
RenameDatasetRename a dataset specified by the dataset ID.
ListDatasetsByOrganizationIDGet the datasets in an organization.
ListDatasetsByIDsGet a list of datasets using their IDs.

ML training API

The ML training API allows you to get information about and cancel ML training jobs taking place on the Viam app:

Method NameDescription
SubmitTrainingJobSubmit a training job.
SubmitCustomTrainingJobSubmit a training job from a custom training script.
GetTrainingJobGet training job metadata.
ListTrainingJobsGet training job metadata for all jobs within an organization.
CancelTrainingJobCancel the specified training job.
DeleteCompletedTrainingJobDelete a completed training job from the database, whether the job succeeded or failed.

Billing client API

The billing client API supports the following methods to retrieve billing information from the Viam app:

Method NameDescription
GetCurrentMonthUsageAccess data usage information for the current month for a given organization.
GetOrgBillingInformationAccess billing information (payment method, billing tier, etc.) for a given org.
GetInvoicesSummaryAccess total outstanding balance plus invoice summaries for a given org.
GetInvoicePdfAccess invoice PDF data and optionally save it to a provided file path.

Component APIs

These APIs provide interfaces for controlling and getting information from various components of a machine. Built-in API methods are defined for every model of each component type. Documentation on using these methods in your SDK code is found on each component page as follows:

Arm

The arm component supports the following methods:

Method NameDescription
GetEndPositionGet the current position of the arm as a pose.
MoveToPositionMove the end of the arm to the desired pose, relative to the base of the arm.
MoveToJointPositionsMove each joint on the arm to the position specified in positions.
GetJointPositionsGet the current position of each joint on the arm.
GetKinematicsGet the kinematics information associated with the arm as the format and byte contents of the kinematics file.
IsMovingGet if the arm is currently moving.
StopStop all motion of the arm.
GetGeometriesGet all the geometries associated with the arm in its current configuration, in the frame of the arm.
ReconfigureReconfigure this resource.
DoCommandExecute model-specific commands that are not otherwise defined by the component API.
FromRobotGet the resource from the provided robot with the given name.
GetResourceNameGet the ResourceName for this arm with the given name.
CloseSafely shut down the resource and prevent further use.

Base

The base component supports the following methods:

Method NameDescriptionmicro-RDK Support
MoveStraightMove the base in a straight line across the given distance (mm) at the given velocity (mm/sec).

SpinTurn the base in place, rotating it to the given angle (degrees) at the given angular velocity (degrees/sec).

SetPowerSet the linear and angular power of the base, represented as a percentage of max power for each direction in the range of [-1.0 to 1.0].

SetVelocitySet the linear velocity (mm/sec) and angular velocity (degrees/sec) of the base.

GetPropertiesGet the width and turning radius of the model of base in meters.

IsMovingReturns whether the base is actively moving (or attempting to move) under its own power.

StopStop the base from moving immediately.

GetGeometriesGet all the geometries associated with the base in its current configuration, in the frame of the base.

ReconfigureReconfigure this resource.

DoCommandExecute model-specific commands that are not otherwise defined by the component API.

FromRobotGet the resource from the provided robot with the given name.

GetResourceNameGet the ResourceName for this base with the given name.

CloseSafely shut down the resource and prevent further use.

Board

The board component supports the following methods:

Method NameDescriptionmicro-RDK Support
SetGPIOSet the digital signal output of this pin to low (0V) or high (active, >0V).

GetGPIOGet if the digital signal output of this pin is high (active, >0V).

GetPWMGet the pin’s pulse-width modulation (PWM) duty cycle: a float [0.0, 1.0] representing the percentage of time the digital signal output by this pin is in the high state (active, >0V) relative to the interval period of the PWM signal (interval period being the mathematical inverse of the PWM frequency).

SetPWMSet the pin’s Pulse-width modulation (PWM) duty cycle: a float [0.0, 1.0] indicating the percentage of time the digital signal output of this pin is in the high state (active, >0V) relative to the interval period of the PWM signal (interval period being the mathematical inverse of the PWM frequency).

PWMFrequencyGet the PWM frequency of the GPIO pin.

SetPWMFrequencySet the pin to the given PWM frequency (in Hz). When frequency is 0, it will use the board’s default PWM frequency.

AnalogNamesGet the name of every configured Analog on the board.

AnalogByNameGet a configured Analog by name.

WriteWrite an analog value to a pin on the board.

GetDigitalInterruptValueGet a configured DigitalInterrupt by name.

StreamTicksStart a stream of DigitalInterrupt ticks.

SetPowerModeSet the board to the indicated PowerMode.

GetGeometriesGet all the geometries associated with the board in its current configuration, in the frame of the board.

ReadRead the current integer value of the digital signal output by the ADC.

ValueGet the current value of this interrupt.

DigitalInterruptNamesGet the name of every configured DigitalInterrupt on the board.

GPIOPinByNameGet a GPIOPin by pin number.

ReconfigureReconfigure this resource.

DoCommandExecute model-specific commands that are not otherwise defined by the component API.

FromRobotGet the resource from the provided robot with the given name.

NameGet the name of the digital interrupt.

GetResourceNameGet the ResourceName for this board with the given name.

CloseSafely shut down the resource and prevent further use.

Camera

The camera component supports the following methods:

Method NameDescription
GetImageReturn an image from the camera.
GetImagesGet simultaneous images from different imagers, along with associated metadata.
GetPointCloudGet a point cloud from the camera as bytes with a MIME type describing the structure of the data.
GetPropertiesGet the camera intrinsic parameters and camera distortion, as well as whether the camera supports returning point clouds.
DoCommandExecute model-specific commands that are not otherwise defined by the component API.
GetGeometriesGet all the geometries associated with the camera in its current configuration, in the frame of the camera.
FromRobotGet the resource from the provided robot with the given name.
GetResourceNameGet the ResourceName for this camera with the given name.
CloseSafely shut down the resource and prevent further use.

Encoder

The encoder component supports the following methods:

Method NameDescriptionmicro-RDK Support
GetPositionGet the current position of the encoder in ticks or degrees.

ResetPositionSet the current position of the encoder to be the new zero position.

GetPropertiesGet a list of all the position types that are supported by a given encoder.

GetGeometriesGet all the geometries associated with the encoder in its current configuration, in the frame of the encoder.

ReconfigureReconfigure this resource.

DoCommandExecute model-specific commands that are not otherwise defined by the component API.

GetResourceNameGet the ResourceName for this encoder with the given name.

CloseSafely shut down the resource and prevent further use.

Gantry

The gantry component supports the following methods:

Method NameDescription
GetPositionGet the current positions of the axis of the gantry (mm).
MoveToPositionMove the axes of the gantry to the desired positions (mm) at the requested speeds (mm/sec).
GetLengthsGet the lengths of the axes of the gantry (mm).
HomeRun the homing sequence of the gantry to re-calibrate the axes with respect to the limit switches.
GetGeometriesGet all the geometries associated with the gantry in its current configuration, in the frame of the gantry.
IsMovingGet if the gantry is currently moving.
StopStop all motion of the gantry.
ReconfigureReconfigure this resource.
DoCommandExecute model-specific commands that are not otherwise defined by the component API.
FromRobotGet the resource from the provided robot with the given name.
GetResourceNameGet the ResourceName for this gantry with the given name.
CloseSafely shut down the resource and prevent further use.

Generic

The generic component supports the following methods:

Method NameDescriptionmicro-RDK Support
DoCommandExecute model-specific commands.

GetGeometriesGet all the geometries associated with the generic component in its current configuration, in the frame of the generic component.

FromRobotGet the resource from the provided robot with the given name.

GetResourceNameGet the ResourceName for this generic component with the given name.

CloseSafely shut down the resource and prevent further use.

Gripper

The gripper component supports the following methods:

Method NameDescription
OpenOpens the gripper.
GrabCloses the gripper until it grabs something or closes completely, and returns whether it grabbed something or not.
IsMovingReturns whether the gripper is actively moving (or attempting to move) under its own power.
StopStops the gripper.
GetGeometriesGet all the geometries associated with the gripper in its current configuration, in the frame of the gripper.
ReconfigureReconfigure this resource.
DoCommandExecute model-specific commands that are not otherwise defined by the component API.
FromRobotGet the resource from the provided robot with the given name.
GetResourceNameGet the ResourceName for this gripper with the given name.
CloseSafely shut down the resource and prevent further use.

Input Controller

The input controller component supports the following methods:

Method NameDescription
GetControlsGet a list of the Controls that your controller provides.
GetEventsThis method returns the current state of the controller as a map of Event Objects, representing the most recent event that has occurred on each available Control.
TriggerEventDirectly send an Event Object from external code.
GetGeometriesGet all the geometries associated with the input controller in its current configuration, in the frame of the input controller.
RegisterControlCallbackDefines a callback function to execute whenever one of the EventTypes selected occurs on the given Control.
ReconfigureReconfigure this resource.
DoCommandExecute model-specific commands that are not otherwise defined by the component API.
GetResourceNameGet the ResourceName for this input controller with the given name.
CloseSafely shut down the resource and prevent further use.

Motor

The motor component supports the following methods:

Method NameDescriptionmicro-RDK Support
SetPowerSet the portion of max power to send to the motor (between -1 and 1).

SetRPMSpin the motor indefinitely at the specified speed, in revolutions per minute. If rpm is positive, the motor will spin forwards, and if rpm is negative, the motor will spin backwards.

GoForSpin the motor the specified number of revolutions at specified revolutions per minute.

GoToTurn the motor to a specified position (in terms of revolutions from home/zero) at a specified speed in revolutions per minute (RPM).

ResetZeroPositionSet the current position (modified by offset) to be the new zero (home) position.

GetPositionReport the position of the motor based on its encoder.

GetPropertiesReport a dictionary mapping optional properties to whether it is supported by this motor.

IsPoweredReturn whether or not the motor is currently running, and the portion of max power (between 0 and 1; if the motor is off the power will be 0).

GetGeometriesGet all the geometries associated with the motor in its current configuration, in the frame of the motor.

IsMovingReturn whether the motor is actively moving (or attempting to move) under its own power.

StopCut the power to the motor immediately, without any gradual step down.

ReconfigureReconfigure this resource.

DoCommandExecute model-specific commands that are not otherwise defined by the component API.

FromRobotGet the resource from the provided robot with the given name.

GetResourceNameGet the ResourceName for this motor with the given name.

CloseSafely shut down the resource and prevent further use.

Movement Sensor

The movement sensor component supports the following methods. Some methods are only supported by certain models:

Method NameDescriptionModels That Support This Methodmicro-RDK Support
GetPositionGet the current latitude, longitude and altitude.GPS models, wheeled-odometry

GetLinearVelocityGet the current linear velocity as a 3D vector.GPS models, wheeled-odometry

GetAngularVelocityGet the current angular velocity as a 3D vector.IMU models, gyro-mpu6050, and wheeled-odometry

GetLinearAccelerationGet the current linear acceleration as a 3D vector.IMU models, accel-adxl345, and gyro-mpu6050

GetCompassHeadingGet the current compass heading in degrees.GPS models

GetOrientationGet the current orientation.IMU models, wheeled-odometry

GetPropertiesGet the supported properties of this sensor.all models

GetAccuracyGet the accuracy of the various sensors.GPS models

GetReadingsObtain the measurements/data specific to this sensor.all models

GetGeometriesGet all the geometries associated with the movement sensor in its current configuration, in the frame of the movement sensor.all models

DoCommandSend or receive model-specific commands.all models

CloseSafely shut down the resource and prevent further use.all models

Power Sensor

The power sensor component supports the following methods:

Method NameDescription
GetCurrentReturn the current of a specified device and whether it is AC or DC.
GetVoltageReturn the voltage of a specified device and whether it is AC or DC.
GetPowerReturn the power consumption of a specified device in watts.
GetGeometriesGet all the geometries associated with the power sensor in its current configuration, in the frame of the power sensor.
GetReadingsGet all measurements or readings that this power sensor provides.
DoCommandExecute model-specific commands that are not otherwise defined by the component API.
CloseSafely shut down the resource and prevent further use.

Sensor

The sensor component supports the following methods:

Method NameDescription
GetReadingsGet the measurements or readings that this sensor provides.
GetGeometriesGet all the geometries associated with the sensor in its current configuration, in the frame of the sensor.
DoCommandSend or receive model-specific commands.
CloseSafely shut down the resource and prevent further use.

Servo

The servo component supports the following methods:

Method NameDescription
MoveMove the servo to the desired angle.
GetPositionGet the current angle of the servo.
StopStop the servo.
GetGeometriesGet all the geometries associated with the servo in its current configuration, in the frame of the servo.
DoCommandSend or receive model-specific commands.
CloseSafely shut down the resource and prevent further use.

Service APIs

These APIs provide interfaces for controlling and getting information from the services you configured on a machine. Built-in API methods are defined for each service implementation. Documentation on using these methods in your SDK code is found on service pages as follows:

Base Remote Control

The base remote control service supports the following methods:

Method NameDescription
ControllerInputsGet a list of inputs from the controller that are being monitored for that control mode.
ReconfigureReconfigure this resource.
DoCommandExecute model-specific commands that are not otherwise defined by the service API.
CloseClose out of all remote control related systems.

Data Management

The data management service supports the following methods:

Method NameDescriptionmicro-RDK Support
SyncSync data stored on the machine to the cloud.

ReconfigureReconfigure this resource.

DoCommandExecute model-specific commands that are not otherwise defined by the service API.

CloseSafely shut down the resource and prevent further use.

Generic

The generic service supports the following methods:

Method NameDescription
DoCommandExecute model-specific commands.
GetResourceNameGet the ResourceName for this instance of the generic service with the given name.
CloseSafely shut down the resource and prevent further use.

ML Model

The ML model service supports the following methods:

Method NameDescription
InferTake an already ordered input tensor as an array, make an inference on the model, and return an output tensor map.
MetadataGet the metadata: name, data type, expected tensor/array shape, inputs, and outputs associated with the ML model.
ReconfigureReconfigure this resource.
DoCommandExecute model-specific commands that are not otherwise defined by the service API.
GetResourceNameGet the ResourceName for this instance of the ML model service with the given name.
CloseSafely shut down the resource and prevent further use.

Motion

The motion service supports the following methods:

Method NameDescription
MoveThe Move method is the primary way to move multiple components, or to move any object to any other location.
MoveOnMapMove a base component to a destination pose on a SLAM map.
MoveOnGlobeMove a base component to a destination GPS point, represented in geographic notation (latitude, longitude).
GetPoseGetPose gets the location and orientation of a component within the frame system.
StopPlanStop a base component being moved by an in progress MoveOnGlobe or MoveOnMap call.
ListPlanStatusesReturns the statuses of plans created by MoveOnGlobe or MoveOnMap calls that meet at least one of the following conditions since the motion service initialized: - the plan’s status is in progress - the plan’s status changed state within the last 24 hours All repeated fields are in chronological order.
GetPlanBy default, returns the plan history of the most recent MoveOnGlobe or MoveOnMap call to move a base component.
ReconfigureReconfigure this resource.
DoCommandExecute model-specific commands that are not otherwise defined by the service API.
GetResourceNameGet the ResourceName for this instance of the motion service with the given name.
CloseSafely shut down the resource and prevent further use.

The navigation service supports the following methods:

Method NameDescription
GetModeGet the Mode the service is operating in.
SetModeSet the Mode the service is operating in.
GetLocationGet the current location of the robot in the navigation service.
GetWaypointsGet an array of waypoints currently in the service’s data storage.
AddWaypointAdd a waypoint to the service’s data storage.
RemoveWaypointRemove a waypoint from the service’s data storage.
GetObstaclesGet an array or list of the obstacles currently in the service’s data storage.
GetPathsGet each path, the series of geo points the robot plans to travel through to get to a destination waypoint, in the machine’s motion planning.
GetPropertiesGet information about the navigation service.
ReconfigureReconfigure this resource.
DoCommandExecute model-specific commands that are not otherwise defined by the service API.
GetResourceNameGet the ResourceName for this instance of the navigation service with the given name.
CloseSafely shut down the resource and prevent further use.

SLAM

The Simultaneous Localization And Mapping (SLAM) service supports the following methods:

Method NameDescription
GetPositionGet the current position of the component the SLAM service is configured to source point cloud data from in the SLAM map as a Pose.
GetPointCloudMapGet the point cloud map.
GetInternalStateGet the internal state of the SLAM algorithm required to continue mapping/localization.
GetPropertiesGet information about the current SLAM session.
InternalStateFullInternalStateFull concatenates the streaming responses from InternalState into the internal serialized state of the SLAM algorithm.
PointCloudMapFullPointCloudMapFull concatenates the streaming responses from PointCloudMap into a full point cloud.
ReconfigureReconfigure this resource.
DoCommandExecute model-specific commands that are not otherwise defined by the service API.
GetResourceNameGet the ResourceName for this instance of the SLAM service with the given name.
CloseSafely shut down the resource and prevent further use.

Vision

Different vision service models support different methods:

Method NameDescription
GetDetectionsFromCameraGet a list of detections from the next image from a specified camera using a configured detector.
GetDetectionsGet a list of detections from a given image using a configured detector.
GetClassificationsFromCameraGet a list of classifications from the next image from a specified camera using a configured classifier.
GetClassificationsGet a list of classifications from a given image using a configured classifier.
GetObjectPointCloudsGet a list of 3D point cloud objects and associated metadata in the latest picture from a 3D camera (using a specified segmenter).
CaptureAllFromCameraGet the next image, detections, classifications, and objects all together, given a camera name.
ReconfigureReconfigure this resource.
DoCommandExecute model-specific commands that are not otherwise defined by the service API.
FromRobotGet the resource from the provided robot with the given name.
GetResourceNameGet the ResourceName for this instance of the Vision service with the given name.
GetPropertiesFetch information about which vision methods a given vision service supports.
CloseSafely shut down the resource and prevent further use.

ResourceBase methods

In the Python SDK, the ResourceBase class defines a basic set of API methods that all child resources should provide for users. In the other SDKs, resource APIs implement but do not inherit these base requirements.

ResourceBase methods include:

FromRobot

Get a resource configured on a machine by "name".

Parameters:

Returns:

  • (Resource): The named resource if it exists on your machine. For example, an arm.
my_arm = Arm.from_robot(robot, "my_arm")

For more information, see the Python SDK Docs.

Parameters:

Returns:

  • (Resource): The named resource if it exists on your machine. For example, an arm.
my_arm = arm.FromRobot(robot, "my_arm")

For more information, see the Go SDK Docs.

In the TypeScript SDK, the equivalent of the FromRobot is defined in each resource API’s client constructor.

For example, a component with type arm and name my_arm belonging to a machine robot is instantiated as follows:

Parameters:

Returns:

const myArmClient = new VIAM.ArmClient(robot, "my_arm");

For more information, see the Typescript SDK Docs.

Name

Get the ResourceName of a resource with the configured name.

Parameters:

  • name (str): The name of the resource.

Returns:

my_arm_name = my_arm.get_resource_name("my_arm")

For more information, see the Python SDK Docs.

Get the Name of the resource.

Parameters:

  • None

Returns:

  • name (Name): The Name of the resource, including fields for the API with Type and SubtypeName, and string Remote and Name.
MyArmName := MyArm.Name()

For more information, see the Go SDK Docs.

DoCommand

DoCommand sends commands containing arbitrary data to the resource.

Parameters:

Returns:

my_board = Board.from_robot(robot=robot, name="my_board")

my_command = {
  "command": "dosomething",
  "someparameter": 52
}

await my_board.do_command(my_command)

For more information, see the Python SDK Docs.

Parameters:

Returns:

myBoard, err := board.FromRobot(machine, "my_board")

resp, err := myBoard.DoCommand(ctx, map[string]interface{}{"command": "dosomething", "someparameter": 52})

For more information, see the Go SDK Docs.

Parameters:

Returns:

For more information, see the Typescript SDK Docs.