Stop the robot after the third line/fi: Difference between revisions
(Created page with "Ajastimella robotti saadaan kulkemaan mustan viivan yli, jonka jälkeen etsitään seuraavaa mustaa viivaa. Kolmannen viivan jälkeen pysähdytään. Se kannattaa laittaa silm...") |
(Created page with "==== Flip-flop-algoritmi ====") |
||
Line 37: | Line 37: | ||
==== | ==== Flip-flop-algoritmi ==== | ||
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. | 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. |
Revision as of 20:22, 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.
Teoriaa
Alla on kerrottu kaksi erilaista menetelmää. Koska valoanturi lukee kentän valoisuutta koko ajan, ja anturin virkistystaajuus on suuri, niin anturin ylittäessä mustaa viivaa anturi saa paljon lähes nolla-arvoja, eli mustaa. Katso kuva.

Kalibroitu anturi saa arvon (lähes) 100, kun se on valkoisella ja arvoja, jotka ovat lähellä nollaa (0), kun anturi on mustalla.
Ajatin / kiertokulma
Ajastimella robotti saadaan kulkemaan mustan viivan yli, jonka jälkeen etsitään seuraavaa mustaa viivaa. Kolmannen viivan jälkeen pysähdytään. Se kannattaa laittaa silmukkaan, eli jos sinun tarvitsee käyttää samaa koodinpätkää uudestaan, laita se silmukkaan (tai tee siitä funktio).
Flip-flop-algoritmi
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.
