How to use gyroscope/fi: Difference between revisions
(Created page with "=== Robotti ===") |
(Created page with "Lähes kaikki robotit toimivat, mutta nämä esimerkit on tehty Verne/ Asimov 2-robotilla.") |
||
Line 11: | Line 11: | ||
=== Robotti === | === Robotti === | ||
Lähes kaikki robotit toimivat, mutta nämä esimerkit on tehty Verne/ Asimov 2-robotilla. | |||
=== Sensors === | === Sensors === |
Revision as of 20:40, 15 September 2020
<languages/>
Johdanto
Gyroskooppi on iso apu navigoinnissa. Gyroskooppi on kuten kompassi, eli se antaa suuntakulman suhteessa gyroskoopin resettiin. Gyroskooppia voidaan hyödyntää oikean kääntökulman saamiseksi tai tiettyyn kulmaan ajamiseen. Tässä esitetyt gyroskooppikoodit ovat verrannollisia, mutta ne voidaan implementoida myös esimerkiksi PID-algoritmilla.
Gyroskooppikoodit kannattaa kirjoittaa MyBlock-funktioiksi, jotta voit käyttää niitä uusiksi seuraavissa koodeissasi.
Tässä esitetään kaksi erilaista menetelmää: (i) algoritmi, jolla robotti ajaa suoraan ja (ii) koodi, jolla robotti kääntyy tiettyyn kulmaan.
Robotti
Lähes kaikki robotit toimivat, mutta nämä esimerkit on tehty Verne/ Asimov 2-robotilla.
Sensors
The gyroscope sensor is used.
Example Videos
The two different methods are shown.
Theory
The limitations of gyroscope sensor should be known. E.g. the magnetic field affects the sensor values. Also, the sensor should be exactly still while starting the sensor. Otherwise, it might start drifting. If the sensor starts drifting, the easiest method to make it work properly is to unplug and plug the sensor again. Usually it works on the first replugging.
Example Code
The first example code explains the resetting, and how to use proportional algorithm to drive straight. The second code employs the proportional algorithm to follow a given compass direction.


Exercises
- Make the robot to always turn the shorter distance.
- Make the robot to always turn the longer distance.
- Use the Modulo operator to fix the number of turns the robot makes during the drive.
- Make a MyBlock that drives, and turns the robot as LEGOs steering block, but while using the gyro sensor.
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