viam.services.motion.client
Module Contents
Classes
Motion is a Viam service that coordinates motion planning across all of the components in a given robot. |
- class viam.services.motion.client.MotionClient(name: str, channel: grpclib.client.Channel)[source]
Bases:
viam.services.service_client_base.ServiceClientBase
,viam.resource.rpc_client_base.ReconfigurableResourceRPCClientBase
Motion is a Viam service that coordinates motion planning across all of the components in a given robot.
The motion planning service calculates a valid path that avoids self collision by default. If additional constraints are supplied in the
world_state
message, the motion planning service will also account for those.- SUBTYPE: Final
- async move(component_name: viam.proto.common.ResourceName, destination: viam.proto.common.PoseInFrame, world_state: Optional[viam.proto.common.WorldState] = None, constraints: Optional[viam.proto.service.motion.Constraints] = None, *, extra: Optional[Mapping[str, Any]] = None, timeout: Optional[float] = None) bool [source]
Plan and execute a movement to move the component specified to its goal destination.
Note: Frames designated with respect to components can also be used as the
component_name
when calling for a move. This technique allows for planning and moving the frame itself to thedestination
. To do so, simply create a resource name with originating ReferenceFrame’s name. Then pass in the resource name intocomponent_name
. Ex:resource_name = Arm.get_resource_name("externalFrame") success = await MotionServiceClient.move(resource_name, ...)
- Parameters:
component_name (viam.proto.common.ResourceName) – Name of a component on a given robot.
destination (viam.proto.common.PoseInFrame) – The destination to move to, expressed as a
Pose
and the frame in which it was observed.world_state (viam.proto.common.WorldState) – When supplied, the motion service will create a plan that obeys any contraints expressed in the WorldState message.
constraints (viam.proto.service.motion.Constraints) – When supplied, the motion service will create a plan that obeys any specified constraints
- Returns:
Whether the move was successful
- Return type:
bool
- async move_on_globe(component_name: viam.proto.common.ResourceName, destination: viam.proto.common.GeoPoint, movement_sensor_name: viam.proto.common.ResourceName, obstacles: Optional[Sequence[viam.proto.common.GeoObstacle]] = None, heading: Optional[float] = None, configuration: Optional[viam.proto.service.motion.MotionConfiguration] = None, *, extra: Optional[Mapping[str, viam.utils.ValueTypes]] = None, timeout: Optional[float] = None) bool [source]
Move a component to a specific latitude and longitude, using a
MovementSensor
to check the location.- Parameters:
component_name (ResourceName) – The component to move
destination (GeoPoint) – The destination point
movement_sensor_name (ResourceName) – The
MovementSensor
which will be used to check robot locationobstacles (Optional[Sequence[GeoObstacle]], optional) – Obstacles to be considered for motion planning. Defaults to None.
heading (Optional[float], optional) – Compass heading to achieve at the destination, in degrees [0-360). Defaults to None.
linear_meters_per_sec (Optional[float], optional) – Linear velocity to target when moving. Defaults to None.
angular_deg_per_sec (Optional[float], optional) – Angular velocity to target when turning. Defaults to None.
- Returns:
Whether the request was successful
- Return type:
bool
- async move_on_map(component_name: viam.proto.common.ResourceName, destination: viam.proto.common.Pose, slam_service_name: viam.proto.common.ResourceName, *, extra: Optional[Mapping[str, viam.utils.ValueTypes]] = None, timeout: Optional[float] = None) bool [source]
Move a component to a specific pose, using a
SlamService
for the SLAM map- Parameters:
component_name (ResourceName) – The component to move
destination (Pose) – The destination, which can be any pose with respect to the SLAM map’s origin
slam_service_name (ResourceName) – The slam service from which the SLAM map is requested
- Returns:
Whether the request was successful
- Return type:
bool
- async get_pose(component_name: viam.proto.common.ResourceName, destination_frame: str, supplemental_transforms: Optional[List[viam.proto.common.Transform]] = None, *, extra: Optional[Mapping[str, Any]] = None, timeout: Optional[float] = None) viam.proto.common.PoseInFrame [source]
Get the Pose and observer frame for any given component on a robot. A
component_name
can be created like this:component_name = Arm.get_resource_name("arm")
Note that the example uses the
Arm
class, but any component class that inherits fromComponentBase
will work (Base
,Gripper
, etc).- Parameters:
component_name (viam.proto.common.ResourceName) – Name of a component on a robot.
destination_frame (str) – Name of the desired reference frame.
supplemental_transforms (Optional[List[viam.proto.common.Transform]]) – Transforms used to augment the robot’s frame while calculating pose.
- Returns:
Pose of the given component and the frame in which it was observed.
- Return type:
Pose
(PoseInFrame)
- async do_command(command: Mapping[str, viam.utils.ValueTypes], *, timeout: Optional[float] = None) Mapping[str, viam.utils.ValueTypes] [source]
Send/receive arbitrary commands
- Parameters:
command (Dict[str, ValueTypes]) – The command to execute
- Returns:
Result of the executed command
- Return type:
Dict[str, ValueTypes]
- classmethod from_robot(robot: viam.robot.client.RobotClient, name: str = 'builtin') typing_extensions.Self
Get the service client named
name
from the provided robot.- Parameters:
robot (RobotClient) – The robot
name (str) – The name of the service client
- Returns:
The service client, if it exists on the robot
- Return type:
Self
- 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 theOperation
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:
- async close()
Safely shut down the resource and prevent further use.
Close must be idempotent. Later configuration may allow a resource to be “open” again. If a resource does not want or need a close function, it is assumed that the resource does not need to retun errors when future non-Close methods are called.