-
Notifications
You must be signed in to change notification settings - Fork 43
Gyro Challenges
The gyro challenges focuses on moving accurately. Imperfections in the wheel, floor, motors, weight balance, etc. means that a real robot will never drive perfectly straight without some means to align itself. Similarly, the GearsBot will not drive perfectly straight without help (...especially at higher speed where the tires tends to slip). If a line is available for the robot to follow, that would be best. When there are no lines available, the gyro can help the robot maintain an accurate heading.
This challenge simply requires your robot to run straight until the end. You might be able to make it with just a "move" command at low speed, but with the end point 10 meters away and only a little over a centimetre clearance on each side, a gyro will enable you to move faster and more accurately.
The approach for using a gyro is very similar to that of a single sensor line follower, and any techniques used for a single sensor line follower (eg. 2 states, 3 states, proportional) will work here as well. A simple example (3 states) would be to check the gyro reading, and either go straight or turn slightly to the left or right depending on the values.
# Pseudo code. Don't copy this.
IF gyro > 0; THEN
TURN_LEFT()
ELSE IF gyro < 0; THEN
TURN_RIGHT()
ELSE IF gyro == 0; THEN
GO_STRAIGHT()
END IF
Besides travelling straight, your gyro can also help you make precise turns. In this challenge, create a function that use the gyro to help your robot go straight (...use the code from the previous challenge), and another function that uses the gyro to help your robot make an exact 90 degrees turn. Example...
START_TURN()
WHILE gyro < 90; DO
NOTHING
DONE
STOP_TURN()
In this challenge, the direction of the path is randomized. Use the ultrasonic sensor to detect the position of the object at the end of the path. From that, you can determine the direction to turn to and drive down the path without falling off.
WARNING: The ultrasonic sensor reads in a cone.
Python References