How many line sensors does your robot use? I was thinking about using 3 or 6. How would I prograam 3 or 6? My next question is how does your team legally deal with different lightings that could possibly effect your sensors. Such as spot lights at worlds? Could you post the code. How do you set up the line sensors on your robot. Is there any benefit for using 6 then 3?
Any code you may have will be greatly appreciated with explanations.
Typically you would use three line followers placed in line with each other. I don’t know which programming language you use, but the basic logic is easy enough. Go straight if the center one sees white, go right if the right one sees white, and go left if the left one sees white. Now that’s the simplest way that you can go, but you can also use PID control with the line followers that will give you a much smoother and way to line follow. Here is a page which explains that. http://www.inpharmix.com/jps/PID_Controller_For_Lego_Mindstorms_Robots.html
Now for making them work in different lighting. Many people take the reading at each field, and use it as a baseline. But I’m lazy, so I try and do the least amount of work possible. I put a fourth line follower right next to the three that I’m using. Then I place a piece of white electric tape down as close to the field as possible right under that fourth line follower. That way, you can always know what white is, even if the robot travels under a spotlight.
Have you tried using a piece of IR-opaque material surrounding the line-tracker sensor to completely block the ambient light, per <R7>a?
The theory looks good. A pound of lead foil will help lower your CG as well.
Other past suggestions:
Start with one sensor on the line, and one sensor off the line, and take those starting values to calculate the midpoint threshold.
Use a knob on a pot as an input to set the “black” level, and an LED as output to tell you when line-sensor value is greater than pot value; that way you can adjust the level without reprogramming.
Look at the LineFollow function, the first part of the while loop is about cotnrolling the speed, the second section is about reading the line sensors, and the third part is seeing when to stop.
Take the speed contro las is. You want to understand the sensor handling first and foremost since it is the real control part of this function.
Based upon what the sensors see, the robot thinks it is at a cross and keeps going, or it adjusts its left/right speeds to get closer to the middle sensor to be the one on the line.
Up in the global variables area you can see their calibration of bright dark and mipoint used to look for the line. Those suggestions in previous posts would be used in setting with the midpoint value based upon lighting.
The speed part gets the robot to not get too out of wack and overdrive the lines.
I think this is the wrong approach to the problem at hand.
“I want to use 6 sensors, how can I do that?” is silly. That’s not the problem. Your problem is more likely “I want to follow a line. How many sensors do I need to effectively do it?”.
Three is standard, but I’ve seen teams use 4 or 5. One team used 4 sensors this way. They would drive toward a line and wait for the first sensor (ahead of the others) to trip, then they would slow to a crawl. Once the second set of three sensors “caught” the line, they would spin until they were properly oriented and then track the line.
I agree, more sensors are not necessarily better, successful line tracking is more about where the sensors are placed, how far from the ground, where are they in relation to the axis of rotation of the chassis etc. Start with three, write some code and get a feeling for how they work and react. If you then feel adding more will improve the control algorithm then thats the time to do it.
Our line following code worked very well, however I hope to try some PID code this year. I’ll be posting my code at the end of the competition year, and maybe earlier as well.
Our solution to “What if the robot drives under a spotlight?” was simply to mount the Line Followers about as low to the ground as possible. We never really had any problems, and this gave us the largest different between the value for the gray tiles and the value for the white tape lines.