What Autonomous Is and How It Runs
Learn what happens in the 30-second Autonomous period, which sensors help a robot find its way, and how an autonomous OpMode moves from INIT to STOP.
In this lesson you will
- Describe the Autonomous period and where it sits in a match
- Explain why a simple, reliable routine beats an ambitious, unreliable one
- Identify common sensors used in autonomous and what each one measures
- Write a minimal
@AutonomousOpMode that follows the INIT, start, run and stop lifecycle
Lesson
Every FIRST Tech Challenge match begins with the Autonomous period: 30 seconds in which robots move only on code that the team wrote before the match. Nobody touches the gamepads. After a short transition (8 seconds), the 2-minute Driver-Controlled (TeleOp) period starts, and its final part is usually called the endgame.
Why autonomous matters
- In many seasons, tasks completed during Autonomous are worth extra points compared with doing the same task later.
- A good autonomous routine can leave your robot in a useful position for the start of Driver-Controlled.
- Autonomous is the clearest test of your engineering: the robot has to sense, decide and move with no human help.
- Your alliance partner depends on you. Two robots with predictable paths are far less likely to collide.
Here is the most important idea of this week: reliability beats ambition. A short routine that works every single time is worth more than a long one that works only sometimes. Start small, such as driving off the start line and parking, and add steps only when the earlier steps are dependable. Talk to your alliance partner before each match about where both robots will go; that is Gracious Professionalism and Coopertition in action.
How a robot knows where it is
During Autonomous there is no driver watching, so the robot needs sensors to measure what it is doing. These are the most common ones on FTC robots:
| Sensor | What it measures | Typical autonomous use |
|---|---|---|
| Motor encoder | How far the motor shaft has rotated (in ticks) | Driving a set distance, moving an arm to a position |
| IMU (inside the Control Hub) | How much the robot has rotated | Turning to an exact heading, driving straight |
| Distance sensor | Distance to a nearby object or wall | Stopping a set distance from a wall |
| Color sensor | Color and brightness of a surface | Detecting tape lines or a game element's color |
| Touch sensor / limit switch | Whether something is pressed | Knowing a lift has reached the bottom |
| Webcam | Images for vision processing | Finding game elements or field markers |
This week focuses on encoders and the IMU, because almost every robot already has them and together they are enough for a solid basic routine.
The life of an autonomous OpMode
- 1INITThe driver selects your OpMode and presses INIT. Your code maps hardware, sets motor directions, resets encoders and prepares the IMU. The robot must not move yet.
- 2Wait for start
waitForStart()pauses your code until the driver presses START when the match begins. - 3RunYour code performs its moves one after another. Every loop should check
opModeIsActive()so the robot stops when asked. - 4StopThe OpMode ends when your code finishes, when the driver presses STOP, or when the Autonomous timer runs out. Always set motor power to 0 at the end.
1package org.firstinspires.ftc.teamcode;
2
3import com.qualcomm.robotcore.eventloop.opmode.Autonomous;
4import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
5import com.qualcomm.robotcore.hardware.DcMotor;
6import com.qualcomm.robotcore.util.ElapsedTime;
7
8@Autonomous(name = "Timed Drive Test", group = "Auto")
9public class TimedDriveTest extends LinearOpMode {
10 @Override
11 public void runOpMode() {
12 // INIT: runs after the driver presses INIT
13 DcMotor leftDrive = hardwareMap.get(DcMotor.class, "left_drive");
14 DcMotor rightDrive = hardwareMap.get(DcMotor.class, "right_drive");
15 leftDrive.setDirection(DcMotor.Direction.REVERSE);
16 ElapsedTime timer = new ElapsedTime();
17
18 telemetry.addData("Status", "Initialized, waiting for START");
19 telemetry.update();
20 waitForStart();
21
22 // RUN: drive forward for 1.5 seconds
23 timer.reset();
24 leftDrive.setPower(0.4);
25 rightDrive.setPower(0.4);
26 while (opModeIsActive() && timer.seconds() < 1.5) {
27 telemetry.addData("Time", "%.2f s", timer.seconds());
28 telemetry.update();
29 }
30
31 // STOP: always cut power at the end
32 leftDrive.setPower(0);
33 rightDrive.setPower(0);
34 }
35}
Key terms
- Autonomous period
- The first 30 seconds of a match, when robots run only on pre-written code with no driver input.
- OpMode
- A program that runs on the robot and is selected from the Driver Station, either TeleOp or Autonomous.
- `@Autonomous`
- An annotation that makes an OpMode appear in the Driver Station's autonomous list.
- `ElapsedTime`
- An FTC SDK timer class that measures how many seconds have passed since it was created or reset.
- Sensor
- A device that measures something about the robot or its surroundings so the code can react to it.
Practical exercise
Run your first autonomous and see why timers are unreliable
- 1Create the
TimedDriveTestOpMode and make sure the motor names match your robot configuration exactly. - 2Mark a start line on the floor with painter's tape and line up the back of the robot with it.
- 3Run the OpMode 5 times with the same battery and measure how far the robot travelled each time.
- 4Swap to a different (more or less charged) battery and run it 5 more times.
- 5Compare the two sets of distances and write down what changed and why you think it changed.
Knowledge check
Answer every question, then check your answers.