Robot Command

For clients to the robot command service.

exception bosdyn.client.robot_command.RobotCommandResponseError(response, error_message=None)[source]

Bases: bosdyn.client.exceptions.ResponseError

General class of errors for RobotCommand service.

exception bosdyn.client.robot_command.Error[source]

Bases: bosdyn.client.exceptions.Error

Base class for non-response errors in this module.

exception bosdyn.client.robot_command.NoTimeSyncError(response, error_message=None)[source]

Bases: bosdyn.client.robot_command.RobotCommandResponseError

Client has not done timesync with robot.

exception bosdyn.client.robot_command.ExpiredError(response, error_message=None)[source]

Bases: bosdyn.client.robot_command.RobotCommandResponseError

The command was received after its max_duration had already passed.

exception bosdyn.client.robot_command.TooDistantError(response, error_message=None)[source]

Bases: bosdyn.client.robot_command.RobotCommandResponseError

The command end time was too far in the future.

exception bosdyn.client.robot_command.NotPoweredOnError(response, error_message=None)[source]

Bases: bosdyn.client.robot_command.RobotCommandResponseError

The robot must be powered on to accept a command.

exception bosdyn.client.robot_command.NotClearedError(response, error_message=None)[source]

Bases: bosdyn.client.robot_command.RobotCommandResponseError

Behavior fault could not be cleared.

exception bosdyn.client.robot_command.UnsupportedError(response, error_message=None)[source]

Bases: bosdyn.client.robot_command.RobotCommandResponseError

The API supports this request, but the system does not support this request.

exception bosdyn.client.robot_command.CommandFailedError[source]

Bases: bosdyn.client.robot_command.Error

Command indicated it failed in its feedback.

exception bosdyn.client.robot_command.CommandTimedOutError[source]

Bases: bosdyn.client.robot_command.Error

Timed out waiting for SUCCESS response from robot command.

exception bosdyn.client.robot_command.UnknownFrameError(response, error_message=None)[source]

Bases: bosdyn.client.robot_command.RobotCommandResponseError

Robot does not know how to handle supplied frame.

class bosdyn.client.robot_command.RobotCommandClient[source]

Bases: bosdyn.client.common.BaseClient

Client for calling RobotCommand services.

default_service_name = 'robot-command'
service_type = 'bosdyn.api.RobotCommandService'
update_from(other)[source]

Update instance from another object.

Parameters

other – The object where to copy from.

property timesync_endpoint

Accessor for timesync-endpoint that was grabbed via ‘update_from()’.

robot_command(command, end_time_secs=None, timesync_endpoint=None, lease=None, **kwargs)[source]

Issue a command to the robot synchronously.

Parameters
  • command – Command to issue.

  • end_time_secs – End time for the command in seconds.

  • timesync_endpoint – Timesync endpoint.

  • lease – Lease object to use for the command.

Returns

Id of the issued robot command.

Raises
robot_command_async(command, end_time_secs=None, timesync_endpoint=None, lease=None, **kwargs)[source]

Async version of robot_command().

Parameters
  • command – Command to issue.

  • end_time_secs – End time for the command in seconds.

  • timesync_endpoint – Timesync endpoint.

  • lease – Lease object to use for the command.

Returns

Id of the issued robot command.

Raises
robot_command_feedback(robot_command_id, **kwargs)[source]

Get feedback from a previously issued command.

Parameters

robot_command_id – Id of the robot command to get feedback on.

Raises

RpcError – Problem communicating with the robot.

robot_command_feedback_async(robot_command_id, **kwargs)[source]

Async version of robot_command_feedback().

Parameters

robot_command_id – Id of the robot command to get feedback on.

Raises

RpcError – Problem communicating with the robot.

clear_behavior_fault(behavior_fault_id, lease=None, **kwargs)[source]

Clear a behavior fault on the robot.

Parameters
  • behavior_fault_id – Id of the behavior fault.

  • lease – Lease information to use in the message.

Returns

Boolean whether response status is STATUS_CLEARED.

Raises
clear_behavior_fault_async(behavior_fault_id, lease=None, **kwargs)[source]

Async version of clear_behavior_fault().

Parameters
  • behavior_fault_id

  • lease

  • behavior_fault_id – Id of the behavior fault.

  • lease – Lease information to use in the message.

Returns

Boolean whether response status is STATUS_CLEARED.

Raises
class bosdyn.client.robot_command.RobotCommandBuilder[source]

Bases: object

This class contains a set of static helper functions to build and issue robot commands.

This is not intended to cover every use case, but rather give developers a starting point for issuing commands to the robot.The robot command proto uses several advanced protobuf techniques, including the use of Any and OneOf.

A RobotCommand is composed of one or more commands. The set of valid commands is robot / hardware specific. An armless spot only accepts one command at a time. Each command may or may not takes a generic param object. These params are also robot / hardware dependent.

static stop_command()[source]

Command to stop with minimal motion. If the robot is walking, it will transition to stand. If the robot is standing or sitting, it will do nothing.

Returns

RobotCommand, which can be issued to the robot command service.

static freeze_command()[source]

Command to freeze all joints at their current positions (no balancing control)

Returns

RobotCommand, which can be issued to the robot command service.

static selfright_command()[source]

