|
Light Sensors, Part 3 |
|
|
|
Improved Line FollowingIn the previous light sensor lesson we studied different approaches to following a line, all using a single light sensor. In this lesson we're going to see how adding an additional light sensor to our robot can improve its ability to follow a line. Why two light sensors are better than oneSo why are two light sensors better than one when it comes to following a line? The short answer is that using two light sensors gives you more information to work with so you can be more precise in telling your robot what to do. The reason you get more information with two light sensors is similar to why two eyes work better than one - you can examine and evaluate more of your environment at one time. There are several different techniques you can use when writing a program that uses two light sensors. First, depending on the width of the line you want to follow you can position the light sensors close together and write your program to keep both light sensors on the line. Second, you can position the light sensors farther apart - again, the spacing depends on the width of the line you want to follow - and straddle the line. With this technique you would want to keep both of the light sensors off the line. Yet another approach, similar to the single light sensor design presented in the previous lesson, is to follow an edge of the line by positioning the light sensors so that one of them is on the line and the other is not. The third approach is the one presented in this lesson. Line following programOnce you've decided on an overall design for your program you still need to figure out how it's going to work. Just like there are multiple ways to position the light sensors there are different program designs you can use to follow a line edge with two light sensors. We present one possible solution in this lesson. You may want to see if you can come up with a different and possibly better one. Program descriptionThis line following program will continually evaluate the light sensor readings, keeping track of the lightest and darkest values the robot sees. Using these values it can decide at any given time how close it is to the optimal position. The light sensor that is positioned over the line should return the lowest possible value and the other one should return the highest possible. To make the program easier to read and maintain we will divide it into three segments:
Pseudo-code
Robolab codeThe three main segments of the program are shown here as Robolab program diagrams.
|
|
|
|
|
|
Copyright © 2003, Hacienda Robotics Program. |
|