viam.components.base.client

Module Contents

Classes

BaseClient

gRPC client for the Base component.

class viam.components.base.client.BaseClient(name: str, channel: grpclib.client.Channel)[source]

Bases: viam.components.base.Base, viam.resource.rpc_client_base.ReconfigurableResourceRPCClientBase

gRPC client for the Base component.

async move_straight(distance: int, velocity: float, *, extra: Optional[Dict[str, Any]] = None, timeout: Optional[float] = None)[source]

Move the base in a straight line the given distance, expressed in millimeters, at the given velocity, expressed in millimeters per second. When distance or velocity is 0, the base will stop. This method blocks until completed or cancelled.

Parameters:
  • distance (int) – The distance (in millimeters) to move. Negative implies backwards.

  • velocity (float) – The velocity (in millimeters per second) to move. Negative implies backwards.

async spin(angle: float, velocity: float, *, extra: Optional[Dict[str, Any]] = None, timeout: Optional[float] = None)[source]

Spin the base in place angle degrees, at the given angular velocity, expressed in degrees per second. When velocity is 0, the base will stop. This method blocks until completed or cancelled.

Parameters:
  • angle (float) – The angle (in degrees) to spin.

  • velocity (float) – The angular velocity (in degrees per second) to spin. Given a positive angle and a positive velocity, the base will turn to the left.

async set_power(linear: viam.components.base.Vector3, angular: viam.components.base.Vector3, *, extra: Optional[Dict[str, Any]] = None, timeout: Optional[float] = None)[source]

Set the linear and angular velocity of the Base When linear is 0, the the base will spin. When angular is 0, the the base will move in a straight line. When both linear and angular are 0, the base will stop. When linear and angular are both nonzero, the base will move in an arc, with a tighter radius if angular power is greater than linear power.

Parameters:
  • linear (Vector3) – The linear component. Only the Y component is used for wheeled base. Positive implies forwards.

  • angular (Vector3) – The angular component. Only the Z component is used for wheeled base. Positive turns left; negative turns right.

async set_velocity(linear: viam.components.base.Vector3, angular: viam.components.base.Vector3, *, extra: Optional[Dict[str, Any]] = None, timeout: Optional[float] = None)[source]

Set the linear and angular velocities of the base.

Parameters:
  • linear (Vector3) – Velocity in mm/sec

  • angular (Vector3) – Velocity in deg/sec

async stop(*, extra: Optional[Dict[str, Any]] = None, timeout: Optional[float] = None)[source]

Stop the base.

async is_moving(*, timeout: Optional[float] = None) bool[source]

Get if the base is currently moving.

Returns:

Whether the base is moving.

Return type:

bool

async get_properties(*, extra: Optional[Dict[str, Any]] = None, timeout: Optional[float] = None, **kwargs) viam.components.base.Base.Properties[source]

Get the base width and turning radius

Returns:

The properties of the base

Return type:

Properties

async do_command(command: Mapping[str, viam.utils.ValueTypes], *, timeout: Optional[float] = None) Mapping[str, viam.utils.ValueTypes][source]

Send/Receive arbitrary commands to the Resource

Parameters:

command (Mapping[str, ValueTypes]) – The command to execute

Raises:

NotImplementedError – Raised if the Resource does not support arbitrary commands

Returns:

Result of the executed command

Return type:

Mapping[str, ValueTypes]

async get_geometries(*, extra: Optional[Dict[str, Any]] = None, timeout: Optional[float] = None) List[viam.proto.common.Geometry][source]

Get all geometries associated with the Component, in their current configuration, in the frame of the Component.

Returns:

The geometries associated with the Component.

Return type:

List[Geometry]

classmethod from_robot(robot: viam.robot.client.RobotClient, name: str) typing_extensions.Self

Get the component named name from the provided robot.

Parameters:
  • robot (RobotClient) – The robot

  • name (str) – The name of the component

Returns:

The component, 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 the Operation 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:

viam.operations.Operation

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.