# Base remote control service

## Used with

\
Base*  
\
Input controller*  
\
Movement sensor

* Required for use

**Input controller is required hardware + related Viam component**

The base remote control service implements an [input controller](https://docs.viam.com/reference/components/input-controller/) as a remote control for a [base](https://docs.viam.com/reference/components/base/). This uses the [`input` API](https://docs.viam.com/reference/apis/components/input-controller/) 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:

1. `"arrowControl"`: Arrow buttons control speed and angle
2. `"triggerSpeedControl"`: Trigger button controls speed and joystick controls angle
3. `"buttonControl"`: Four buttons (usually X, Y, A, B) control speed and angle
4. `"joystickControl"`: One joystick controls speed and angle
5. `"droneControl"`: Two joysticks control speed and angle

You can monitor the input from these controls in the **CONTROL** tab.

## Configuration

You must configure a [base](https://docs.viam.com/reference/components/base/) with a [movement sensor](https://docs.viam.com/reference/components/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:

- [Builder](https://docs.viam.com/reference/services/base-rc/#tabset-referenceservicesbase-rc-1-0)
- [JSON Template](https://docs.viam.com/reference/services/base-rc/#tabset-referenceservicesbase-rc-1-1)
- [JSON Example](https://docs.viam.com/reference/services/base-rc/#tabset-referenceservicesbase-rc-1-2)

Navigate to the **CONFIGURE** tab of your machine’s page. Click the **+** icon next to your machine part in the left-hand menu and select **Blocks**. Select the `base remote control` type. Enter a name or use the suggested name for your service and click **Add to machine**.

In your base remote control service’s configuration panel, copy and paste the following JSON object into the attributes field:

```json

```

Edit the attributes as applicable to your machine, according to the table below.

For example:

```json

```

```json

```

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](https://docs.viam.com/reference/components/base/) you have configured for the base you are operating with this service. |
| `input_controller` | string | **Required** | The `name` of the [input controller](https://docs.viam.com/reference/components/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.<br>Options:<br>- `"arrowControl"`<br>- `"triggerSpeedControl"`<br>- `"buttonControl"`<br>- `"joystickControl"`<br>- `"droneControl"`<br>Default: `"arrowControl"` |
| `max_angular_degs_per_sec` | float | Optional | The max angular velocity for the [base](https://docs.viam.com/reference/components/base/) in degrees per second. |
| `max_linear_mm_per_sec` | float | Optional | The max linear velocity for the [base](https://docs.viam.com/reference/components/base/) in meters per second. |

## API

The base remote control service supports the following methods:

| Method Name | Description |
| --- | --- |
| [`ControllerInputs`](https://docs.viam.com/reference/apis/services/base-rc/#controllerinputs) | Get a list of inputs from the controller that are being monitored for that control mode. |
| [`Reconfigure`](https://docs.viam.com/reference/apis/services/base-rc/#reconfigure) | Reconfigure this resource. |
| [`DoCommand`](https://docs.viam.com/reference/apis/services/base-rc/#docommand) | Execute model-specific commands that are not otherwise defined by the service API. |
| [`GetResourceName`](https://docs.viam.com/reference/apis/services/base-rc/#getresourcename) | Get the `ResourceName` for this instance of the generic service with the given name. |
| [`Close`](https://docs.viam.com/reference/apis/services/base-rc/#close) | Close out of all remote control related systems. |

#### Tip

The following code examples assume that you have a machine configured with a [base](https://docs.viam.com/reference/components/base/) named `"my_base"`, [input controller](https://docs.viam.com/reference/components/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 and select **API keys** to get your credentials, then use the code sample to connect to your machine.

### ControllerInputs

Get a list of inputs from the controller that are being monitored for that control mode.

- [Go](https://docs.viam.com/reference/services/base-rc/#tabset-referenceservicesbase-rc-2-0)

**Parameters:**
- None.

**Returns:**
- [([]input.Control)](https://pkg.go.dev/go.viam.com/rdk/components/input#Control): A list of inputs from the controller that are being monitored for that control mode.

**Example:**

```go

```

For more information, see the [Go SDK Docs](https://pkg.go.dev/go.viam.com/rdk/services/baseremotecontrol#Service).

### Reconfigure

Reconfigure this resource. Reconfigure must reconfigure the resource atomically and in place.

- [Go](https://docs.viam.com/reference/services/base-rc/#tabset-referenceservicesbase-rc-3-0)

**Parameters:**
- `ctx` [(Context)](https://pkg.go.dev/context#Context): A Context carries a deadline, a cancellation signal, and other values across API boundaries.
- `deps` [(Dependencies)](https://pkg.go.dev/go.viam.com/rdk/resource#Dependencies): The resource dependencies.
- `conf` [(Config)](https://pkg.go.dev/go.viam.com/rdk/resource#Config): The resource configuration.

**Returns:**
- [(error)](https://pkg.go.dev/builtin#error): An error, if one occurred.

For more information, see the [Go SDK Docs](https://pkg.go.dev/go.viam.com/rdk/resource#Resource).

### DoCommand

Execute model-specific commands that are not otherwise defined by the service API. Most models do not implement `DoCommand`. Any available model-specific commands should be covered in the model’s documentation. If you are implementing your own base remote control service and want to add features that have no corresponding built-in API method, you can implement them with [`DoCommand`](https://docs.viam.com/reference/sdks/docommand/).

- [Go](https://docs.viam.com/reference/services/base-rc/#tabset-referenceservicesbase-rc-4-0)

**Parameters:**
- `ctx` [(Context)](https://pkg.go.dev/context#Context): A Context carries a deadline, a cancellation signal, and other values across API boundaries.
- `cmd` [(map[string]interface{})](https://go.dev/blog/maps): The command to execute.

**Returns:**
- [(map[string]interface{})](https://pkg.go.dev/builtin#string): The command response.
- [(error)](https://pkg.go.dev/builtin#error): An error, if one occurred.

**Example:**

```go

```

For more information, see the [Go SDK Docs](https://pkg.go.dev/go.viam.com/rdk/resource#Resource).

### GetResourceName

Get the `ResourceName` for this instance of the generic service with the given name.

- [Go](https://docs.viam.com/reference/services/base-rc/#tabset-referenceservicesbase-rc-5-0)

**Parameters:**
- None.

**Returns:**
- [(Name)](https://pkg.go.dev/go.viam.com/rdk@v0.89.0/resource#Name)

**Example:**

```go

```

For more information, see the [Go SDK Docs](https://pkg.go.dev/go.viam.com/rdk/resource#Resource).

### Close

Close out of all remote control related systems.

- [Go](https://docs.viam.com/reference/services/base-rc/#tabset-referenceservicesbase-rc-6-0)

**Parameters:**
- `ctx` [(Context)](https://pkg.go.dev/context#Context): A Context carries a deadline, a cancellation signal, and other values across API boundaries.

**Returns:**
- [(error)](https://pkg.go.dev/builtin#error): An error, if one occurred.

**Example:**

```go

```

For more information, see the [Go SDK Docs](https://pkg.go.dev/go.viam.com/rdk/resource#Resource).
