A line follower robot is able to follow some arbitrary track without any physical connection with the track except for the wheels. This method has great advantages over something like tracks or rails since the cost of laying down a new course is just the cost of paint! Line follower robots have many commercial applications such as autonomous cars on roads or forklifts in large factories. One of the main math concepts behind a popular line following algorithm is something called a PID controller. It may sound complex and calculus-y since the "I" stands for integral and the "D" stands derivative but we'll just be making a P controller ("P" stands for proportional) so no worries.
First, consider the Mindstorms light sensor. Let's say when the light sensor is completely over a white color it will read a "100" and if it's completely over a black color it will read "0". Or - and this part is important - if it's pointed at something that is white on one side and black on the other it will read a value somewhere around "50". This all should make sense since white pigment is more reflective then black pigment. Now, if you can answer the following three questions you should start seeing how a line following robot could be made. Keep in mind that we want the robot to always go straight along the edge between black and white.
Question: Roughly speaking, what would the light sensor read in each scenario? If we want to go straight, how much power should we put in each motor? See if you can answer these questions then click to find the answers.
Since the light sensor is perfectly in the middle of black and white the light sensor should read roughly "50". This also means the robot is already going straight and we don't need to adjust the motor speeds.
Now the light sensor is all the way in the black and the light sensor should read roughly "0". This also means the robot is veering left and we need to put more power into the left wheel.
Now the light sensor is all the way in the white and the light sensor should read roughly "100". This also means the robot is veering right and we need to put more power into the right wheel.
This is a lot like Scenario (C) except a little bit of black is in the sensor as well. This means the light sensor won't quite be "100" - let's say it reads "80". We should probably put more power into the right motor but maybe not as much as when the sensor reads "100".
The math at this point is fairly straightforward. We'll just write down a few input / output relationships between sensor reading and motor power, find the linear mapping (slope and intercept) then we can find the motor power for ANY sensor reading. For example consider two possible approaches to staying on the edge:
(A)
Light Reading
Right Motor Speed
50
50
100
100
0
0
75
75
(B)
Light Sensor
Right Motor Speed
50
50
100
55
0
45
75
52.5
Approach (A) is very violent. When the light sensor is off the edge it puts full power (or no power) into the motor to correct. This may lead to oscillations around the edge. Approach (B) is more cautious. It tries to gradually right the ship. This may lead to not adapting fast enough, especially around turns, and the robot veering off course.
Now find some equation that maps the light sensor reading to the right motor speed. Notice the defining difference between (A) and (B) is the slope! That's why this is called a P-Controller. We adjust the motors (p)roportionally to the error we read in the light sensor.
Challenge Rules
This will be a double elimination tournament. Robots will go head-to-head on equal length tracks. The first robot to cross the finish line will be declared the winner for that round. A couple rules:
1. Any robot design can be used; however, you are only allowed to use one light sensor.
2. If your robot leaves the track, the judge will signal the team and they are allowed to place the robot back on the track from the point of its departure.
A line follower robot is able to follow some arbitrary track without any physical connection with the track except for the wheels. This method has great advantages over something like tracks or rails since the cost of laying down a new course is just the cost of paint! Line follower robots have many commercial applications such as autonomous cars on roads or forklifts in large factories. One of the main math concepts behind a popular line following algorithm is something called a PID controller. It may sound complex and calculus-y since the "I" stands for integral and the "D" stands derivative but we'll just be making a P controller ("P" stands for proportional) so no worries.
First, consider the Mindstorms light sensor. Let's say when the light sensor is completely over a white color it will read a "100" and if it's completely over a black color it will read "0". Or - and this part is important - if it's pointed at something that is white on one side and black on the other it will read a value somewhere around "50". This all should make sense since white pigment is more reflective then black pigment. Now, if you can answer the following three questions you should start seeing how a line following robot could be made. Keep in mind that we want the robot to always go straight along the edge between black and white.
Question: Roughly speaking, what would the light sensor read in each scenario? If we want to go straight, how much power should we put in each motor? See if you can answer these questions then click to find the answers.
The math at this point is fairly straightforward. We'll just write down a few input / output relationships between sensor reading and motor power, find the linear mapping (slope and intercept) then we can find the motor power for ANY sensor reading. For example consider two possible approaches to staying on the edge:
(A)
(B)
Approach (A) is very violent. When the light sensor is off the edge it puts full power (or no power) into the motor to correct. This may lead to oscillations around the edge. Approach (B) is more cautious. It tries to gradually right the ship. This may lead to not adapting fast enough, especially around turns, and the robot veering off course.
Now find some equation that maps the light sensor reading to the right motor speed. Notice the defining difference between (A) and (B) is the slope! That's why this is called a P-Controller. We adjust the motors (p)roportionally to the error we read in the light sensor.
Challenge Rules
This will be a double elimination tournament. Robots will go head-to-head on equal length tracks. The first robot to cross the finish line will be declared the winner for that round. A couple rules:1. Any robot design can be used; however, you are only allowed to use one light sensor.
2. If your robot leaves the track, the judge will signal the team and they are allowed to place the robot back on the track from the point of its departure.
example code:
Tracy
Ya