viam.components.base.base
Module Contents
Classes
Base represents a physical base of a robot. |
- class viam.components.base.base.Base(name: str)[source]
Bases:
viam.components.component_base.ComponentBase
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 thesuper().__init__()
function.- class Properties[source]
- width_meters: float
- turning_radius_meters: float
- wheel_circumference_meters: float
- 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 givenvelocity
, expressed in millimeters per second. Whendistance
orvelocity
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 angularvelocity
, expressed in degrees per second. Whenvelocity
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.
- abstract async set_power(linear: viam.components.base.Vector3, angular: viam.components.base.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. Whenangular
is 0, the the base will move in a straight line. When bothlinear
andangular
are 0, the base will stop. Whenlinear
andangular
are both nonzero, the base will move in an arc, with a tighter radius if angular power is greater than linear power.
- abstract async set_velocity(linear: viam.components.base.Vector3, angular: viam.components.base.Vector3, *, extra: Optional[Dict[str, Any]] = None, timeout: Optional[float] = None, **kwargs)[source]
Set the linear and angular velocities of the base.
- 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
- abstract async get_properties(*, timeout: Optional[float] = None, **kwargs) Properties [source]
Get the base width and turning radius
- Returns:
The properties of the base
- Return type:
- 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
- abstract async do_command(command: Mapping[str, ValueTypes], *, timeout: Optional[float] = None, **kwargs) Mapping[str, ValueTypes]
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]
- 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 theOperation
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: