Follow a line: Difference between revisions
No edit summary |
No edit summary |
||
Line 5: | Line 5: | ||
There a multiple different methods (algorithms) to follow a line. We show two simplest methods (which can be coded with a huge variety), also [[Viivanseuraaja zigzag ev3-g |''zig zag'' linefollower]] and [[Viivanseuraaja verrannollinen ev3-g | | There a multiple different methods (algorithms) to follow a line. We show two simplest methods (which can be coded with a huge variety), also [[Viivanseuraaja zigzag ev3-g |''zig zag'' linefollower]] and [[Viivanseuraaja verrannollinen ev3-g | | ||
proportional line follower]]. See the linked pages for more references. | proportional line follower]]. See the linked pages for more references. The line can be drawn on a huge paper, or made by using black (or colored) tape. The easiest line is smooth, but it might contain very sharp turns. However, the line should not cut itself. | ||
=== Robot === | === Robot === | ||
Line 52: | Line 52: | ||
<math>s(c) = k(c-50)</math> | <math>s(c) = k(c-50)</math> | ||
which allows to test different steering coefficients <math>k</math>. | which allows to test different steering coefficients <math>k</math>. This is easy to implement in Ev3-G programming language. | ||
[[File:LinefollowerProp.png|thumb]] | |||
=== Example Code === | |||
==== Zig Zag ==== | |||
=== | ==== Proportional ==== | ||
=== Exercises === | === Exercises === |
Revision as of 00:03, 5 September 2020
<languages/> <translate>
Introduction
There a multiple different methods (algorithms) to follow a line. We show two simplest methods (which can be coded with a huge variety), also zig zag linefollower and proportional line follower. See the linked pages for more references. The line can be drawn on a huge paper, or made by using black (or colored) tape. The easiest line is smooth, but it might contain very sharp turns. However, the line should not cut itself.
Robot
Any robot (with tires or treads, perhaps walking robots too) will work.
Sensors
One light sensor or color sensor is needed.
Example Videos
Theory
These algorithms follow the border of the line, not the line.
Calibration
The color sensor should be calibrated, either in the program using black and light reflectances, or by calibrating the values from the sensor. See the linked page for more information.
Zig Zag
Zig zag algorithm turns to right if sees white, and to left if the sensor is on the black. Or vice versa. The algorithm is easy to program using only one if block. The speed and turning value need to be considered and adjusted.
Proportional
The proportional line follower steers according to the value read from the color sensor. The sensor is assumed to be calibrated, so that at value the robot will go straight. Define a steering function
.
It is clearly seen, that
Does | ||
---|---|---|
0 | -100 | Steer left |
50 | 0 | Go straight |
100 | 100 | Steer right |
The coefficient is which makes the robot steer rapidly. You might wish to have smaller or larger steering effect depending on the path. The steering function can be generalized easily to
which allows to test different steering coefficients . This is easy to implement in Ev3-G programming language.

Example Code
Zig Zag
Proportional
Exercises
This course is supported by Meet and Code. The course is made in collaboration with Robotiikka- ja tiedekasvatus ry.

</translate>