Line Robot - Basic lessons - Exercises - Turn by 90°
Another exercise useful for Robocup Rescue competitions.
Task: turn by exactly 90° left.
An example of invalid solution:
void RobotSoccer::loop() {
go(-50, 50);
delayMs(1000);
end();
}
The solution is invalid because the robot will not always rotate by 90°. It could be 70°, 105°, or some other value, depending of battery's voltage, obstacles on the floor, etc.
Solution
void RobotLine::loop() {
turn(-90);
end();
}
We admit that this is not fair because You didn't know that this function existed. But it does exist and You can turn robot by any angle using IMU (compass). If You are interested in the code, find this function in mrm-robot-line.cpp. The argument (-90) is number of degrees clockwise. To turn it anticlockwise, use negative values, like the mentioned -90.