Encoder Autonomous
Use motor feedback for measured movement.
Use motor feedback for measured movement.
In this lesson, you will:
Encoder autonomous improves timed movement by measuring motor rotation. It still does not prove field position, but it gives code a feedback signal.
This lesson should be read as a robotics lesson first and a programming lesson second. The code matters because it lets the team create repeatable behavior under match pressure. Students should slow down long enough to name the inputs, outputs, assumptions, and safety limits before they touch the robot.
Encoders tell how far shafts turned, not whether the robot perfectly moved on the field. Wheel slip and collisions still matter.
A good mental model gives the team a shared language. When a driver, builder, and programmer can point to the same behavior and use the same words, debugging gets calmer and code review becomes useful instead of personal.
Reset or record starting ticks, compute a target, drive while error remains and timeout has not passed, then stop. Print current ticks and reason for exit.
Keep the implementation staged. First create the smallest version that compiles. Then add telemetry that proves it is running. Then connect one hardware device or one decision. Finally, repeat the test from a cold init so the team knows it was not a lucky hot reload.
EncoderAuto.javaJava
int start = leftMotor.getCurrentPosition();
int target = start + 900;
runtime.reset();
while (opModeIsActive() && runtime.seconds() < 2.0 && leftMotor.getCurrentPosition() < target) {
setDrivePower(0.25, 0.25);
}Wrong target signs, unreset encoders, and run-mode confusion are common. If ticks do not change, check wiring and mode before rewriting logic.
Use the five-value debugging habit: input, state, target, measurement, output. If one of those values is missing, add it before rewriting logic. The goal is to make the robot tell the truth about what it thinks is happening.
Check your understanding before moving on.
What is the most important habit in Encoder Autonomous?
0 of 1 answered
Mark this lesson complete — “Autonomous State Machines” is up next.