Pose tracker API
The pose tracker API allows you to get the poses of the bodies that a pose tracker component tracks.
A body is any named thing that a pose tracker reports a pose for.
What counts as a body depends on the model: an AprilTag, a calibration board, a tracked controller, or a candidate grasp for an object.
For example, the viam:apriltag:pose_tracker model names each body by its tag ID, such as "0" or "7".
Each pose is a PoseInFrame: a position and orientation, plus the name of the reference frame the pose is relative to.
Each model chooses that frame.
For example, viam:apriltag:pose_tracker reports poses in the frame of its camera, and viam-labs:grasp-pose:top-down reports poses in the world frame.
Pose tracker models
The following public models in the Viam registry implement the pose tracker API:
| Model | Bodies |
|---|---|
viam:apriltag:pose_tracker | AprilTags a camera sees |
viam:camera-calibration:charuco | A ChArUco calibration board |
viam:opencv:charuco | A ChArUco calibration board |
viam:opencv:chessboard | A chessboard calibration pattern |
viam-labs:grasp-pose:top-down | Ranked top-down grasp poses for the objects a vision service detects |
viam-labs:teach-frames:pose-tracker | Workcell frames you teach by moving an arm |
Methods
The pose tracker component supports the following methods:
| Method Name | Description |
|---|---|
GetPoses | Get the current pose of each body the pose tracker tracks, as a map from body name to a pose in a reference frame. |
GetGeometries | Get all the geometries associated with the pose tracker in its current configuration, in the frame of the pose tracker. |
Reconfigure | Reconfigure this resource. |
DoCommand | Execute model-specific commands that are not otherwise defined by the component API. |
GetStatus | Get the current status of the pose tracker as a map of key-value pairs describing its state. |
GetResourceName | Get the ResourceName for this pose tracker. |
Close | Safely shut down the resource and prevent further use. |
API
GetPoses
Get the current pose of each body the pose tracker tracks, as a map from body name to a pose in a reference frame. Pass a list of body names to get only those bodies, or an empty list to get every body the pose tracker can currently report. Each model chooses the reference frame of its poses, so check the reference frame of each returned pose.
Parameters:
body_names(List[str]) (required): Names of the bodies whose poses are being requested. In the event this parameter is not supplied or is an empty list, all available poses are returned.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:
- (Dict[str, viam.proto.common.PoseInFrame])
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.bodyNames([]string)extra(map[string]interface{}): Extra options to pass to the underlying RPC call.
Returns:
- (referenceframe.FrameSystemPoses)
- (error): An error, if one occurred.
For more information, see the Go SDK Docs.
Parameters:
Returns:
Example:
// Get the poses of specific bodies
var poses = await myPoseTracker.poses(['left_hand', 'right_hand']);
var leftHand = poses['left_hand'];
// Get the poses of every tracked body
var allPoses = await myPoseTracker.poses([]);
For more information, see the Flutter SDK Docs.
GetGeometries
Get all the geometries associated with the pose tracker in its current configuration, in the frame of the pose tracker.
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:
- (List[viam.proto.common.Geometry]): The geometries associated with the Component.
Example:
my_pose_tracker = PoseTracker.from_robot(robot=machine, name="my_pose_tracker")
geometries = await my_pose_tracker.get_geometries()
if geometries:
# Get the center of the first geometry
print(f"Pose of the first geometry's centerpoint: {geometries[0].center}")
For more information, see the Python SDK Docs.
Parameters:
extra({}) (optional)callOptions(CallOptions) (optional)
Returns:
Example:
const generic = new VIAM.GenericComponentClient(machine, 'my_generic_component');
// Get the geometries of this component
const geometries = await generic.getGeometries();
console.log('Geometries:', geometries);
For more information, see the TypeScript SDK Docs.
Reconfigure
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:
- (error): An error, if one occurred.
For more information, see the Go SDK Docs.
DoCommand
Execute model-specific commands that are not otherwise defined by the component API.
Most models do not implement DoCommand.
Any available model-specific commands should be covered in the model’s documentation.
If you are implementing your own pose tracker and want to add features that have no corresponding built-in API method, you can implement 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:
- (Mapping[str, viam.utils.ValueTypes]): Result of the executed command.
Raises:
- (NotImplementedError): Raised if the Resource does not support arbitrary commands.
Example:
my_pose_tracker = PoseTracker.from_robot(robot=machine, name="my_pose_tracker")
command = {"cmd": "test", "data1": 500}
result = await my_pose_tracker.do_command(command)
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:
- (map[string]interface{}): The command response.
- (error): An error, if one occurred.
Example:
myPoseTracker, err := pose_tracker.FromProvider(machine, "my_pose_tracker")
command := map[string]interface{}{"cmd": "test", "data1": 500}
result, err := myPoseTracker.DoCommand(context.Background(), command)
For more information, see the Go SDK Docs.
Parameters:
command(Struct | Record<string, JsonValue>) (required): The command to execute. Accepts either aStructor a plain object, which will be converted automatically.callOptions(CallOptions) (optional)
Returns:
- (Promise<JsonValue>)
Example:
// Plain object (recommended)
const result = await resource.doCommand({
myCommand: { key: 'value' },
});
// Struct (still supported)
import { Struct } from '@viamrobotics/sdk';
const result = await resource.doCommand(Struct.fromJson({ myCommand: { key: 'value' } }));
For more information, see the TypeScript SDK Docs.
GetStatus
Get the current status of the pose tracker as a map of key-value pairs describing its state.
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:
- (Mapping[str, viam.utils.ValueTypes]): The status of the component.
Example:
status = await component.get_status()
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:
- (map[string]interface{})
- (error): An error, if one occurred.
Example:
myPoseTracker, err := posetracker.FromProvider(machine, "my_pose_tracker")
status, err := myPoseTracker.Status(context.Background())
For more information, see the Go SDK Docs.
Parameters:
callOptions(CallOptions) (optional)
Returns:
- (Promise<JsonValue>)
For more information, see the TypeScript SDK Docs.
GetResourceName
Get the ResourceName for this pose tracker.
Parameters:
name(str) (required): The name of the Resource.
Returns:
- (viam.proto.common.ResourceName): The ResourceName of this Resource.
Example:
my_pose_tracker_name = PoseTracker.get_resource_name("my_pose_tracker")
For more information, see the Python SDK Docs.
Parameters:
- None.
Returns:
Example:
myPoseTracker, err := posetracker.FromProvider(machine, "my_pose_tracker")
err = myPoseTracker.Name()
For more information, see the Go SDK Docs.
Parameters:
- None.
Returns:
- (string): The name of the resource.
Example:
pose_tracker.name
For more information, see the TypeScript SDK Docs.
Parameters:
nameString (required)
Returns:
Example:
final myPoseTrackerResourceName = myPoseTracker.getResourceName("my_pose_tracker");
For more information, see the Flutter SDK Docs.
Close
Safely shut down the resource and prevent further use.
Parameters:
- None.
Returns:
- None.
Example:
my_pose_tracker = PoseTracker.from_robot(robot=machine, name="my_pose_tracker")
await my_pose_tracker.close()
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:
- (error): An error, if one occurred.
Example:
myPoseTracker, err := posetracker.FromProvider(machine, "my_pose_tracker")
err = myPoseTracker.Close(context.Background())
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!