viam.services.slam

Submodules

Package Contents

Classes

Pose

Pose is a combination of location and orientation.

SLAM

SLAM represents a SLAM service.

class viam.services.slam.Pose(*, x: float = ..., y: float = ..., z: float = ..., o_x: float = ..., o_y: float = ..., o_z: float = ..., theta: float = ...)

Bases: google.protobuf.message.Message

Pose is a combination of location and orientation. Location is expressed as distance which is represented by x , y, z coordinates. Orientation is expressed as an orientation vector which is represented by o_x, o_y, o_z and theta. The o_x, o_y, o_z coordinates represent the point on the cartesian unit sphere that the end of the arm is pointing to (with the origin as reference). That unit vector forms an axis around which theta rotates. This means that incrementing / decrementing theta will perform an inline rotation of the end effector. Theta is defined as rotation between two planes: the first being defined by the origin, the point (0,0,1), and the rx, ry, rz point, and the second being defined by the origin, the rx, ry, rz point and the local Z axis. Therefore, if theta is kept at zero as the north/south pole is circled, the Roll will correct itself to remain in-line.

x: float

millimeters from the origin

y: float

millimeters from the origin

z: float

millimeters from the origin

o_x: float

z component of a vector defining axis of rotation

o_y: float

x component of a vector defining axis of rotation

o_z: float

y component of a vector defining axis of rotation

theta: float

degrees

class viam.services.slam.SLAM(name: str)[source]

Bases: viam.services.service_base.ServiceBase

SLAM represents a SLAM service.

This acts as an abstract base class for any drivers representing specific arm implementations. This cannot be used on its own. If the __init__() function is overridden, it must call the super().__init__() function.

SUBTYPE: Final
abstract async get_internal_state(*, timeout: Optional[float]) List[bytes][source]

Get the internal state of the SLAM algorithm required to continue mapping/localization.

Returns:

Chunks of the internal state of the SLAM algorithm

Return type:

List[GetInternalStateResponse]

abstract async get_point_cloud_map(*, timeout: Optional[float]) List[bytes][source]

Get the point cloud map.

Returns:

Complete pointcloud in standard PCD format. Chunks of the PointCloud, concatenating all

GetPointCloudMapResponse.point_cloud_pcd_chunk values

Return type:

List[GetPointCloudMapResponse]

abstract async get_latest_map_info(*, timeout: Optional[float]) datetime.datetime[source]

Get the timestamp of the last update to the point cloud SLAM map.

Returns:

The timestamp of the last update.

Return type:

datetime

abstract async get_position(*, timeout: Optional[float]) viam.services.slam.Pose[source]

Get current position of the specified component in the SLAM Map.

Returns:

The current position of the specified component

Return type:

Pose

classmethod from_robot(robot: viam.robot.client.RobotClient, name: str) typing_extensions.Self

Get the service named name from the provided robot.

Parameters:
  • robot (RobotClient) – The robot

  • name (str) – The name of the service

Returns:

The service, if it exists on the robot

Return type:

Self

abstract async do_command(command: Mapping[str, viam.utils.ValueTypes], *, timeout: Optional[float] = None, **kwargs) Mapping[str, viam.utils.ValueTypes]

Send/Receive arbitrary commands to the Resource

Parameters:

command (Mapping[str, ValueTypes]) – The command to execute

Raises:

NotImplementedError – Raised if the Resource does not support arbitrary commands

Returns:

Result of the executed command

Return type:

Mapping[str, ValueTypes]

classmethod get_resource_name(name: str) viam.proto.common.ResourceName

Get the ResourceName for this Resource with the given name

Parameters:

name (str) – The name of the Resource

get_operation(kwargs: Mapping[str, Any]) viam.operations.Operation

Get the Operation associated with the currently running function.

When writing custom resources, you should get the Operation by calling this function and check to see if it’s cancelled. If the Operation is cancelled, then you can perform any necessary (terminating long running tasks, cleaning up connections, etc. ).

Parameters:

kwargs (Mapping[str, Any]) – The kwargs object containing the operation

Returns:

The operation associated with this function

Return type:

viam.operations.Operation