Sdk

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

exception bosdyn.client.sdk.SdkError[source]

Bases: Error

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

exception bosdyn.client.sdk.UnsetAppTokenError[source]

Bases: SdkError

Path to app token not set.

exception bosdyn.client.sdk.UnableToLoadAppTokenError[source]

Bases: 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.

set_max_message_length(max_message_length)[source]

Updates the send and receive max message length values in all the clients/channels created from this point on.

Parameters

max_message_length (int) – Max message length value to use for sending and receiving messages.

Returns

None.

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.

clear_robots()[source]

Remove all cached Robot instances. Subsequent calls to create_robot() will return newly created Robots. Existing robot instances will continue to work, but their time sync and token refresh threads will be stopped.

static load_app_token(*_)[source]

Do nothing, this method is kept only to maintain backwards compatibility.

Deprecated since version 2.0.1: App tokens are no longer in use. Authorization is now handled via licenses.

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

Decodes a JWT token without verification.

Args:

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.

Deprecated since version 3.0.1: Decoding tokens is no longer supported in the sdk. Use pyjwt directly instead.

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

Log the time remaining until app token expires.

Arguments:

token: A jwt token

Raises:

UnableToLoadAppTokenError: If the token expiration information cannot be retrieved.

Deprecated since version 3.0.1: Decoding tokens is no longer supported in the sdk. Use pyjwt directly instead.