Drive a Rover (like SCUTTLE) Using a Gamepad with a Dongle

This tutorial teaches you how to add a Bluetooth dongle gamepad controller to your wheeled robot. By the end of this tutorial, you’ll be able to drive your rover around like an RC car.

Requirements

You will need the following hardware to complete this tutorial:

Set up the hardware

Plug the gamepad Bluetooth dongle into a USB port on the rover’s board. Turn on power to the rover.

Add the controller to the rover’s config

Go to your rover’s Config tab on the Viam app.

Configure a gamepad:

  • Click Create component.
  • Select input_controller for the component Type.
  • Select gamepad for the Model.
  • Enter my-gamepad as the component Name.
  • Click Create.

Blank configuration JSON

If instead of using the config builder, you prefer to write raw JSON, switch to Raw JSON mode on the Config tab. Inside the components array of your config, add the following configuration for your gamepad:

{
  "name": "my-gamepad",
  "model": "gamepad",
  "type": "input_controller",
  "namespace": "rdk",
  "attributes": {},
  "depends_on": []
}

The controller config adds the gamepad controller to your robot. However, it is not functional yet. To make it functional, you need to add the base remote control service.

Add the base remote control service

Services are software packages that provide robots with higher level functionality. To link the controller’s input to the base functionality, you need to configure the base remote control service:

  • Go to the Services subtab of your robot’s Config tab.
  • In the Create service panel, click the Type dropdown and select Base Remote Control.
  • Enter gamepad_service for the Service name.
  • Click Create service.

Copy and paste the following into the empty Attributes field, replacing <your-base-name> with your base’s name.

{
  "base": "<your-base-name>",
  "input_controller": "my-gamepad"
}

Service configuration

If instead of using the config builder, you prefer to write raw JSON, switch to Raw JSON mode on the Config tab. Add the following configuration for your base remote control service, replacing <your-base-name> with your base’s name:

  "services": [
    {
      "name": "gamepad_service",
      "type": "base_remote_control",
      "attributes": {
        "input_controller": "my-gamepad",
        "base": "<your-base-name>"
      }
    }
  ]

If you already have a "services" array with other services configured, add just the contents of the square brackets above to that array, rather than creating two different "services" arrays.

Click Save config, then go to the Control tab.

You should see the panel for the gamepad and its connection indicator:

Gamepad input UI showing a “connected” indicator and a list of inputs from all the buttons, for example X=0.0, RY=0.0 and East=0.

Try moving the left joystick or pressing the D-pad to move the rover using the gamepad.

The ESM-9101 controller has different modes that allow you to use either the joystick or the D-pad. If you are in the mode that allows you to use the joystick (#7), it will change the X and Y values on the Control tab gamepad panel:

"X
0.0000
Y
0.0000"

If you are in the mode that allows you to use the D-pad (#8), it will change the Hat0X and Hat0Y values:

"Hat0X
0.0000
Hat0Y
0.0000"

Testing these attributes tells you which mode you are in.

EasySMX ESM-9101 wireless controller information

Here is a diagram of the gamepad.

gamepad diagramgamepad legend

To change the movement/direction control on the gamepad between the D-pad and the joystick, press and hold the Home button (#11) until it displays the lighted segment combination for the gamepad configuration you need. Each red color arrangement allows you to control the gamepad in the Viam app:

LED 1 and 3: Use the D-Pad
Led 1 and 3 are lit
LED 3 and 4: Use the D-Pad
Led 3 and 4 are lit
LED 1 and 2: Use the D-Pad
Led 1 and 4 are lit
LED 1 and 4: Use the Joystick
Led 1 and 4 are lit


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.