The Robotics Primer Workbook
Developed by  USC, iRobot® and Microsoft® Robotics Studio
Categories: Exercise | Player Exercise

Sensors:Exercise6:Color blob tracking

Contents

Setup

This exercise requires the use of the Gumstix hardware. You will also need the CMU Cam 2+.

Before using the CMU Cam2+ you should connect it to a PC to test it and become familiar with its functionality. The CMU Cam2+ manual contains instructions for connecting the camera to a PC and running their java GUI. Use the Acroname serial interface to connect a serial cable between the CMU Cam2+ and your PC. The java GUI provides a convenient method to test the functionality of the camera and gain an understanding of the data it returns.

You will also need to make a serial cable to interface the camera with the Robostix. Follow these instructions:

Howto:Build a CMU Cam2 to Robostix Serial Cable

Part 1: Color Blob Detection

The CMU Cam2 is primarily used for color blob detection. Image frames are processed on the CMU Cam2+ and color blob information is sent back over a TTL serial connection. This part of the exercise will familiarize you with the CMU Cam2+ and Robostix, and ensure that your setup works properly.

First connect the CMU Cam2+ to your PC and run the java GUI (see the Setup section). Hold a colored piece of paper in front of the camera. Select the paper using the GUI, and write down the color information found in the Color tab.

Captured frame with colored paper
Enlarge
Captured frame with colored paper
Colored paper selected
Enlarge
Colored paper selected
Color info
Enlarge
Color info

Connect the CMU Cam2+ to the Robostix using the serial cable built in the Setup of this exercise. Make sure to plug in the cable properly. Pin 1 on the cable ends should connect to pin 1 on the Robostix and camera.

TTL serial cable and Robostix
Enlarge
TTL serial cable and Robostix
TTL serial cable and CMU Cam2+
Enlarge
TTL serial cable and CMU Cam2+

Once the camera has been attached to the Robostix, create a Player configuration file. This file will instruct player what color(s) we wish to track using the CMU Cam2+

# Driver for the Roomba
driver
(
  name "roomba"
  provides ["position2d:0" "ir:0" "power:0" "bumper:0" "opaque:0"]
  port "/dev/ttyS2"
  safe 1
  alwayson 1
)

# Driver for the Robostix
driver
(
  name "robostix"
  provides ["aio:0" "sonar:0" "blobfinder:0"]
  alwayson 1

  i2c-dev "/dev/i2c-0"

  num_blobs 1
  color0 [0 93 110 255 0 94]
)

Run the Player server with your configuration file.

$ player cmucam2.cfg

Run the example program located in TODO-write the example program.

$ ./cmucam2_test client.xml

At this point the cmucam2_test program should write out information about what color blobs the CMU Cam2+ currently detects. Hold the piece of paper in front of the CMU Cam2+ and move it around. Take note of what information changes as you move the piece of paper.


Modify the Player configure file and the example program to track two different colored blobs.

Part 2: Lights and Colors

Whenever a sensor is used, its limitations and requirements must be understood. Vision based sensors tend to be finicky, and the CMU Cam2+ is no exception. Different lighting conditions can affect how well the camera detects blobs, and colors that do not exist naturally in the environment must be used.

Gather together a variety of colored paper, and cut out a square of each. Use the CMU Cam2 java program to access the camera images, and select the colored squares for color tracking. Describe your results. Were only the squares highlighted, or did the CMU Cam2 also select parts of the background? Which colors worked best?

With the same color squares vary the lighting conditions. Make the lights dimmer, and try using direct sunlight if possible. Describe how different light intensity and types affect the camera. Did certain colors work better than others in sunlight or dim light?

Answer

Part 3: Color Tracking

This final part of this exercise will combine the CMU Cam2+ and the robot. Your job is to write a controller to rotate the robot so that is follows a moving color blob. Connect the CMU Cam2+ to the Gumstix, and pick a color that works well in your environment. First make sure the camera can detect the color square. Now use the color blob information to rotate the robot whenever the color blob starts to leave the camera's field of view.

Answer

Retrieved from "http://roboticsprimer.sourceforge.net/workbook/Sensors:Exercise6:Color_blob_tracking"

This page has been accessed 2,500 times. This page was last modified 00:52, 4 April 2007. Content is available under GNU Free Documentation License 1.2.


Browse
Main Page
Glossary
Sections
Prerequisites
Introduction
Robot Components
Locomotion
Sensors
Feedback Control
Deliberative Control
Reactive Control
Hybrid Control
Behavior-based Control
Emergent Behavior
Navigation
Group Robotics
Learning


Log in / create account