Base Remote Control Service
The base remote control service implements an input controller as a remote control for a base.
This uses the input
API to make it easy to add remote drive controls for your rover or other mobile robot with a controller like a gamepad.
Add the base remote control service after configuring your machine with a base and input controller to control the linear and angular velocity of the base with the controller’s button or joystick controls.
Control mode is determined by the configuration attribute "control_mode"
, for which there are five options:
"arrowControl"
: Arrow buttons control speed and angle"triggerSpeedControl"
: Trigger button controls speed and joystick controls angle"buttonControl"
: Four buttons (usually X, Y, A, B) control speed and angle"joystickControl"
: One joystick controls speed and angle"droneControl"
: Two joysticks control speed and angle
You can monitor the input from these controls in the CONTROL tab of the Viam app.
Used with
* Required for use
Configuration
You must configure a base with a movement sensor as part of your machine to be able to use a base remote control service.
First, make sure your base is physically assembled and powered on. Then, configure the service:
Navigate to the CONFIGURE tab of your machine’s page in the Viam app.
Click the + icon next to your machine part in the left-hand menu and select Service.
Select the base remote control
type.
Enter a name or use the suggested name for your service and click Create.
In your base remote control service’s configuration panel, copy and paste the following JSON object into the attributes field:
{
"base": "<your-base-name>",
"input_controller": "<your-controller-name>"
}
Edit the attributes as applicable to your machine, according to the table below.
For example:
{
"name": "<your-base-remote-control-service>",
"type": "base_remote_control",
"attributes": {
"base": "<your-base-name>",
"input_controller": "<your-controller-name>"
}
}
{
"name": "my-base-remote-control-service",
"type": "base_remote_control",
"attributes": {
"base": "my-base",
"input_controller": "my-input-controller",
"control_mode": "arrowControl"
}
}
Edit and fill in the attributes as applicable. The following attributes are available for base remote control services:
Name | Type | Required? | Description |
---|---|---|---|
base | string | Required | The name of the base you have configured for the base you are operating with this service. |
input_controller | string | Required | The name of the input controller you have configured for the base you are operating with this service. |
control_mode | string | Optional | The mode of remote control you want to use. Options:
Default: "arrowControl" |
max_angular_degs_per_sec | float | Optional | The max angular velocity for the base in degrees per second. |
max_linear_mm_per_sec | float | Optional | The max linear velocity for the base in meters per second. |
API
The base remote control service supports the following methods:
Method Name | Description |
---|---|
ControllerInputs | Get a list of inputs from the controller that are being monitored for that control mode. |
Reconfigure | Reconfigure this resource. |
DoCommand | Execute model-specific commands that are not otherwise defined by the service API. |
Close | Close out of all remote control related systems. |
Tip
The following code examples assume that you have a machine configured with a base named "my_base"
, input controller named "my_controller"
, and base remote control service named "my_base_rc_service"
.
Make sure to add the required code to connect to your machine and import any required packages at the top of your code file.
Go to your machine’s CONNECT tab on the Viam app and select the Code sample page for sample code to connect to your machine.
ControllerInputs
Get a list of inputs from the controller that are being monitored for that control mode.
Parameters:
- None.
Returns:
- ([]input.Control): A list of inputs from the controller that are being monitored for that control mode.
Example:
// Get the list of inputs from the controller that are being monitored for that control mode.
inputs := baseRCService.ControllerInputs()
For more information, see the Go SDK Docs.
Reconfigure
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:
- (error): An error, if one occurred.
For more information, see the Go SDK Docs.
DoCommand
Execute model-specific commands that are not otherwise defined by the service API.
For built-in service models, any model-specific commands available are covered with each model’s documentation.
If you are implementing your own base remote control service and add features that have no built-in API method, you can access them with DoCommand
.
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:
- (map[string]interface{}): The command response.
- (error): An error, if one occurred.
Example:
myBaseRemoteControlSvc, err := baseremotecontrol.FromRobot(machine, "my_base_remote_control_svc")
command := map[string]interface{}{"cmd": "test", "data1": 500}
result, err := myBaseRemoteControlSvc.DoCommand(context.Background(), command)
For more information, see the Go SDK Docs.
Close
Close out of all remote control related systems.
Parameters:
ctx
(Context): A Context carries a deadline, a cancellation signal, and other values across API boundaries.
Returns:
- (error): An error, if one occurred.
Example:
baseRCService, err := baseremotecontrol.FromRobot(machine, "my_baseRCService_svc")
err := baseRCService.Close(context.Background())
For more information, see the Go SDK Docs.
Have questions, or want to meet other people working on robots? Join our Community Discord.
If you notice any issues with the documentation, feel free to file an issue or edit this file.
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!