viam.components.base

Submodules

Package Contents

Classes

Base

Base represents a physical base of a robot.

Vector3

Abstract base class for protocol messages.

class viam.components.base.Base(name: str)[source]

Base represents a physical base of a robot.

This acts as an abstract base class for any drivers representing specific base implementations. This cannot be used on its own. If the __init__() function is overridden, it must call the super().__init__() function.

SUBTYPE :Final
abstract async move_straight(distance: int, velocity: float, *, extra: Optional[Dict[str, Any]] = None, timeout: Optional[float] = None, **kwargs)[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.

abstract async spin(angle: float, velocity: float, *, extra: Optional[Dict[str, Any]] = None, timeout: Optional[float] = None, **kwargs)[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. Negative implies backwards.

  • velocity (float) – The angular velocity (in degrees per second). to spin. Negative implies backwards.

abstract async set_power(linear: viam.proto.common.Vector3, angular: viam.proto.common.Vector3, *, extra: Optional[Dict[str, Any]] = None, timeout: Optional[float] = None, **kwargs)[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. Negative implies backwards.

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

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

Set the linear and angular velocities of the base.

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

  • angular (Vector3) – Velocity in deg/sec

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

Stop the base.

abstract async is_moving() bool[source]

Get if the base is currently moving.

Returns

Whether the base is moving.

Return type

bool

class viam.components.base.Vector3(*, x: float = ..., y: float = ..., z: float = ...)

Abstract base class for protocol messages.

Protocol message classes are almost always generated by the protocol compiler. These generated types subclass Message and implement the methods shown below.

x :float
y :float
z :float