Previous
Generic
The SLAM service API allows you to get a machine’s position within a map.
The SLAM service supports the following methods:
Method Name | Description |
---|---|
GetPosition | Get the current position of the component the SLAM service is configured to source point cloud data from in the SLAM map as a Pose . |
GetPointCloudMap | Get the point cloud map. |
GetInternalState | Get the internal state of the SLAM algorithm required to continue mapping/localization. |
GetProperties | Get information about the current SLAM session. |
InternalStateFull | InternalStateFull concatenates the streaming responses from InternalState into the internal serialized state of the SLAM algorithm. |
PointCloudMapFull | PointCloudMapFull concatenates the streaming responses from PointCloudMap into a full point cloud. |
Reconfigure | Reconfigure this resource. |
DoCommand | Execute model-specific commands that are not otherwise defined by the service API. |
GetResourceName | Get the ResourceName for this instance of the SLAM service with the given name. |
Close | Safely shut down the resource and prevent further use. |
Get the current position of the component the SLAM service is configured to source point cloud data from in the SLAM map as a Pose
.
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:
slam_svc = SLAMClient.from_robot(robot=machine, name="my_slam_service")
# Get the current position of the specified source component in the SLAM map as a Pose.
pose = await slam.get_position()
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:
Pose
representing the current position of the specified component.Example:
// Get the current position of the specified source component
// in the SLAM map as a Pose.
pos, name, err := mySLAMService.Position(context.Background())
For more information, see the Go SDK Docs.
Parameters:
callOptions
(CallOptions) (optional)Returns:
Example:
const slam = new VIAM.SlamClient(machine, "my_slam");
// Get the current position of the robot in the SLAM map
const position = await slam.getPosition();
console.log("Current position:", position);
For more information, see the TypeScript SDK Docs.
Get the point cloud map.
Parameters:
return_edited_map
(bool) (required): signal to the SLAM service to return an edited map, if the map package contains one and if the SLAM service supports the feature.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:
slam_svc = SLAMClient.from_robot(robot=machine, name="my_slam_service")
# Get the point cloud map in standard PCD format.
pcd_map = await slam_svc.get_point_cloud_map()
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.returnEditedMap
(bool)Returns:
For more information, see the Go SDK Docs.
Parameters:
returnEditedMap
(boolean) (optional)callOptions
(CallOptions) (optional)Returns:
Example:
const slam = new VIAM.SlamClient(machine, "my_slam");
// Get the point cloud map
const pointCloudMap = await slam.getPointCloudMap();
// Get the edited point cloud map
const editedMap = await slam.getPointCloudMap(true);
For more information, see the TypeScript SDK Docs.
Get the internal state of the SLAM algorithm required to continue mapping/localization.
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:
slam = SLAMClient.from_robot(robot=machine, name="my_slam_service")
# Get the internal state of the SLAM algorithm required to continue mapping/localization.
internal_state = await slam.get_internal_state()
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:
For more information, see the Go SDK Docs.
Parameters:
callOptions
(CallOptions) (optional)Returns:
Example:
const slam = new VIAM.SlamClient(machine, "my_slam");
// Get the internal state of the SLAM algorithm
const internalState = await slam.getInternalState();
For more information, see the TypeScript SDK Docs.
Get information about the current SLAM session.
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:
slam_svc = SLAMClient.from_robot(robot=machine, name="my_slam_service")
# Get the properties of your current SLAM session.
slam_properties = await slam_svc.get_properties()
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:
(Properties): Information about the current SLAM session. An object containing four fields:
SensorInfo
(SensorInfo[]): Information about the sensors (camera and movement sensor) configured for your SLAM service, including the name and type of sensor.
CloudSlam
(bool): A boolean which indicates whether the session is being run in the cloud.
MappingMode
(MappingMode): Represents the form of mapping and localizing the current session is performing. This includes creating a new map, localizing on an existing map and updating an existing map.
InternalStateFileType
(string): The file type the service’s internal state algorithm is stored in.
(error): An error, if one occurred.
Example:
// Get the properties of your current SLAM session
properties, err := mySLAMService.Properties(context.Background())
For more information, see the Go SDK Docs.
Parameters:
callOptions
(CallOptions) (optional)Returns:
Example:
const slam = new VIAM.SlamClient(machine, "my_slam");
// Get the properties of the SLAM service
const properties = await slam.getProperties();
console.log("SLAM properties:", properties);
For more information, see the TypeScript SDK Docs.
InternalStateFull
concatenates the streaming responses from InternalState
into the internal serialized state of the SLAM algorithm.
Parameters:
ctx
(Context): A Context carries a deadline, a cancellation signal, and other values across API boundaries.slamSvc
(Service): The SLAM service name to fetch the internal state for.Returns:
For more information, see the Go SDK Docs.
PointCloudMapFull
concatenates the streaming responses from PointCloudMap
into a full point cloud.
Parameters:
ctx
(Context): A Context carries a deadline, a cancellation signal, and other values across API boundaries.slamSvc
(Service): The SLAM service name to fetch the point cloud map for.returnEditedMap
(bool): A boolean representing whether to return the edited map (true
) or not (false
).Returns:
For more information, see the Go 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 service 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 SLAM service 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:
Example:
my_slam_svc = SLAMClient.from_robot(robot=machine, "my_slam_svc")
my_command = {
"cmnd": "dosomething",
"someparameter": 52
}
await my_slam_svc.do_command(command=my_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:
Example:
mySLAMService, err := slam.FromRobot(machine, "my_slam_svc")
command := map[string]interface{}{"cmd": "test", "data1": 500}
result, err := mySLAMService.DoCommand(context.Background(), command)
For more information, see the Go SDK Docs.
Parameters:
command
(Struct) (required): The command to execute.callOptions
(CallOptions) (optional)Returns:
Example:
import { Struct } from "@viamrobotics/sdk";
const result = await resource.doCommand(
Struct.fromJson({
myCommand: { key: "value" },
}),
);
For more information, see the TypeScript SDK Docs.
Get the ResourceName
for this instance of the SLAM service with the given name.
Parameters:
name
(str) (required): The name of the Resource.Returns:
Example:
my_slam_svc_name = SLAMClient.get_resource_name("my_slam_svc")
For more information, see the Python SDK Docs.
Safely shut down the resource and prevent further use.
Parameters:
Returns:
Example:
my_slam_svc = SLAMClient.from_robot(robot=machine, name="my_slam_svc")
await my_slam_svc.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:
Example:
mySlamSvc, err := slam.FromRobot(machine, "my_slam_svc")
err = mySlamSvc.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!