Line Follower

advertisement
Line Follower
There are a number of methods which can be used to build a line following robot. In general there
are three different types of line followers:
1. Single light sensor model
2. Two light sensor model
3. Three ligth sensor model
Of these three models the most versatile, relatively reliable and easier to construct is the two light
sensor model. It further can follow more easily black lines which go any direction. Where the
single sensor models are either left or right turning favoring.
Line Following Learning Resources
Below are a number of PDF‘s with basic instructions on experimenting quickly with the various
line following methods as described in more detail on the accompanying web pages.




3 Minute Line Follower Robot
Single Sensor Line Follower Program
Two Sensor Line Follower Program
Light Sensor Calibration
Placement of Light Sensors
Where the light sensor is positioned makes a big diference in how well the robot follows an given
line. In general placing the light sensor ahead of the wheels (motors) allows the robot to react more
accurately to upcoming course (line) changes. You may want to experiment with the placement of
the sensors and the distance between the sensor and the driving wheels. Experiment with placing
the sensors behind the driving motors and observe the efects this has on the accuracy and fluency of
the robot as it tries to follow the line.
Two Sensor
In this scenario, two light sensors are positioned so that thet are on either side of the black line the
robot is intended to follow. By detecting which sensor changes from white to black, we know how
to turn back toward and onto the line. This robot is therefore able to follow any line making any
type of turns (left or right etc)
There are 4 possible states which can occur:
#1
L – Black R – White
Robot needs to make a right turn to get back
centered onto the line
#2
Both White
In this case the robot is perfectly centered above the
black line and can drive straight forward, without
corrective action.
Both Black
This is the case when the robot reaches an
intersecting other black line. This is a special case
and can be used to execute a special action.
#4
L – White R – Black
Robot needs to make a corrective action, in this case
it needs to make a left turn to turn back onto the
black line.
This can be expressed using the following flow-chart:
Note that in case of the Left and Right Sensor both
detecting black, no action is determined. We could
use it as a special condition, to for-example stop
driving, or keep driving straigth and in effect
ignoring the intersecting line.
Program Example
Things to note:
1. A Forever loop is used to repeatedly get
sensor readings and apply the appropriate
steering correction to the wheels, as fast as
possible. The loop will repeat several times
per second.
2. Inside the loop, we first set a logic variable
to ‗false‘ which is used to control the outer
loop, and is effeted when the special
condition occurs where both the left and
right sensor see black — corss an
intersecting black line.
3. We repeatedly check the Left light sensor
and then switch based it seeing more then
50% of light (none-black).
4. We then check the Right light sensor and
switch based on it seeing more then 50% of
light (none black) The turns are done by
stopping one wheel and turning only the
other wheel, using individual Motor blocks
for each motor. This is more consistent and
faster than using a single 2-motor Move
block with steering because the rotation
sensors don‘t interfere with the amount of
steering.
5. When the special condition occurs where
both the Right and Left sensor see black, a
the Logic Varibale is set to True. whne this
occures, the overall control loop is exited.
Motor block duration is set to Unlimited because we
just want to start moving that way then immediately
loop back and check the sensor again to see if we
need to change direction (Unlimited here means ―Go
this way until I tell you otherwise‖).
Advanced three Sensor model — PID control model
Want to make your robot follow a line? At slower speeds, the process is pretty simple – if the
sensors say it is going left, steer right and if going right, steer left. This process has its limitations
though, mainly when the speed is increased . This is when a PID controller starts to shine.
PID stands for Proportional, Integral, Derivative. A PID controller is a mathematically-based
routine that processes sensor data and uses it to control the direction (and/ or speed) of a robot to
keep it on course. Why does PID work better than our simple model described above? Let‘s talk
about how robot acts (or behaves) as it follows a line to see why.
Robot Behavior when following a line
Let‘s say our robot has 3 sensors, Left, Center and Right. When the Center sensor sees the line, the
robot is programmed to go straight. When the Left sensor sees the line, the robot is programmed to
turn right. When the Right sensor sees the line, the robot is programmed to turn left. This will
typically cause the robot the wobble back and forth over the line and if going too fast, it may lose
control and stop following the line.
This method only takes one behavior into consideration – is the robot centered over the line. To
improve performance, we should also take into consideration 2 more behaviors – how rapidly is the
robot moving from side to side and how long is it not centered over the line. These 3 behaviors are
called Proportional, Integral and Derivative in terms of a PID controller.
Download