WestlakeLEARN
FTC · Java

FIRST Tech Challenge

FTC · Java

  • Simple Autonomous
  • Encoder Autonomous
  • Autonomous State Machines
  • Actions and Sequencing
  • Build a Vision-Selected Autonomous

Encoder Autonomous

Use motor feedback for measured movement.

Module 8: Autonomous FoundationsAutonomous

In this lesson, you will:

  1. 01Reset/read encoders.
  2. 02Move toward target ticks.
  3. 03Use timeout and stop reason.

Concept narrative

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.

Robot mental model

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.

Implementation walkthrough

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);
}

Common mistakes and debugging

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.

Practice

Drive to a target tick count with a timeout and report whether the target or timeout ended the step.

Checkpoint

  • Ticks move in expected direction.
  • Timeout works.
  • Exit reason is visible.

Reflection check

Check your understanding before moving on.

What is the most important habit in Encoder Autonomous?

0 of 1 answered

References

FIRST FTC DocsOfficial SDK, Robot Controller, and programming reference.Learn Java for FTCFTC-focused Java book and exercises by Alan G. Smith.Game Manual 0FTC community reference for programming, controls, and robot design.

Finished reading?

Mark this lesson complete — “Autonomous State Machines” is up next.

Simple AutonomousAutonomous State Machines