- :-

Topics Covered

  • Line Tracking Behavior
  • LineTrackLeft Command Block
  • Lesson Links

    Check Your Understanding:
    1. 1. If the robot's Color Sensor is seeing black, what can it tell about its position?
    2. It is over the line
      It is outside the line to the left
      It is outside the line to the right
      It is facing Northward
    3. 2. Suppose the robot is tracking the left edge of the line, and sees Black. Which way should it move?
    4. Forward and to the left, because the left edge is that way
      Forward and to the right, because the left edge is that way
      Straight forward because the line will curve eventually
      Turn left in place, because the left edge is that way
    5. 3. Which basic program pattern is being used in this Line Tracking behavior?
    6. Sequential Movements
      Wait For sensor
      Variables
      Repeated Conditional Behavior
    Try It!
    Try it! 1

    Right-edge Line Tracking

    Modify your program to track the right side of the line using the lineTrackRight command block. Try it!

    What do you notice? How is this different from the original program?

    What happens?
    The robot tracks the right side of the line. When the color sensor sees black it turns to the right. When the color sensor sees white, it turns toward the left.
    Try it! 2

    Line Tracking Threshold

    When the robot is line tracking, the color sensor provides the amount of reflected light from the surface under it. Dark surfaces absorb light, while bright surfaces reflect it.

    Download and run the included program.Try it!

    Physical Robot Users

  • Using the EV3's menu, navigate to the Brick App tab and select Port View.
  • Use the port view on the EV3 and observe the value of the Color Sensor set for Reflected Light (COL - REFLECTED).
  • Place the robot so that the color sensor is over the black line and write down the value reported on the EV3's LCD screen.


  • Then, move the robot so that the color sensor is over the white surface and write down the value reported on the EV3's LCD screen.



  • Virtual Robot Users


  • Run the program and use the WASD keyboard keys to move the robot so it is over a black surface.
  • Use the Robot > Debugger Windows > EV3 Remote Screen to see the value reported. Write it down.
  • Use the WASD keyboard keys to move the robot so that it is over the white surface. Write down the value reported on the EV3 Remote Screen.


  • To calculate the perfect threshold value for your environment:

    • Add the two values you recorded, and divide them by two.

    • Use this value in the second box of the lineTrackLeft and lineTrackRight command blocks for the most reliable results when line tracking.
    What do you notice? How is this different from the original program?

    1. 1. The robot is attempting to line track a black line on a white surface.
      If the color sensor gives a reading above the threshold, what does this mean?
    2. The color sensor is over white
      The color sensor is over black
      The color sensor will never give a reading above the threshold
      The threshold value is wrong
    3. 2. Your robot is doing right side line following.
      If the color sensor gets a value that is below the threshold, which way should I move?
    4. Forward and to the left
      Forward and to the right
      Straight forward because the line will curve eventually
      Turn right in place, because the right edge is that way
    Try it! 3

    Turning Ratio

    The last two boxes of the lineTrackLeft and lineTrackRight commands are motor speeds, and affect how sharply the robot will turn toward and away from the black line. Try it!

    To test out your robot in this activity, a line tracking course that has
    a straight porition and a curved portion is recommended.

    Below is an example of how the course could look:

    Part1 : Modify your program so that the second box is set to 100 and the third box is set to 0. Download and run your program on a line tracking course that includes both straight and curved portions.

    What happens?
    The robot turns very sharply, overshooting the line on the straight portions of the course.

    Part2 : Modify your program so that the second box is set to 50 and the third box is set to 40. Download and run your program on the same line tracking course.

    What happens?
    The robot turns much more gradually, which works well on the straight portions of the course, but fails to track the curved portions.
    1. 1. Why is it important to control the speed at which the robot tracks a line?
    2. If the robot turns too fast and "overshoots" the line, it will not track the line correctly
      If the robot turns too slowly, it will not track sharp turns in the line
      Depending upon how straight or curved a line is, it may require the robot to turn at different speeds
      All of the above
    Mini Challenge

    Mini Challenge 1: Line Track 4 Rotations

    Program your robot to track the line conditionally!
    • Place the robot on line tracking table
    • Modify the behavior of your program so that it stops line tracking after 4 Motor Rotations on the Left Motor.

    How did you make your other Repeated Decisions Behaviors stop at a certain point?.

    Use a RepeatUntil Loop Block, set to use the value of the motor encoder, instead of a RepeatForever Loop Block.

    + hint
    Did You Know?

    Did you know?

    How the lineTrack Command Blocks work
    The lineTrackRight and lineTrackLeft Command Blocks contain a built-in conditional behavior that allows the robot to track the edge of a line.

    The same conditional behavior can be created using an if-else conditional block.