Base API | Component APIs
Base API
The base API allows you to give commands to your base components for moving all configured components attached to a platform as a whole without needing to send commands to individual components.
The base component supports the following methods:
| Method Name | Description | viam-micro-server Support |
|---|---|---|
MoveStraight |
Move the base in a straight line across the given distance (mm) at the given velocity (mm/sec). | |
Spin |
Turn the base in place, rotating it to the given angle (degrees) at the given angular velocity (degrees/sec). | |
SetPower |
Set the linear and angular power of the base, represented as a percentage of max power for each direction in the range of [-1.0 to 1.0]. | |
SetVelocity |
Set the linear velocity (mm/sec) and angular velocity (degrees/sec) of the base. | |
GetProperties |
Get the width and turning radius of the model of base in meters. | |
IsMoving |
Returns whether the base is actively moving (or attempting to move) under its own power. | |
Stop |
Stop the base from moving immediately. | |
GetGeometries |
Get all the geometries associated with the base in its current configuration, in the frame of the base. | |
Reconfigure |
Reconfigure this resource. | |
DoCommand |
Execute model-specific commands that are not otherwise defined by the component API. | |
GetResourceName |
Get the ResourceName for this base. |
|
Close |
Safely shut down the resource and prevent further use. |
API
MoveStraight
Move the base in a straight line across the given distance (mm) at the given velocity (mm/sec).
Parameters:
distance( int) (required): The distance (in millimeters) to move. Negative implies backwards.velocity( float) (required): The velocity (in millimeters per second) to move. Negative implies backwards.extra(Mapping[ str, Any]) (optional): Extra options to pass to the underlying RPC call.timeout( float) (optional): An option to set how long to wait (in seconds) before calling a time-out and closing the underlying RPC call.
Returns:
- None.
Spin
Turn the base in place, rotating it to the given angle (degrees) at the given angular velocity (degrees/sec).
Parameters:
angle( float) (required): The angle (in degrees) to spin.velocity( float) (required): The angular velocity (in degrees per second) to spin. Given a positive angle and a positive velocity, the base will turn to the left.extra(Mapping[ str, Any]) (optional): Extra options to pass to the underlying RPC call.timeout( float) (optional): An option to set how long to wait (in seconds) before calling a time-out and closing the underlying RPC call.
Returns:
- None.
SetPower
Set the linear and angular power of the base, represented as a percentage of max power for each direction in the range of [-1.0 to 1.0].
Parameters:
linear( viam.components.base.Vector3) (required): The linear component. Only the Y component is used for wheeled base. Positive implies forwards.angular( viam.components.base.Vector3) (required): The angular component. Only the Z component is used for wheeled base. Positive turns left; negative turns right.extra(Mapping[ str, Any]) (optional): Extra options to pass to the underlying RPC call.timeout( float) (optional): An option to set how long to wait (in seconds) before calling a time-out and closing the underlying RPC call.
Returns:
- None.
SetVelocity
Set the linear velocity (mm/sec) and angular velocity (degrees/sec) of the base.
Parameters:
linear( viam.components.base.Vector3) (required): Velocity in mm/sec.angular( viam.components.base.Vector3) (required): Velocity in deg/sec.extra(Mapping[ str, Any]) (optional): Extra options to pass to the underlying RPC call.timeout( float) (optional): An option to set how long to wait (in seconds) before calling a time-out and closing the underlying RPC call.
Returns:
- None.
GetProperties
Get the width and turning radius of the model of base in meters.
Parameters:
extra(Mapping[ str, Any]) (optional): Extra options to pass to the underlying RPC call.timeout( float) (optional): An option to set how long to wait (in seconds) before calling a time-out and closing the underlying RPC call.
Returns:
- ( viam.components.base.Base.Properties): : The properties of the base.
IsMoving
Returns whether the base is actively moving (or attempting to move) under its own power.
Parameters:
timeout( float) (optional): An option to set how long to wait (in seconds) before calling a time-out and closing the underlying RPC call.
Returns:
- ( bool): : Whether the base is moving.
Stop
Stop the base from moving immediately.
Parameters:
Returns:
- None.
GetGeometries
Get all the geometries associated with the base in its current configuration, in the frame of the base.
Parameters:
Returns:
- ( List[viam.proto.common.Geometry]): : The geometries associated with the Component.
Reconfigure
Reconfigure this resource.
Parameters:
ctx(Context): A Context carries a deadline, a cancellation signal, and other values across API boundaries.deps(Dependencies): The resource dependencies.conf(Config): The resource configuration.
Returns:
- (error): An error, if one occurred.
DoCommand
Execute model-specific commands that are not otherwise defined by the component API.
Parameters:
command(Mapping[ str, ValueTypes]) (required): The command to execute.timeout( float) (optional): An option to set how long to wait (in seconds) before calling a time-out and closing the underlying RPC call.
Returns:
- (Mapping[ str, viam.utils.ValueTypes]): : Result of the executed command.
GetResourceName
Get the ResourceName for this base.
Parameters:
name( str) (required): The name of the Resource.
Returns:
- ( viam.proto.common.ResourceName): : The ResourceName of this Resource.
Close
Safely shut down the resource and prevent further use.
Parameters:
- None.
Returns:
- None.