How to Configure a SCUTTLE Robot with a Camera

Instructions for configuring a SCUTTLE Robot on the Viam platform

This tutorial will guide you through setting up a SCUTTLE Robot with a camera.

Requirements

Configuring the Board

  1. Begin by accessing Viam at https://app.viam.com.
  2. If you are using an existing robot config, select your robot's config and skip to Step 5.
  3. Create an Organization. If you already have an Organization, then this step is optional.
  4. Create a Location. If you already have a Location, then this step is optional.
  5. Add your first component, the Raspberry Pi.
    1. Enter a name for your robot in Name, then click Add to add your robot and access your robot's configuration page. In this tutorial, we've named the board "local." As long as you're consistent, you can name the board whatever you want.
    2. Select the component Type, "board."
    3. Select "pi" from the Model drop-down.
    4. Click Save Config to save the new component, which will generate an empty JSON configuration:
This image is the component configuration panel for a board component.
The Depends On drop-down listbox has no selection.
Initially, the left-side Attributes panel for board component is empty.
The right-side panel contains a list of available board component Attributes.

Configuring the Motors and Wheels

Adding the Right-Side Wheel

The next step is to add a wheel and make it spin. The first step is to create a NEW COMPONENT.

  1. Begin by adding the Right-Side Wheel, naming the component right.
  2. Select "motor" from the Type drop-down.
  3. Select "gpio" from the Model drop-down.
  4. Click Create Component, which will bring you to the following screen:
  5. Fancy component config screen for a Motor.

    This screen provides read-only displays of JSON configuration and allows you to select which board controls this motor, to toggle the Component Pin Assignment between Direction and Int1/Int2, and to Enable Pins (i.e., set them to High, Low, or Neither). Also, you can add a Frame and a Data Capture Pathway, and set the Depends On.

  6. Next, you'll need to describe how the motor is wired to the Pi:
    1. Click Go to Advanced. You'll now see the current JSON attributes for this motor component and a reference for the available attributes:
    2. Advanced component config screen for a Motor.
    3. Then select local from the Depends On drop-down (since the motor is wired to the Raspberry Pi named "local."
    4. Make the following changes to the JSON:
      1. Set a to 16
      2. Set b to 15
      3. Leave the dir and pwm (pulse-width modulation) pins blank, because this specific motor driver’s configuration does not require those settings.
      4. Set max_rpm to 100
      5. Set board to local

Right-Wheel JSON

{
 "pins": {
   "a": "16",
   "b": "15",
   "dir": "",
   "pwm": ""
 },
 "board": "local",
 "max_rpm": 100
}

Testing the Motor Configuration

Having entered a board and a motor component, you can now actuate your motor. Save the config by clicking SAVE CONFIG at the bottom of the page, then click CONTROL at the top of the page to navigate to the Control Page.

On the Control page, you’ll see a panel for the right motor. You’ll use this panel to set the motor’s power level.

Be careful when activating your robot! Start with the power level (RPM) set to 10% and increase it incrementally until the wheel rotates at a satisfactory speed.

At this point, the right-side wheel should be working.

Adding the Left-Side Wheel

Now, you’re ready to add the left-side wheel to start driving this robot in a coordinated manner. To do this, you’ll have to add the second motor controller and link them with a base.

Once again, you’ll select NEW COMPONENT. The config attributes for the left motor controller are very similar to that of the right motor component that you already configured (since the hardware is the same and connected to a single board).

  1. Add the Left Side Wheel, naming the component left.
  2. Select "motor" from the Type drop-down.
  3. Select "gpio" from the Model drop-down.
  4. Click Create Component. Viam opens the component config panel for the wheel.
  5. Now, tell Viam how this motor is wired to the Pi:
    1. First, select the board name from the Depends On, which in our case is "local."
    2. Now, make the following changes in the Left-Wheel's JSON:
      1. Set a to 12
      2. Set b to 11
      3. Leave the dir and pwm (pulse-width modulation) pins blank, because this specific motor driver’s configuration does not require those settings.
      4. Set max_rpm to 100
      5. Set board to local

Left-Wheel JSON:

{
 "pins": {
   "a": "12",
   "b": "11",
   "dir": "",
   "pwm": ""
 },
 "board": "local",
 "max_rpm": 100
}

With both motors configured, the component page now display panels for both motors:

Viam (https://app.viam.com) displays component panels in order of their creation. Therefore, it’s normal if your motor panels are not adjacent.

Configuring the Base

Unite your wheels with a base component, which describes the physical structure onto which your components are mounted. Configuring a base component will give you a nice UI for moving the rover around.

From the Config screen:

  1. Enter “base” in Name.

  2. Enter “wheeled” in Model.

  3. From Depends On, select three items: “left,” “right,” and “local.”

  4. Enter “400” in width_mm (measured between the midpoints of the wheels).

  5. Enter “250” in wheel_circumference_mm.

  6. Enter “left” in “left”

  7. Enter “right” in “right”

    The left and right attributes are intended to be the motors corresponding to the left and right sides of the rover. You can simply add “left” and “right” between the brackets for your set of motors, respectively.

The configuration of your base component’s attributes should look something like this:

{
 "width_mm": 400,
 "wheel_circumference_mm": 250,
 "left": ["left"],
 "right": ["right"]
}

When you save the config and switch to the Control tab, you’ll see new control buttons for the base. In the Keyboard tab, toggle your keyboard control to active, and then use W and S to go back and forth, and A and D to arc and spin.

If you click the Discrete tab, then you’ll see different movement modes such as Straight and Spin; and different movement types such as Continuous and Discrete and directions such as Forwards and Backwards.

Now you have a rover that you can drive via Viam’s UI at https://app.viam.com.

Try driving your SCUTTLE Robot around using the WASD keyboard controls described above.

Configuring the Camera

Finally, we’ll add a camera to your SCUTTLE Robot. To begin, click NEW COMPONENT before proceeding to the steps below.

  1. Enter “camera” in Name.
  2. Enter “camera” in Model.
  3. From Depends On, select “local.”
  4. Click Create Component.

Now, you’ll see the config panel for the camera component:

On the Camera Config panel:

  1. Enter “camera” in Name.
  2. Enter “camera” in Model.
  3. From Depends On, select “local.”
  4. In the JSON, set video_path to “video0.”

If you wish to copy and paste code for your camera, use the following:

{
 "intrinsic_parameters": {
   "width_px": 0,
   "height_px": 0,
   "fx": 0,
   "fy": 0,
   "ppx": 0,
   "ppy": 0
 },
 "distortion_parameters": {
   "rk1": 0,
   "rk2": 0,
   "rk3": 0,
   "tp1": 0,
   "tp2": 0
 },
 "stream": "",
 "width_px": 0,
 "height_px": 0,
 "debug": false,
 "format": "",
 "video_path": "video0"
}

Once you save the config, you’ll be able to see your camera’s stream in the Control tab.

On Completion

After successfully completing this tutorial, you should have a fully functional SCUTTLE Robot. You can drive it around and view its camera stream. To take things to the next level, check out our Color Detection with SCUTTLE Robot tutorial or create your own camera-related tutorial. Alternatively, you can check out our Bluetooth Gamepad For SCUTTLE tutorial or our Line Follower Robot tutorial.

Documents Referenced