Configure a Rover like Yahboom or SCUTTLE

This tutorial will guide you through configuring a rover.

If you are using a SCUTTLE, a Yahboom rover, or a different rover, this tutorial covers instructions for your rover model.

Requirements

Make sure your rover is assembled before starting this tutorial.

Start configuring your robot

Add a new machine in the Viam app. On the machine’s page, follow the setup instructions to install viam-server on the computer you’re using for your project. Wait until your machine has successfully connected to the Viam app.

Once connected, navigate to the machine’s CONFIGURE tab.

A SCUTTLE robot on a carpeted floor.

The configuration for each rover is different depending on which components your rover is composed of. In the following, you can see two popular examples with components that are present on most rovers:

Configure the board

The first component you will add is the board which represents the Raspberry Pi to which the other components are wired.

Click the + icon next to your machine part in the left-hand menu and select Component. Select the board type, then select the viam:raspberry-pi:rpi model. Enter local as the name and click Create. You can use a different name but will then need to adjust the name in the following steps to the name you choose.

An example board configuration in the app builder UI. The name (local), type (board) and model (pi) are shown. No other attributes are configured.

You don’t need to add any attributes for your board.

Configuring the motors and encoders

Configure the encoders

Configure the left and right encoders as follows:

Start with the right encoder:

Right encoder

Click the + icon next to your machine part in the left-hand menu and select Component. Select the encoder type, then select the AMS-AS5048 model. Enter renc as the name and click Create.

Click the board dropdown list and select the name of your board, local.

In the i2c bus field type 1, and in the i2c address field type 65.

Left encoder

Click the + icon next to your machine part in the left-hand menu and select Component. Select the encoder type, then select the AMS-AS5048 model. Enter lenc as the name for your encoder and click Create.

Click the board dropdown list and select the name of your board, local.

In the i2c bus field type 1, and in the i2c address field type 64.

Add the following JSON objects to the components array:

{
    "name": "lenc",
    "model": "AMS-AS5048",
    "type": "encoder",
    "namespace": "rdk",
    "attributes": {
      "connection_type": "i2c",
      "i2c_attributes": {
        "i2c_bus": "1",
        "i2c_addr": 64
      }
    }
},
{
    "name": "renc",
    "model": "AMS-AS5048",
    "type": "encoder",
    "namespace": "rdk",
    "attributes": {
      "connection_type": "i2c",
      "i2c_attributes": {
        "i2c_bus": "1",
        "i2c_addr": 65
      }
    }
}

Follow the instructions for the model of encoder your rover uses to configure your encoders and configure at least a right and a left encoder.

Configure the motors

Start with the right motor:

Right motor

Click the + icon next to your machine part in the left-hand menu and select Component. Select the motor type, then select the gpio model. Enter right as the name or use the suggested name for your motor and click Create.

Then from the Board dropdown, select local, the Raspberry Pi the motor is wired to.

Select Encoded in the Encoder section and select renc as the encoder and set ticks per rotation to 2.

Next, describe how the motor is wired to the Pi:

  1. Switch the Component Pin Assignment Type to In1/In2.
  2. Set A/In1 to 16.
  3. Set B/In2 to 15.
  4. Leave the pwm (pulse-width modulation) pin blank, because this specific motor driver’s configuration does not require a separate PWM pin.

The motor config panel.

Left motor

Click the + icon next to your machine part in the left-hand menu and select Component. Select the motor type, then select the gpio model. Enter left as the name or use the suggested name for your motor and click Create.

Then select local from the Board dropdown to choose the Raspberry Pi the motor is wired to.

Select Encoded in the Encoder section and select lenc as the encoder and set ticks per rotation to 2.

Next, describe how the motor is wired to the Pi:

  1. Switch the Component Pin Assignment Type to In1/In2.
  2. Set A/In1 to 12.
  3. Set B/In2 to 11.
  4. Leave the pwm (pulse-width modulation) pin blank, because this specific motor driver’s configuration does not require a separate PWM pin.

Add the following JSON objects to the components array:

{
  "name": "right",
  "model": "gpio",
  "type": "motor",
  "namespace": "rdk",
  "attributes": {
    "pins": {
      "a": "16",
      "b": "15",
      "pwm": "",
      "dir": ""
    },
    "board": "local",
    "dir_flip": false,
    "ticks_per_rotation": 2
  },
  "depends_on": [ "local" ]
},
{
  "name": "left",
  "model": "gpio",
  "type": "motor",
  "namespace": "rdk",
  "attributes": {
    "pins": {
      "a": "12",
      "b": "11",
      "pwm": ""
    },
    "board": "local",
    "dir_flip": false,
    "ticks_per_rotation": 2
  },
  "depends_on": [ "local" ]
}

Since both right (and left) side motors of the Yahboom rover are wired together to a single motor driver, you configure the right (and left) side motors as a single motor component.

Start with the right set of wheels.

Right motor

Click the + icon next to your machine part in the left-hand menu and select Component. Select the motor type, then select the gpio model. Enter right as the name or use the suggested name for your motor and click Create.

G P I O motor config in the builder UI with the In1 and In2 pins configured and the PWM pin field left blank.

Click the Board dropdown and select local as the board the motor driver is wired to. Next, configure the Component Pin Assignment section to represent how the motor is wired to the board. In the Component Pin Assignment section of the right motor card, toggle the Type to In1/In2 to use the compatible mode for this motor driver.

If you followed the setup instructions for putting together your Yahboom rover correctly, you can set the pins as follows:

  • a to 35
  • b to 37
  • pwm (pulse-width modulation) to 33.

