Color Tracking with Movement


This tutorial demonstrates how to enable Movement tracking to have your Six or Roli robot track a ball. There are two kinds of tracking behaviors, each with their own parameters. Do not confuse a tracking behavior with a tracking type. Here are the differences...

Tracking Type: This is how the robot is tracking. Meaning, what is it tracking? Color? Motion? Face? Glyph? Etc, you get the point. The tracking type is what the camera is looking for. Tracking types are found on the main screen of the Camera control under the Tracking tab. They are check-boxes, when checked means the respective tracking type is active.

Tracking Behavior: This is how the robot responds to the tracking type, as in the behavior when it tracks/recognizes an object. The robot may move servos to follow the tracked object or it may move the entire robot toward the object. A behavior is how the robot will respond to the object that it is tracking. In addition to having the robot physically move in response to a tracked object, you may also have the robot execute scripts when it detects an object, this is also a behavior. The Tracking Behaviors are found in the Settings dialog of the Camera control.

This tutorial uses the Camera Device. Not sure if you have noticed yet, but at the bottom of every tutorial are links to EZ-Builder Controls for further reference. In this example, you will find a link to the EZ-Builder Camera Device at the bottom of the tutorial for further reading. Some lessons do not reference controls, therefore they will not have any listed. This lesson does have a reference link, and you will find it at the bottom of this tutorial.

*Note: This demo will not work with JD. Instead, JD can track an object with Servo Tracking. This will be covered in another tutorial.

What You Will Need

  • A calibrated, assembled, connected and Six or Roli with charged battery
  • A red ball in a brightly lit room with little shadows.
  • Load the default example project for your robot (Roli or Six)

*Note: We will be tracking a color in this lesson. This means that any objects in the background of the same color (red) will confuse the robot. Always track colors in a room without other similar colors in the background.

Step 1

The "What You Will Need" section asked you to connect your Roli or Six robot and load the default project. You have done that, right? Okay good! Now locate the Camera Control and press the GEAR icon. We know you're not skipping ahead through tutorials, so you must have read the tutorial where we explain that every control has a gear icon, and that gear icon accesses the settings of that control. Okay, press the gear button.

Step 2

The settings for the camera will appear. This is a really fun configuration screen - however, as a beginner it may look confusing. So before you start playing with anything, let's compare the default settings from your project to the screenshot above. We want you to ensure they match. See, it is just like Where's Waldo...

Verify the Servo Tracking check-boxes are not checked. This is because we are not using Servo Tracking, right? We are using the Movement Tracking Behavior, which is moving the robot. The movement of the robot is done by the Movement Panel. Every robot has a Movement Panel, that is how the robot knows how to move. You must already know this from the previous prerequisite lesson of using EZ-Builder. The Roli robot uses a HBridge PWM Movement Panel, and the Six robot uses the Auto Position Movement Panel. Do not worry about how the robot knows what direction to turn yet, we cover that later in this lesson.

Now, you might be wondering why one of the highlighted settings in the above photo is red? That is a special setting! It is special between different robots. When the robot detects an object, it will move in a direction for that specified amount of time before checking for the object location again. If this setting is too low, the robot will jerk but not move. If the setting is too high, the robot will turn completely and lose site of the object. Roli usually has a setting around 100ms to 200ms, depending on the PWM speed of the HBridge. It is a good idea to fine tune Roli's PWM speed in his HBridge Movement Panel to a slower speed, otherwise he will move too quickly. Six is a different story, because his movement takes much longer time to turn. Setting Six's movement delay to 2000ms or 3000ms will allow his legs to give him enough time to turn. We don't want to give you all the answers right away, so now you have something fun to play with. Find the value that is right for your robot based on its speed when this lesson has been completed. For now, set it to the recommended values that we listed above.

When you are confident the configuration matches the above image, press the SAVE button to save the settings. The dialog will close. You may return to this settings page to fine tune the Movement Delay once you have completed the lesson.

Step 3

In the main Camera control, press the TRACKING tab and select COLOR.

Step 4

Hold your bright red/orange ball in front of the camera. We will tune the color settings to detect the object in the next step.

Step 5

Slide the Object Brightness dial left and right to fine tune the object detection. You want the blue square to be around the object, without highlighting other detected items. The preview window will display RED on any objects it is detecting. You only want the detected object to be highlighted in red, with a blue box around it.

How close to you hold the object to the camera? Hopefully the image demonstrates that it should not be close to the camera. You sure wouldn't want someone holding an object very close to your eyes, not only would it be intrusive, but you would have no sense about the direction the object is moving.

*Note: Leave the Min Object Size slider at it's default setting. There is no need to change this value at this time.

Step 6

This step is an example of what the color tracking should not look like. When adjusting the brightness of the detected object, you do not want other fragments of color being detected. These are called false positives and will prevent your robot from knowing what color to follow. Because you are asking the robot to follow a color, it is important that the color you wish it to follow is identified. The photo above demonstrates how the Brightness is adjusted too bright and more than the object is detected.

*Note: If you are unable to adjust the Brightness slider to remove false positives, then we must consider the object is not fit for tracking or the room environment is too dark. Use a bright red ball, which can be found at toy stores.

Step 7

Remember we mentioned that you will learn how the robot follows an object? Well, we reminded you of a Movement Panel few steps ago. Now we are going to explain how the robot knows when to move forward or turn while tracking the object.

The robot will use the Movement Panel to turn. The robot knows which direction to turn by the location of the object within the camera view. This is done using the grid lines, which you have probably wondered what they were for. The grid lines determine what direction the robot will move to follow/track the object. If the object is detected in the LEFT grid quadrant, the robot will turn left. If the robot is in the RIGHT quadrant, the robot will turn right. If the object is detected in the CENTER quadrant, the robot will move forward. In this lesson, the TOP and BOTTOM quadrants are not used. You will only use the Top and Bottom quadrants for Movement Tracking when using a flying robot (i.e. AR Parrot Drone).

Keep in mind that the robot will only move forward if the check-box from step #2 is checked. If you would like, scroll up to Step #2 and see if you can find the check-box that we are referring to. I'll give you a hint, it is highlighted in yellow.

The tab of the above screenshot is labelled GRID, for a good reason. This is where you adjust the grid lines using track-bars. The default grid positions are usually okay. However, they may be adjusted for your tracking preference and size of the object. Remember, we are only using the LEFT and RIGHT quadrants, which means only adjusting the top track-bars that are highlighted in the image above. The track-bars will move the vertical grid lines to expand and shrink the RIGHT and LEFT quadrants.

*Note: Hold the object far enough away so it fits in one of the sides of the quadrants.


Congrats, you have setup your Roli or Six to track a ball.. Or, have you? Did you get the Movement Delay determined for your robot? You can revisit Step #2 and fine tune the Movement Delay until it suits your preference.

Last updated 9/29/2015

Select Your Product

This lesson applies to multiple robot products. Select your product below for related lessons.

Revolution Six
Revolution Six

Revolution Roli
Revolution Roli

EZ-B v4 & IoTiny
EZ-B v4 & IoTiny

AdventureBot & BattleFlipper
AdventureBot & BattleFlipper