I spent some time today playing with the Gyro Sensor. There seemed to be a lot of issues with it last weekend as I was training a group of teachers. Though I don’t doubt any of the problems they had (I was there! I saw it!), I got perfect results every time I tried to use it.
DRIFT – Gyro sensors suffer from drift. Perhaps a more saaavy engineer could describe it properly, but for me drift means the gyro sensor will start registering numbers even when it is not moving at all. The way to account for this is to constantly unplug and replug the gyro sensor in when using it. I did that each time I used it in the following experiments, always using Port View to make sure it read like this:
1. The first program I tried was from Robot Educator. It has you use the Gyro sensor in the Change Angle configuration. Robot turns to the right, and stops after an increase of 45, the drives straight. Here’s what the program looks like:
And here’s the video:
2. Next I tried the same program but with an increase of 90 (right angle).
3. After the change in angle worked, I tried using the gyro sensor in the compare angle configuration. This first time I again turned to the right until the sensor sensed an angle greater than 45.
4. Similar to last time I kept everything the same but changed the compare to > 90.
5. Now I tried left turns because this is what caused so many problems at the training. First up is left turn change in angle decrease of 45. Decrease because the numbers get negative as you turn to the left.
6. Same, but with decrease of 90. Forgot to get a screen shot of this one.
7. Wanted to use the compare angle configuration, but made a mistake. I programmed turn left, stop when gyro sensor sense and angle greater than -45. Can you guess what happened?
Yep, zero is greater than -45 so the robot stopped turning immediately (faster than you can see) and went straight.
8. Corrected previous example, changed to less than -45.
9. And finally I went with compare angle, less than -90.
Fortunately the gyro sensor worked fine in my tests. Unfortunately I couldn’t repeat the mistakes that my students made during training last weekend.