Lab 2: Line Following

 

Lead TAs:

Challenge Statement:

Create a mobile robot that when placed at the begining of a white line on a dark plane, follows the line to the end.

Demo:

  1. Place the robot in any desired orientation on the start position marked in the map shown below with the light sensor pointing towards the center of the white line.
  2. Input desired light / dark cutoff value (this can also be done before placing the robot). The ambient lighting will be constant and directional lighting will be such that issue like the robots shadow will be minimized.
  3. Start the robot that should follow the white line passing over the first checkpoint, the half-way checkpoint, the second checkpoint and the goal.
  4. The half-way checkpoint will not be graded unless the robot passes over checkpoint 1 and similarly, credit will not be given for a robot passing over the goal unless it passes over checkpoint 2.
  5. It is OK to have undefined behavior after passing over the goal.
  6. Three tries will be given in order to improve your score if needed. All tries are independent of each other.

Map:

map
Approximate map with various checkpoints marked

How to:

Method 1 (Hug the right boundary) :

  1. Build a differential drive robot using two motors - one for each wheel.
  2. Attach the LEGO NXT light sensor so that it faces down towards the ground.
  3. Write a program that does the following :
      i) If the sensor reading indicates a white line, move right.
      ii) If the sensor reading doesn't indicate a white line, move left.

Method 2 (Course correction) :

  1. Build a differential drive robot using two motors - one for each wheel.
  2. Attach the LEGO NXT light sensor so that it faces down towards the ground.
  3. Write a program that does the following :
      i) If the sensor reading doesn't indicate a white line stop.
        a) Rotate left inplace until a white line is found or for a specified time period. If a line is found goto (ii).
        b) Rotate right inplace until a white line if found or for twice the time period. If a line is found goto (ii).
        c) Otherwise, the robot has gone too far away from the line and must do something else to get back or just give up.
      ii) Drive straight.

Other tips:

  1. Make sure that the light sensor is polled frequently and the PID update interval is small (around 10 - 20 ms) or else the robot may lose sight of the line and never get back.
  2. Don't make the robot move too fast.
  3. Add user input for the light - dark cutoff value as light conditions during the demo will be unknown. The starter code does this.
  4. Enable motor teaming to make the robot go straight if needed.
  5. Go for a simple but solid design as this robot can also be used for the next four labs with minor modifications.
  6. Make the robot smaller than 6' x 6' not including the sensor if you plan on using the same design for labs 5 and 6.

Sample starter code: Code fragment for method 1 written in RobotC.

Evaluation:

  1. Robot seems to follow the line - 20 points
  2. Reached half-way checkpoint (via checkpoint 1) - 30 points
  3. Reached finish (via checkpoint 2) :
      i) In over 45 seconds - 30 points
      ii) In under 45 seconds - 50 points

Grading Sheet: Lab 2

Keywords: Motor Teaming, PID, Light Sensor


Last Updated : 10/16/07 by Kaushik Viswanathan
(c) 1999-2007: Howie Choset, Carnegie Mellon