Follow a line/fi: Difference between revisions
(Created page with "=== Anturit ===") |
(Created page with "Valoanturi on välttämätön. Joissain harjoitustehtävissä hyödynnetään kahta valoanturia.") |
||
Line 13: | Line 13: | ||
=== Anturit === | === Anturit === | ||
Valoanturi on välttämätön. Joissain harjoitustehtävissä hyödynnetään kahta valoanturia. | |||
=== Example Videos === | === Example Videos === |
Revision as of 22:26, 14 September 2020
<languages/>
Introduction
Viivanseurantaan on hyvin paljon erilaisia tapoja eli algoritmeja. Tässä näytämme kaksi yksinkertaista menetelmää, jotka kummatkin voidaan koodata usealla eri tavalla. Menetelmät ovat nimeltään zig zag ja verrannollinen viivanseuranta.
Viivan voit piirtää isolle paperille tai vetämällä esimerkiksi teipillä viivan lattiaan. Helpoin viiva algoritmeille on sileä (tasainen), mutta viivassa voi tietenkin olla myös teräviä käännöksiä. Nämä algoritmit eivät huomaa, jos viiva leikkaa itseään.
Robotti
Lähes mikä tahansa liikkuva robotti toimii.
Anturit
Valoanturi on välttämätön. Joissain harjoitustehtävissä hyödynnetään kahta valoanturia.
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
Zig Zag never drives straight. Either it turns to left or right. However, it can be made very fast, and reliable---of course depending on the line. The turning part is coded into if else block which is in the loop.

Proportional
The proportional code reads the reflected light intensity, and if it exactly 50 the robot drives forward. Otherwise it turns to left or right. There is a proportional constant to determine the speed of the turn.

Exercises
- Use the other side of the line to follow the line
- Make the robot to change the side of the line during the line following: Thus, after following the line e.g. 2 wheel rotations, use the other side of the line
- Make a robot with two color sensors, and use the information from the other sensor to stop the robot when the other sensor recognizes black line.
- Make a robot with two color sensors, and make the robot to follow a line that is in between the two sensors.
- Make a robot with two color sensors, and make the robot to follow first the line with left sensor, then after two wheel rotations use the other sensor to follow the line to the end.
This course is supported by Meet and Code. The course is made in collaboration with Robotiikka- ja tiedekasvatus ry.
