Robot

Settings common to a user’s access to one robot.

exception bosdyn.client.robot.RobotError[source]

Bases: bosdyn.client.exceptions.Error

General class of errors to handle non-response non-grpc errors.

exception bosdyn.client.robot.UnregisteredServiceError[source]

Bases: bosdyn.client.robot.RobotError

Full service definition has not been registered in the robot instance.

exception bosdyn.client.robot.UnregisteredServiceNameError(service_name)[source]

Bases: bosdyn.client.robot.UnregisteredServiceError

Service name has not been registered in the robot instance.

exception bosdyn.client.robot.UnregisteredServiceTypeError(service_type)[source]

Bases: bosdyn.client.robot.UnregisteredServiceError

Service type has not been registered in the robot instance.

class bosdyn.client.robot.Robot(name=None)[source]

Bases: object

Settings common to one user’s access to one robot.

This is the main point of access to all client functionality. The ensure_client member is used to get any client to a service exposed on the robot. Additionally, many helpers are exposed to provide commonly used functionality without explicitly accessing a particular client object.

Note that any rpc call made to the robot can raise an RpcError subclass if there are errors communicating with the robot. Additionally, ResponseErrors will be raised if there was an error acting on the request itself. An InvalidRequestError indicates a programming error, where the request was malformed in some way. InvalidRequestErrors will never be thrown except in the case of client bugs.

See also Sdk and BaseClient

setup_token_cache(token_cache=None, unique_id=None)[source]

Instantiates a token cache to persist the user token.

If the user provides a cache, it will be saved in the robot object for convenience.

update_from(other)[source]

Adds to this object’s processors, etc based on other

ensure_client(service_name, channel=None, options=[])[source]

Ensure a Client for a given service. Note: If a new service has been registered with the directory service, this may raise UnregisteredServiceNameError when trying to connect to it until sync_with_directory() is called.

Parameters
  • service_name – The name of the service.

  • channel – gRPC channel object to use. Default None, in which case the Sdk data is used to generate a channel. The channel will become associated with the client.

Raises
get_cached_robot_id()[source]

Return the RobotId proto for this robot, querying it from the robot if not yet cached.

Raises

RpcError – There as a problem communicating with the robot.

ensure_channel(service_name, options=[])[source]

Verify the right information exists before calling the ensure_secure_channel method.

Parameters

service_name – Name of the service in the directory.

Returns

Existing channel if found, or newly created channel if not found.

Raises
ensure_secure_channel(authority, skip_app_token_check=False, options=[])[source]

Get the channel to access the given authority, creating it if it doesn’t exist.

authenticate(username, password, timeout=None)[source]

Authenticate to this Robot with the username/password at the given service.

Raises
authenticate_with_token(token, timeout=None)[source]

Authenticate to this Robot with the token at the given service.

Raises
authenticate_from_cache(username, timeout=None)[source]

Authenticate to this Robot with a cached token at the given service.

Raises
authenticate_from_payload_credentials(guid, secret, payload_registration_client=None, timeout=None)[source]

Authenticate to this Robot with the guid/secret of the hosting payload.

This call is used to authenticate to a robot using payload credentials. If a payload is not yet authorized, it will block until the payload is authorized by an operator in the robot web page.

Raises
update_user_token(user_token, username=None)[source]

Update this Robot with a user token.

Raises

token_cache.WriteFailedError – Error saving to the cache.

get_cached_usernames()[source]

Return an ordered list of usernames queryable from the cache.

get_id(id_service_name='robot-id')[source]

Get all the information that identifies the robot.

list_services(directory_service_name='directory', directory_service_authority='api.spot.robot')[source]

Get all the available services on the robot.

sync_with_directory(directory_service_name='directory', directory_service_authority='api.spot.robot')[source]

Update local state with all available services on the robot.

Returns

Mapping of service name to service type

Return type

Dict[string, string]

register_payload_and_authenticate(payload, secret, timeout=None)[source]

Register a payload with the robot and request a user_token.

This method will block until the payload is authorized by an operator in the robot webpage. :raises InvalidPayloadCredentialsError: The guid and/or secret are not valid. :raises InvalidPayloadCredentialsError: The payload was rejected on the robot web page. :raises token_cache.WriteFailedError: Authentication succeeded, but failed to update the local token_cache. :raises RpcError: There was a problem communicating with the robot.

start_time_sync(time_sync_interval_sec=None)[source]

Start time sync thread if needed.

Parameters

val (float) – The interval (in seconds) that the time-sync estimate should be updated.

stop_time_sync()[source]

Stop the time sync thread if needed.

property time_sync

Accessor for the time-sync thread. Creates and starts thread if not already started.

operator_comment(comment, timestamp_secs=None, timeout=None)[source]

Send an operator comment to the robot for the robot’s log files.

Parameters
  • comment (string) – Operator comment text to be added to the log.

  • timestamp_secs (float) – Comment time in seconds since the unix epoch (client clock). If set, this is converted to robot time when sent to the robot. If None and time sync is available, the current time is converted to robot time and sent as the comment timestamp. If None and time sync is unavailable, the logged timestamp will be the time the robot receives this message.

  • timeout (float) – Number of seconds to wait for RPC response.

Raises
  • NotEstablishedError – timestamp_secs given, but time-sync has not been achieved.

  • RpcError – A problem occurred sending the comment to the robot.

power_on(timeout_sec=20, update_frequency=1.0, timeout=None)[source]

Power on robot. This function blocks until robot powers on.

Parameters
  • timeout_sec (float) – Max time this function will block for.

  • update_frequency (float) – Frequency at which power status is checked.

  • timeout – Number of seconds to wait for RPC response.

Raises
  • PowerResponseError – Problem with the power on sequence.

  • RpcError – Problem communicating with the robot.

  • power_client.CommandTimedOutError – The robot did not power on within timeout_sec

power_off(cut_immediately=False, timeout_sec=20, update_frequency=1.0, timeout=None)[source]

Power off robot. This function blocks until robot powers off. By default, this will attempt to put the robot in a safe state before cutting power.

Parameters
  • cut_immediately (bool) – True to cut power to the robot immediately. False to issue a safe power off command to the robot.

  • timeout_sec (float) – Max time this function will block for.

  • update_frequency (float) – Frequency at which power status is checked.

  • timeout – Number of seconds to wait for RPC response.

Raises
  • RpcError – Problem communicating with the robot.

  • power_client.CommandTimedOutError – The robot did not power off within timeout_sec

  • PowerResponseError – If cut_immediately, raised on problems with the power on sequence.

  • RobotCommandResponseError – If not cut_immediately, raised on problems with the safe power off.

is_powered_on(timeout=None)[source]

Check the power state of the robot.

Parameters

timeout – Number of seconds to wait for RPC response.

Returns

Returns True if robot is powered on, False otherwise.

Return type

bool

Raises

RpcError – A problem occurred trying to communicate with the robot.

get_frame_tree_snapshot(timeout=None)[source]

Get the current frame tree snapshot from the robot state client.

Parameters

timeout – Number of seconds to wait for RPC response.

Returns

An instance of the bosdyn.api.FrameTreeSnapshot that contains data from the latest robot state.

Raises

RpcError – A problem occurred sending the comment to the robot.