Previous
Arm
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 with the given name. | |
Close | Safely shut down the resource and prevent further use. |
To get started using Viam’s SDKs to connect to and control your base and the rest of your machine, go to your machine’s page on the Viam app, Navigate to the CONNECT tab’s Code sample page, select your preferred programming language, and copy the sample code.
To show your machine’s API key in the sample code, toggle Include API key.
We strongly recommend that you add your API key and machine address as an environment variable. Anyone with these secrets can access your machine, and the computer running your machine.
When executed, this sample code creates a connection to your machine as a client.
The following examples assume you have a wheeled base called "my_base"
configured as a component of your machine.
If your base has a different name, change the name
in the code.
Import the base package for the SDK you are using:
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:
Example:
For more information, see the Python SDK Docs.
Parameters:
ctx
(Context): A Context carries a deadline, a cancellation signal, and other values across API boundaries.distanceMm
(int): The distance to move the base in millimeters. Positive implies forwards. Negative implies backwards.mmPerSec
(float64): The velocity at which to move the base in millimeters per second. Positive implies forwards. Negative implies backwards.extra
(map[string]interface{}): Extra options to pass to the underlying RPC call.Returns:
Example:
For more information, see the Go SDK Docs.
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:
Example:
For more information, see the Python SDK Docs.
Parameters:
ctx
(Context): A Context carries a deadline, a cancellation signal, and other values across API boundaries.angleDeg
(float64): The angle to spin in degrees. Positive implies turning to the left.degsPerSec
(float64): The angular velocity at which to spin in degrees per second. Given a positive angle and a positive velocity, the base turns to the left (for built-in base models).extra
(map[string]interface{}): Extra options to pass to the underlying RPC call.Returns:
Example:
For more information, see the Go SDK Docs.
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].
Supported by viam-micro-server
.
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:
Example:
For more information, see the Python SDK Docs.
Parameters:
ctx
(Context): A Context carries a deadline, a cancellation signal, and other values across API boundaries.linear
(r3.Vector): The percentage of max power of the base’s linear propulsion. In the range of -1.0 to 1.0, with 1.0 meaning 100% power. Viam’s coordinate system considers +Y to be the forward axis (+/- X right/left, +/- Z up/down), so use the Y component of this vector to move forward and backward when controlling a wheeled base. Positive “Y” values imply moving forwards. Negative “Y” values imply moving backwards.angular
(r3.Vector): The percentage of max power of the base’s angular propulsion. In the range of -1.0 to 1.0, with 1.0 meaning 100% power. Use the Z component of this vector to spin left or right when controlling a wheeled base. Positive “Z” values imply spinning to the left (for built-in base models).extra
(map[string]interface{}): Extra options to pass to the underlying RPC call.Returns:
Example:
For more information, see the Go SDK Docs.
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:
Example:
For more information, see the Python SDK Docs.
Parameters:
ctx
(Context): A Context carries a deadline, a cancellation signal, and other values across API boundaries.linear
(r3.Vector): The linear velocity in millimeters per second. Only the Y component of the vector is used for a wheeled base.angular
(r3.Vector): The angular velocity in degrees per second. Only the Z component of the vector is used for a wheeled base.extra
(map[string]interface{}): Extra options to pass to the underlying RPC call.Returns:
Example:
For more information, see the Go SDK Docs.
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:
Example:
For more information, see the Python SDK Docs.
Parameters:
ctx
(Context): A Context carries a deadline, a cancellation signal, and other values across API boundaries.extra
(map[string]interface{}): Extra options to pass to the underlying RPC call.Returns:
WidthMeters
, TurningRadiusMeters
, and WheelCircumferenceMeters
representing the width, turning radius, and wheel circumference of the physical base in meters (m).Example:
For more information, see the Go SDK Docs.
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:
Example:
For more information, see the Python SDK Docs.
Parameters:
ctx
(Context): A Context carries a deadline, a cancellation signal, and other values across API boundaries.Returns:
Example:
For more information, see the Go SDK Docs.
Stop the base from moving immediately.
Supported by viam-micro-server
.
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:
Example:
For more information, see the Python SDK Docs.
Parameters:
ctx
(Context): A Context carries a deadline, a cancellation signal, and other values across API boundaries.extra
(map[string]interface{}): Extra options to pass to the underlying RPC call.Returns:
Example:
For more information, see the Go SDK Docs.
Get all the geometries associated with the base in its current configuration, in the frame of the base. The motion and navigation services use the relative position of inherent geometries to configured geometries representing obstacles for collision detection and obstacle avoidance while motion planning.
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:
Example:
For more information, see the Python SDK Docs.
Parameters:
ctx
(Context): A Context carries a deadline, a cancellation signal, and other values across API boundaries.extra
(map[string]interface{}): Extra options to pass to the underlying RPC call.Returns:
Example:
For more information, see the Go SDK Docs.
Reconfigure this resource. Reconfigure must reconfigure the resource atomically and in place.
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:
For more information, see the Go SDK Docs.
Execute model-specific commands that are not otherwise defined by the component API.
For built-in models, model-specific commands are covered with each model’s documentation.
If you are implementing your own base and add features that have no built-in API method, you can access them with DoCommand
.
Supported by viam-micro-server
.
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:
Raises:
Example:
For more information, see the Python SDK Docs.
Parameters:
ctx
(Context): A Context carries a deadline, a cancellation signal, and other values across API boundaries.cmd
(map[string]interface{}): The command to execute.Returns:
Example:
For more information, see the Go SDK Docs.
Get the ResourceName
for this base with the given name.
Parameters:
name
(str) (required): The name of the Resource.Returns:
Example:
For more information, see the Python SDK Docs.
Safely shut down the resource and prevent further use.
Parameters:
ctx
(Context): A Context carries a deadline, a cancellation signal, and other values across API boundaries.Returns:
Example:
For more information, see the Go SDK Docs.
Was this page helpful?
Glad to hear it! If you have any other feedback please let us know:
We're sorry about that. To help us improve, please tell us what we can do better:
Thank you!