Home > PathBot, Video > Follow Lines – Fork in the Road

Follow Lines – Fork in the Road

**Repost from an article I posted on Mindsensors forums last year.

People have asked me to provide more information about my video on the Mindsensors site about testing the Line Leader sensor. How can the robot make a choice at a fork in the road (line)?
My Video: http://www.youtube.com/watch?v=isf2Kz_jdrA
First, let’s expand on the problem. I found an interesting video a while back on YouTube.com for a Robocup Jr – Rescue competition that outlined some fairly complex rules for following a line to a destination. In short, there are 10+ line configurations that a robot must be able to navigate in order to complete the mission. There is much more to this mission, but the focus here is on following the lines…
Robocup Jr Video: http://www.youtube.com/watch?v=LUvBfAmUm48

Here is a sample line configuration for the robot to navigate.

One configuration is shown above where the robot must follow the line to a circle, and determine which direction to travel to complete it. Markers are provided indicating the correct (suggested) route to follow. Markers on various configuration sheets can be left or right.
I am sure there is some smart robot programmer out there who is saying… “It’s easy with a light sensor or two…” (contact me so I can learn!). The robot somehow needs to determine that it is over a green marker, and turn the robot that direction to continue following the line around the circle to the other side. Sounds easy.
I tried to sense color (light intensity) differences with two NXT light sensors initially, and that works, but light intensity also changes as the robot moves from black line to white surface. To the light sensor, the world is gray-scale and there are no sharp lines. A black line on a white surface looks like this.
It is difficult to find "green" or the gray-scale equivilent in this mess. Here is a crude drawing of what the marker section might look like to a light sensor.
The problem is: How can I distinguish green from the edge of the line? Like I said, I am sure someone out there solved this problem with a light sensor or two, but not me. I implemented the Line Leader sensor to solve the problem. Because I have an array of 8 light sensors, and the Line Leader is great at keeping me on the line, I decided that might be able to use the width of the line as an indicator that I am over a marker.
Knowing the line width should be 2 or 3 detectors wide, I figured there must be a way to determine If the line became wider (over a line and marker). Since the green marker may or may not be detected as part of the line, I implemented custom code to read the raw values from each detector in the Line Leader to compare and calculate my own conclusions.

During initialization, I read the WHITE THRESHOLD values into memory. As the robot follows the line, it also compares the raw values to the white threshold values. If more four or more detectors of the eight are dark, the robot must be over a marker. A little more math is used to determine which side of the line leader has encountered the marker and the robot turns that direction.

Code: Select all
void BEH_LineMarker() {
  byte i;
  byte tL = 0;
  byte tR = 0;
      LLReadSensorRaw(LineLeaderPort, llRaw);
     for (i=0; i<4; i++) {   //COMPARE THE LEFT SIDE OF THE LINE LEADER
         if (llRaw.arr[i] < llWhite.arr[i]){
      for (i=4; i<8; i++) {  //COMPARE THE RIGHT SIDE OF THE LINE LEADER
         if (llRaw.arr[i] < llWhite.arr[i]){

When called, this code reads the raw values into llRaw.arr for each of the 8 detectors in the Line Leader. As it compares to the white threshold values, it updates the left or right counters. At the end of comparison, if more than 4 detectors see dark, we must be over a marker, so… If most of the detections where on the right, turn right. If most of the detections were on the left, turn left.
RequestControl() and DeclineControl() are behavior-based fucntions that determine if this behavior wants to control the motors or not. More in another post….

  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: