Sdk

Sdk is a repository for settings typically common to a single developer and/or robot fleet.

exception bosdyn.client.sdk.SdkError[source]

Bases: bosdyn.client.exceptions.Error

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

exception bosdyn.client.sdk.UnsetAppTokenError[source]

Bases: bosdyn.client.sdk.SdkError

Path to app token not set.

exception bosdyn.client.sdk.UnableToLoadAppTokenError[source]

Bases: bosdyn.client.sdk.SdkError

Cannot load the provided app token path.

bosdyn.client.sdk.generate_client_name(prefix='')[source]

Returns a descriptive client name for API clients with an optional prefix.

bosdyn.client.sdk.create_standard_sdk(client_name_prefix, service_clients=None, cert_resource_glob=None)[source]

Return an Sdk with the most common configuration.

Parameters
  • client_name_prefix – prefix to pass to generate_client_name()

  • service_clients – List of service client classes to register in addition to the defaults.

  • cert_resource_glob – Glob expression matching robot certificate(s). Default None to use distributed certificate.

Raises

IOError – Robot cert could not be loaded.

class bosdyn.client.sdk.Sdk(name=None)[source]

Bases: object

Repository for settings typically common to a single developer and/or robot fleet. See also Robot for robot-specific settings.

Parameters

name – Name to identify the client when communicating with the robot.

create_robot(address, name=None)[source]

Get a Robot initialized with this Sdk, creating it if it does not yet exist.

Parameters
  • address – Network-resolvable address of the robot, e.g. ‘192.168.80.3’

  • name – A unique identifier for the robot, e.g. ‘My First Robot’. Default None to use the address as the name.

Returns

A Robot initialized with the current Sdk settings.

register_service_client(creation_func, service_type=None, service_name=None)[source]

Tell the Sdk how to create a specific type of service client.

Parameters
  • creation_func – Callable that returns a client. Typically just the class.

  • service_type – Type of the service. If None (default), will try to get the name from creation_func.

  • service_name – Name of the service. If None (default), will try to get the name from creation_func.

load_robot_cert(resource_path_glob=None)[source]

Load the SSL certificate for the robot.

Parameters

resource_path_glob – Optional path to certificate resource(s). If None, will load the certificate in the ‘resources’ package. Otherwise, should be a glob expression to match certificates. Defaults to None.

Raises

IOError – Robot cert could not be loaded.

load_app_token(resource_path)[source]

Load an app token from a file, and set it on the SDK.

Parameters

resource_path – Path to app token file on file system.

Raises
bosdyn.client.sdk.decode_token(token)[source]

Decodes a JWT token without verification.

Parameters

token – A string representing a token.

Returns

Dictionary containing information about the token. Empty dictionary if failed to load token.

Raises

UnableToLoadAppTokenError – If the token cannot be read.

bosdyn.client.sdk.log_token_time_remaining(token)[source]

Log the time remaining until app token expires.

Parameters

token – A jwt token

Raises

UnableToLoadAppTokenError – If the token expiration information cannot be retrieved.