Simple Autonomous
Build an autonomous routine with timers and safe stops.
Build an autonomous routine with timers and safe stops.
In this lesson, you will:
Each step should have one job: drive, turn, wait, move an arm, or stop. Small steps are easier to test and easier to fix at events.
A robot should never wait forever for a sensor or encoder. Even basic autonomous code should include timeouts and a final stop.
When autonomous misbehaves at an event, the first question is always: which step was it on? Printing the current step name means you can answer from the Driver Station screen instead of guessing from robot behavior.
TimedAuto.javaJava
waitForStart();
if (isStopRequested()) return;
runtime.reset();
while (opModeIsActive() && runtime.seconds() < 1.0) {
setDrivePower(0.25, 0.25);
telemetry.addLine("Step: drive forward");
telemetry.update();
}
setDrivePower(0, 0);
if (!opModeIsActive()) return;
sleep(300);
runtime.reset();
while (opModeIsActive() && runtime.seconds() < 0.5) {
setDrivePower(0.2, -0.2);
telemetry.addLine("Step: turn");
telemetry.update();
}
setDrivePower(0, 0);
telemetry.addLine("Step: complete");
telemetry.update();Check your understanding before moving on.
Why does every autonomous movement need a timeout?
What should the last action of an autonomous routine be?
0 of 2 answered
Mark this lesson complete — “Encoder Autonomous” is up next.