Evolving Autonomous OpModes - Dutton-Christian-Robotics/Learning-to-Code GitHub Wiki
Autonomous OpModes involve the robot controlling itself without human input. However, there are still "levels" of how the robot functions on its own, and there are clear ways to make the robot function in more intelligent ways.
Simple Autonomous
Actions are controlled by time. Because of this, the autonomous operation is very simplistic—even unintelligent. It is not "fault tolerant" because lots of things can disrupt a pre-determined time length. That means that a time-based OpMode can also be less precise than you might want—such as when trying to turn.
These OpModes essentially tell the robot to do something, wait for a predetermined length of time, and then do something else.
Smarter Autonomous
A better autonomous mode allows the robot to make decisions. The question is: what information drives those decisions?
- Internal Sensors. The Expansion Hub includes a set of sensors called the "inertial measurement unit", or IMU. One kind of information the IMU can provide is orientation of the robot—how much it's rotated along any of its three axes. This can be particularly helpful for turning the robot.
- External Sensors. A number of types of sensors can be added to the robot and connected to an Expansion or Control Hub. The standard types of sensors include color/light sensors and distance sensors.
- Encoders. Technically, encoders are a type of external sensor. While it's possible to have actual separate encoders (often referred to as encoder or odometer pods), the most common type of encoders are those that are built in to motors (though not all motors have them). An encoder allows you to know how much a motor has turned—which, along with information about the size of the wheels, allows you to know how far the robot has moved. This in turn allows motors to be controlled by telling them to move a certain distance instead of simply turning them on.