How to use gyroscope/fi
<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.
The gyroscope driving functions should be done as MyBlock so that they are easy to use at your own codes.
We show two different methods, (i) the robot drives straights, and (ii) the robot steers to a given angle.
Robot
Almost any robot will do, though these examples are done by using Verne/ Asimov 2.
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