Next
Base
The arm API allows you to give commands to your arm components for linear motion planning with self-collision prevention. If you want the arm to avoid obstacles, or you want to plan complex motion in an automated way, use the motion API.
The arm component supports the following methods:
Method Name | Description |
---|---|
GetEndPosition | Get the current position of the arm as a pose. |
MoveToPosition | Move the end of the arm in a straight line to the desired pose, relative to the base of the arm. |
MoveToJointPositions | Move each joint on the arm to the position specified in positions . |
MoveThroughJointPositions | Move the arm’s joints through the given positions in the order they are specified. |
GetJointPositions | Get the current position of each joint on the arm. |
GetKinematics | Get the kinematics information associated with the arm as the format and byte contents of the kinematics file. |
IsMoving | Get if the arm is currently moving. |
Stop | Stop all motion of the arm. |
GetGeometries | Get all the geometries associated with the arm in its current configuration, in the frame of the arm. |
Reconfigure | Reconfigure this resource. |
DoCommand | Execute model-specific commands that are not otherwise defined by the component API. |
GetResourceName | Get the ResourceName for this arm with the given name. |
Close | Safely shut down the resource and prevent further use. |
To get started using Viam’s SDKs to connect to and control your arm and the rest of your machine, go to your machine’s page on the Viam app, Navigate to the CONNECT tab’s Code sample page, select your preferred programming language, and copy the sample code.
To show your machine’s API key in the sample code, toggle Include API key.
We strongly recommend that you add your API key and machine address as an environment variable. Anyone with these secrets can access your machine, and the computer running your machine.
When executed, this sample code creates a connection to your machine as a client.
The following examples assume you have an arm called "my_arm"
configured as a component of your machine.
If your arm has a different name, change the name
in the code.
Import the arm package for the SDK you are using:
Get the current position of the arm as a pose.
Parameters:
extra
(Mapping[str, Any]) (optional): Extra options to pass to the underlying RPC call.timeout
(float) (optional): An option to set how long to wait (in seconds) before calling a time-out and closing the underlying RPC call.Returns:
Example:
For more information, see the Python SDK Docs.
Parameters:
ctx
(Context): A Context carries a deadline, a cancellation signal, and other values across API boundaries.extra
(map[string]interface{}): Extra options to pass to the underlying RPC call.Returns:
Pose
is composed of values for location and orientation with respect to the origin. Location is expressed as distance, which is represented by x, y, and z coordinate values. Orientation is expressed as an orientation vector, which is represented by o_x, o_y, o_z, and theta values.Example:
For more information, see the Go SDK Docs.
Parameters:
extra
(None) (optional)callOptions
(CallOptions) (optional)Returns:
Example:
For more information, see the TypeScript SDK Docs.
Move the end of the arm in a straight line to the desired pose, relative to the base of the arm.
All arms have a Home
position, which corresponds to setting all joint angles to 0.
Parameters:
pose
(viam.components.arm.Pose) (required): The destination Pose for the arm. The Pose is composed of values for location and orientation with respect to the origin. Location is expressed as distance, which is represented by x, y, and z coordinate values. Orientation is expressed as an orientation vector, which is represented by o_x, o_y, o_z, and theta values.extra
(Mapping[str, Any]) (optional): Extra options to pass to the underlying RPC call.timeout
(float) (optional): An option to set how long to wait (in seconds) before calling a time-out and closing the underlying RPC call.Returns:
Example:
For more information, see the Python SDK Docs.
Parameters:
ctx
(Context): A Context carries a deadline, a cancellation signal, and other values across API boundaries.pose
(spatialmath.Pose): A representation of the arm’s destination position as a 6 DOF (six degrees of freedom) pose. The Pose
is composed of values for location and orientation with respect to the origin. Location is expressed as distance, which is represented by x, y, and z coordinate values. Orientation is expressed as an orientation vector, which is represented by o_x, o_y, o_z, and theta values.extra
(map[string]interface{}): Extra options to pass to the underlying RPC call.Returns:
Example:
For more information, see the Go SDK Docs.
Parameters:
pose
(PlainMessage) (required): The destination pose for the arm.extra
(None) (optional)callOptions
(CallOptions) (optional)Returns:
Example:
For more information, see the TypeScript SDK Docs.
Move each joint on the arm to the position specified in positions
.
Collision checks are not enabled when doing direct joint control with MoveToJointPositions().
Parameters:
positions
(viam.proto.component.arm.JointPositions) (required): The destination JointPositions for the arm.extra
(Mapping[str, Any]) (optional): Extra options to pass to the underlying RPC call.timeout
(float) (optional): An option to set how long to wait (in seconds) before calling a time-out and closing the underlying RPC call.Returns:
Example:
For more information, see the Python SDK Docs.
Parameters:
ctx
(Context): A Context carries a deadline, a cancellation signal, and other values across API boundaries.positions
([]referenceframe.Input)extra
(map[string]interface{}): Extra options to pass to the underlying RPC call.Returns:
Example:
For more information, see the Go SDK Docs.
Parameters:
jointPositionsList
(number) (required): List of angles (0-360) to move each joint to.extra
(None) (optional)callOptions
(CallOptions) (optional)Returns:
Example:
For more information, see the TypeScript SDK Docs.
Move the arm’s joints through the given positions in the order they are specified. This will block until done or a new operation cancels this one.
Parameters:
ctx
(Context): A Context carries a deadline, a cancellation signal, and other values across API boundaries.positions
([][]referenceframe.Input)options
(*MoveOptions)extra
(map[string]interface{}): Extra options to pass to the underlying RPC call.Returns:
Example:
For more information, see the Go SDK Docs.
Get the current position of each joint on the arm.
Parameters:
extra
(Mapping[str, Any]) (optional): Extra options to pass to the underlying RPC call.timeout
(float) (optional): An option to set how long to wait (in seconds) before calling a time-out and closing the underlying RPC call.Returns:
Example:
For more information, see the Python SDK Docs.
Parameters:
ctx
(Context): A Context carries a deadline, a cancellation signal, and other values across API boundaries.extra
(map[string]interface{}): Extra options to pass to the underlying RPC call.Returns:
Example:
For more information, see the Go SDK Docs.
Parameters:
extra
(None) (optional)callOptions
(CallOptions) (optional)Returns:
Example:
For more information, see the TypeScript SDK Docs.
This method is not yet available with the Viam Go SDK.
Get the kinematics information associated with the arm as the format and byte contents of the kinematics file.
Parameters:
extra
(Mapping[str, Any]) (optional): Extra options to pass to the underlying RPC call.timeout
(float) (optional): An option to set how long to wait (in seconds) before calling a time-out and closing the underlying RPC call.Returns:
Example:
For more information, see the Python SDK Docs.
Get if the arm is currently moving.
Parameters:
timeout
(float) (optional): An option to set how long to wait (in seconds) before calling a time-out and closing the underlying RPC call.Returns:
Example:
For more information, see the Python SDK Docs.
Parameters:
ctx
(Context): A Context carries a deadline, a cancellation signal, and other values across API boundaries.Returns:
Example:
For more information, see the Go SDK Docs.
Parameters:
callOptions
(CallOptions) (optional)Returns:
Example:
For more information, see the TypeScript SDK Docs.
Stop all motion of the arm.
Parameters:
extra
(Mapping[str, Any]) (optional): Extra options to pass to the underlying RPC call.timeout
(float) (optional): An option to set how long to wait (in seconds) before calling a time-out and closing the underlying RPC call.Returns:
Example:
For more information, see the Python SDK Docs.
Parameters:
ctx
(Context): A Context carries a deadline, a cancellation signal, and other values across API boundaries.extra
(map[string]interface{}): Extra options to pass to the underlying RPC call.Returns:
Example:
For more information, see the Go SDK Docs.
Parameters:
extra
(None) (optional)callOptions
(CallOptions) (optional)Returns:
Example:
For more information, see the TypeScript SDK Docs.
Get all the geometries associated with the arm in its current configuration, in the frame of the arm. The motion and navigation services use the relative position of inherent geometries to configured geometries representing obstacles for collision detection and obstacle avoidance while motion planning.
Parameters:
extra
(Mapping[str, Any]) (optional): Extra options to pass to the underlying RPC call.timeout
(float) (optional): An option to set how long to wait (in seconds) before calling a time-out and closing the underlying RPC call.Returns:
Example:
For more information, see the Python SDK Docs.
Parameters:
ctx
(Context): A Context carries a deadline, a cancellation signal, and other values across API boundaries.extra
(map[string]interface{}): Extra options to pass to the underlying RPC call.Returns:
Example:
For more information, see the Go SDK Docs.
Parameters:
extra
(None) (optional)callOptions
(CallOptions) (optional)Returns:
Example:
For more information, see the TypeScript SDK Docs.
Reconfigure this resource. Reconfigure must reconfigure the resource atomically and in place.
Parameters:
ctx
(Context): A Context carries a deadline, a cancellation signal, and other values across API boundaries.deps
(Dependencies): The resource dependencies.conf
(Config): The resource configuration.Returns:
For more information, see the Go SDK Docs.
Execute model-specific commands that are not otherwise defined by the component API.
For built-in models, model-specific commands are covered with each model’s documentation.
If you are implementing your own arm and add features that have no built-in API method, you can access them with DoCommand
.
Parameters:
command
(Mapping[str, ValueTypes]) (required): The command to execute.timeout
(float) (optional): An option to set how long to wait (in seconds) before calling a time-out and closing the underlying RPC call.Returns:
Raises:
Example:
For more information, see the Python SDK Docs.
Parameters:
ctx
(Context): A Context carries a deadline, a cancellation signal, and other values across API boundaries.cmd
(map[string]interface{}): The command to execute.Returns:
Example:
For more information, see the Go SDK Docs.
Parameters:
command
(Struct) (required): The command to execute.callOptions
(CallOptions) (optional)Returns:
Example:
For more information, see the TypeScript SDK Docs.
Get the ResourceName
for this arm with the given name.
Parameters:
name
(str) (required): The name of the Resource.Returns:
Example:
For more information, see the Python SDK Docs.
Safely shut down the resource and prevent further use.
Parameters:
ctx
(Context): A Context carries a deadline, a cancellation signal, and other values across API boundaries.Returns:
Example:
For more information, see the Go SDK Docs.
Was this page helpful?
Glad to hear it! If you have any other feedback please let us know:
We're sorry about that. To help us improve, please tell us what we can do better:
Thank you!