Stop the robot after the third line/fi: Difference between revisions
(Created page with "=== Esimerkkivideot ===") |
(Created page with "Video on vain flip-flop-algoritmista.") |
||
Line 20: | Line 20: | ||
=== Esimerkkivideot === | === Esimerkkivideot === | ||
Video on vain flip-flop-algoritmista. | |||
<youtube>hHpo12qUhgc</youtube> | <youtube>hHpo12qUhgc</youtube> |
Revision as of 20:16, 15 September 2020
<languages/>
Johdanto
Miten saat robotin pysähtymään sen ylitettyä kolmannen viivan, tai n:nnen viivan? Tämä ongelma pitää ratkaista usein FIRST LEGO Leaguessa (FLL) tai Rescue (Pelastus) -kisoissa. Ongelma liittyy siihen, että anturi lukee kenttää koko ajan, jolloin yksinkertaisimmat ratkaisut eivät toimi.

Tässä ohjeessa on kaksi erilaista ratkaisua: (i) käyttäen ajastinta tai moottorin kiertokulmaa viivojen ylittämiseen, ja (ii) käyttäen flip-flip-algoritmia viivojen laskemiseen. Flip-flop-algoritmi toimii hyvin myös eripaksuisilla viivoilla.
Robotti
Lähes kaikki robotit toimivat. Esimerkeissä on Asimov 2/ Verne -robotti.
Anturit
Yksi värianturi riittää.
Esimerkkivideot
Video on vain flip-flop-algoritmista.
Theory
The two different methods are described below. The color sensor reads the reflected light intensity continuously, but the reading frequency is rather large. Thus, during passing the black line, the sensor reads hundreds of close to zero, or black, values. See, the image.

The calibrated color sensor reads about 100 at white, and while passing the black line the sensor values are about 0.
Using the timer/ rotation angle
By using the timer we can drive past the black line, and again look for the next black line. After finding the third one, we stop. This can be done in a loop, also. Usually, if you need to repeat the code, use a loop instead of copying the same script again.
Using flip flop circuit
The idea of the flip flop is that first we flip the state to black, and then after finding white we flop the state back to white. Note that the sensor continuously measures the reflectance.
Example Code
The example codes with two different algorithms are shown.
Using the timer
The timer based code is rather reliable and works perfectly even on difficult environments. The timer can be replaced by the rotation angle.

Using the flip flop algorithm
The flip flop algorithm is simple and reliable, if the ground floor is easy enough.

Exercises
- How fast can you make the robot to pass exactly three lines? Measure the time, and the extra passage (slippage), which the root makes after passing the last line.
- Make the robot work with two sensors, and assign other sensor to follow a line, and the other to stop after to stop the robot after 3rd line. See the image.
- Use the line follower algorithm with other sensor, and the other sensor is used to stop after three perpendicular black lines.
This course is supported by Meet and Code. The course is made in collaboration with Robotiikka- ja tiedekasvatus ry.