Leave dir pin blank, because Yahboom’s motor driver uses an a/b/pwm configuration.

Click Show more and set max_rpm to 300. You can ignore the other optional attributes.

Left motor

Click the + icon next to your machine part in the left-hand menu and select Component. Select the motor type, then select the gpio model. Enter left as the name or use the suggested name for your motor and click Create.

Click the Board dropdown and select local as the board the motor driver is wired to. Next, configure the Component Pin Assignment section to represent how the motor is wired to the board. In the Component Pin Assignment section of the right motor card, toggle the Type to In1/In2 to use the compatible mode for this motor driver.

If you followed the setup instructions for putting together your Yahboom rover correctly, you can set the pins as follows:

  • a to 38
  • b to 40
  • pwm (pulse-width modulation) to 36.

Leave dir pin blank, because Yahboom’s motor driver uses an a/b/pwm configuration.

Click Show more and set max_rpm to 300. You can ignore the other optional attributes.

Follow the instructions for the model of motor your rover uses to configure your motors and configure at least a right and a left motor.

Test the motor configuration

Now that you have configured your motors, you can actuate them. Make sure your machine is turned on. Navigate to the Control tab.

You’ll see a panel for each configured component.

Motor panels

Click on the panel for the right motor.

Power level adjustment

Try changing the motor’s power level and click Run.

If your wheel turns in reverse when it should turn forward, add the dir_flip attribute to the motor’s configuration, by clicking Show more and setting the attribute to “true.”

There, you should see a panel for the right motor: you can use this panel to set the motor’s power level.

(Optional) Configure the camera

Optionally, add a camera to your rover.

Click the + icon next to your machine part in the left-hand menu and select Component. Select the camera type, then select the webcam model. Enter a name or use the suggested name for your camera and click Create.

Configuration of a webcam camera in the Viam app config builder.

If you click on the Video Path field while your robot is live, a dropdown autopopulates with identified camera paths.

{
  "name": "Webcam",
  "model": "webcam",
  "type": "camera",
  "namespace": "rdk",
  "attributes": {
    "video_path": "<PATH_TO_YOUR_WEBCAM>"
  }
}

If your rover has its camera mounted on a pair of servos, like the Yahboom rover, you can use these to control the pan and tilt of the camera.

Click the + icon next to your machine part in the left-hand menu and select Component. Select the servo type, then select the viam:raspberry-pi:pi-servo model. Enter pan as the name and click Create.

Set Depends On to local, and pin to the pin the servo is wired to (23 for the Yahboom rover).

Finally, add the tilt servo as well. Click the + icon next to your machine part in the left-hand menu and select Component. Select the servo type, then select the viam:raspberry-pi:pi-servo model. Enter tilt as the name and click Create.

Set Depends On to local, and pin to the pin the servo is wired to (21 for the Yahboom rover).

Test the camera stream

Once your camera is configured and connected, expand the TEST panel on the CONFIGURE or CONTROL tabs. If everything is configured correctly, you will see the live feed from your camera.

Example Camera view inside Viam app

Configure the base

Next, configure the base component, which describes the geometry of your chassis and wheels so that the software can calculate how to steer the rover in a coordinated way. Configuring a base component also provides you with a nice UI for moving the rover around.

Click the + icon next to your machine part in the left-hand menu and select Component. Select the base type, then select the wheeled model. Enter a name or use the suggested name for your base and click Create.

  1. Select the motors attached to the base in the fields as your right and left motors.
  2. Enter 250 for wheel_circumference_mm.
  3. Enter 400 for width_mm (measured between the midpoints of the wheels).
  1. Select the motors attached to the base in the fields as your right and left motors.
  2. Enter 220 for wheel_circumference_mm.
  3. Enter 150 for width_mm (measured between the midpoints of the wheels).
  1. Select the motors attached to the base in the fields as your right and left motors.
  2. Measure the wheel circumference in mm and enter it in the field for wheel_circumference_mm.
  3. Measure the width in mm between the midpoints of the wheels and enter it in the field for width_mm (measured between the midpoints of the wheels).
An example configuration for a wheeled base in the Viam app config builder, with Attributes & Depends On dropdowns and the option to add a frame.
{
  "components": [
    {
      "attributes": {
        "board": "local",
        "pins": {
          "pwm": "",
          "a": "16",
          "b": "15"
        }
      },
      "model": "gpio",
      "name": "right",
      "type": "motor"
    },
    {
      "attributes": {
        "board": "local",
        "pins": {
          "pwm": "",
          "a": "12",
          "b": "11"
        }
      },
      "model": "gpio",
      "name": "left",
      "type": "motor"
    },
    {
      "attributes": {
        "left": ["left"],
        "right": ["right"],
        "wheel_circumference_mm": 250,
        "width_mm": 400
      },
      "model": "wheeled",
      "name": "your-wheeled-base",
      "type": "base"
    }
  ]
}

Save the config by clicking Save at the top right of the page.

Test the base

After you configure the base, open the base’s TEST panel on the CONFIGURE or CONTROL tabs to view the controls to enable keyboard or discrete control over your machine’s movement.

The base component in control tab

In the Quick move section, you can toggle the keyboard control to active. With the Keyboard toggle active, use W and S to go forward and back, and A and D to arc and spin.

Try driving your base around using the WASD keyboard controls.

You can also move straight, spin, set power or set velocity from the base panel.

If you do not see the base card in the TEST panel, check the LOGS tab for possible setup or configuration errors.

Next steps

Now that you have fully configured your SCUTTLE robot, you can drive it around and view its camera stream.

To take things to the next level, check out one of the following tutorials:

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.