Command to get the robot in a ready, sitting position. If the robot is on its back, it will attempt to flip over.

Returns

RobotCommand, which can be issued to the robot command service.

static safe_power_off_command()[source]

Command to get robot into a position where it is safe to power down, then power down. If the robot has fallen, it will power down directly. If the robot is not in a safe position, it will get to a safe position before powering down. The robot will not power down until it is in a safe state.

Returns

RobotCommand, which can be issued to the robot command service.

static trajectory_command(goal_x, goal_y, goal_heading, frame_name, params=None, body_height=0.0, locomotion_hint=1)[source]

Command robot to move to pose along a 2D plane. Pose can specified in the world (kinematic odometry) frame or the robot body frame. The arguments body_height and locomotion_hint are ignored if params argument is passed.

A trajectory command requires an end time. End time is not set in this function, but rather is set externally before call to RobotCommandService.

Parameters
  • goal_x – Position X coordinate.

  • goal_y – Position Y coordinate.

  • goal_heading – Pose heading in radians.

  • frame_name – Name of the frame to use.

  • params (spot.MobilityParams) – Spot specific parameters for mobility commands. If not set, this will be constructed using other args.

  • body_height – Body height in meters.

  • locomotion_hint – Locomotion hint to use for the trajectory command.

Returns

RobotCommand, which can be issued to the robot command service.

static velocity_command(v_x, v_y, v_rot, params=None, body_height=0.0, locomotion_hint=1, frame_name='body')[source]

Command robot to move along 2D plane. Velocity should be specified in the robot body frame. Other frames are currently not supported. The arguments body_height and locomotion_hint are ignored if params argument is passed.

A velocity command requires an end time. End time is not set in this function, but rather is set externally before call to RobotCommandService.

Parameters
  • v_x – Velocity in X direction.

  • v_y – Velocity in Y direction.

  • v_rot – Velocity heading in radians.

  • params (spot.MobilityParams) – Spot specific parameters for mobility commands. If not set, this will be constructed using other args.

  • body_height – Body height in meters.

  • locomotion_hint – Locomotion hint to use for the velocity command.

  • frame_name – Name of the frame to use.

Returns

RobotCommand, which can be issued to the robot command service.

static stand_command(params=None, body_height=0.0, footprint_R_body=<bosdyn.geometry.EulerZXY object>)[source]

Command robot to stand. If the robot is sitting, it will stand up. If the robot is moving, it will come to a stop. Params can specify a trajectory for the body to follow while standing. In the simplest case, this can be a specific position+orientation which the body will hold at. The arguments body_height and footprint_R_body are ignored if params argument is passed.

Parameters
  • params (spot.MobilityParams) – Spot specific parameters for mobility commands. If not set, this will be constructed using other args.

  • body_height (float) – Height, meters, to stand at relative to a nominal stand height.

  • footprint_R_body (EulerZXY) – The orientation of the body frame with respect to the footprint frame (gravity aligned framed with yaw computed from the stance feet)

Returns

RobotCommand, which can be issued to the robot command service.

static sit_command(params=None)[source]

Command the robot to sit.

Parameters

params (spot.MobilityParams) – Spot specific parameters for mobility commands.

Returns

RobotCommand, which can be issued to the robot command service.

static mobility_params(body_height=0.0, footprint_R_body=<bosdyn.geometry.EulerZXY object>, locomotion_hint=1, stair_hint=False, external_force_params=None)[source]

Helper to create Mobility params for spot mobility commands. This function is designed to help get started issuing commands, but lots of options are not exposed via this interface. See spot.robot_command_pb2 for more details. If unset, good defaults will be chosen by the robot.

Parameters
  • body_height – Body height in meters.

  • footprint_R_body (EulerZXY) – The orientation of the body frame with respect to the footprint frame (gravity aligned framed with yaw computed from the stance feet)

  • locomotion_hint – Locomotion hint to use for the command.

  • stair_hint – Boolean to specify if stair mode should be used.

  • external_force_params (spot.BodyExternalForceParams) – Robot body external force parameters.

Returns

spot.MobilityParams, params for spot mobility commands.

build_body_external_forces(override_external_force_vec=None)[source]

Helper to create Mobility params.

This function allows the user to enable an external force estimator, or set a vector of forces (in the body frame) which override the estimator with constant external forces.

Parameters
  • external_force_indicator – Indicates if the external force estimator should be enabled/disabled or an override force should be used. Can be specified as one of three values: spot_command_pb2.BodyExternalForceParams.{ EXTERNAL_FORCE_NONE, EXTERNAL_FORCE_USE_ESTIMATE, EXTERNAL_FORCE_USE_OVERRIDE }

  • override_external_force_vec – x/y/z list of forces in the body frame. Only used when the indicator specifies EXTERNAL_FORCE_USE_OVERRIDE

Returns

spot.MobilityParams, params for spot mobility commands.

bosdyn.client.robot_command.blocking_stand(command_client, timeout_sec=10, update_frequency=1.0)[source]

Helper function which uses the RobotCommandService to stand.

Blocks until robot is standing, or raises an exception if the command times out or fails.

Parameters
  • command_client – RobotCommand client.

  • timeout_sec – Timeout for the command in seconds.

  • update_frequency – Update frequency for the command in Hz.

Raises