Stop the robot after the third line/fi

From wikiluntti

<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.

Anturin lukemat, kun robotti ylittää mustia viivoja.

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.

The timer code.

Using the flip flop algorithm

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

The flip flop algorithm is easy to implement.

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.

Back to Meet and Code 2020 I: Ev3-G front page