Charlotte EdelsonAnya RamamurthyJessamy Taylor
Published

How to Build a Line Following Rover Using Color Detection

Use this project to build a line following rover with a webcam using color detection

BeginnerFull instructions provided2 hours1,345
How to Build a Line Following Rover Using Color Detection

Things used in this project

Hardware components

SCUTTLE Robot v2.4
SCUTTLE® SCUTTLE Robot v2.4
×1

Software apps and online services

Viam Platform
Viam Robotics Viam Platform

Story

Read more

Custom parts and enclosures

Viam Robotics

viam robotics

Schematics

Viam Robotics

Viam Robotics

Code

Full example config

JSON
Below is an example JSON file that includes the board, base and camera components, and a vision service color detector. You may have different pin numbers and other attributes depending on your hardware setup.
{
  "components": [
    {
      "name": "local",
      "type": "board",
      "model": "pi",
      "attributes": {},
      "depends_on": []
    },
    {
      "name": "leftm",
      "type": "motor",
      "model": "gpio",
      "attributes": {
        "pins": {
          "a": "15",
          "b": "16"
        },
        "board": "local",
        "max_rpm": 200
      },
      "depends_on": [
        "local"
      ]
    },
    {
      "name": "rightm",
      "type": "motor",
      "model": "gpio",
      "attributes": {
        "pins": {
          "b": "11",
          "dir": "",
          "pwm": "",
          "a": "12"
        },
        "board": "local",
        "max_rpm": 200
      },
      "depends_on": [
        "local"
      ]
    },
    {
      "name": "scuttlebase",
      "type": "base",
      "model": "wheeled",
      "attributes": {
        "width_mm": 400,
        "wheel_circumference_mm": 258,
        "left": [
          "leftm"
        ],
        "right": [
          "rightm"
        ]
      },
      "depends_on": [
        "leftm",
        "rightm"
      ]
    },
    {
      "name": "my_camera",
      "type": "camera",
      "model": "webcam",
      "attributes": {
        "video_path": "video0"
      },
      "depends_on": []
    },
    {
      "name": "show_detections",
      "type": "camera",
      "model": "transform",
      "attributes": {
        "source": "my_camera",
        "pipeline": [
          {
            "type": "detections",
            "attributes": {
              "detector_name": "green_detector"
            }
          }
        ]
      },
      "depends_on": []
    }
  ],
  "services": [
    {
      "name": "",
      "type": "vision",
      "attributes": {
        "register_models": [
          {
            "type": "color_detector",
            "parameters": {
              "detect_color": "#19FFD9",
              "segment_size_px": 100,
              "hue_tolerance_pct": 0.06
            },
            "name": "green_detector"
          }
        ]
      }
    }
  ]
}

Viam Robotics

Viam Robotics

Credits

Charlotte Edelson

Charlotte Edelson

5 projects • 8 followers
I head up all things community at Viam, a modern robotics software platform.
Anya Ramamurthy

Anya Ramamurthy

1 project • 6 followers
I'm part of the Viam team and I'm excited about connecting with the robotics community!
Jessamy Taylor

Jessamy Taylor

0 projects • 4 followers
I write tutorials and documentation at Viam, a modern robotics software platform.

Comments