Skip to lesson
Westlake RoboticsLearn
Vault

FIRST Tech Challenge

Loading progress…

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

Autonomous State Machines

Represent autonomous as named nonblocking steps.

Autonomous FoundationsAutonomous

In this lesson, you will:

  • Define enum states.
  • Advance by conditions.
  • Keep telemetry alive.

Concept narrative

A state machine turns autonomous into named steps that run over many loops. It avoids long blocking code and makes it obvious where the routine is stuck.

Robot mental model

The active state is the robot’s current promise. It should have one responsibility and one clear reason to transition.

Implementation walkthrough

Write the enum, initialize the first state, switch on state in the loop, and transition only when a condition or timeout is met.

AutoState.javaJava

switch (state) {
    case DRIVE:
        driveForward();
        if (atTarget() || runtime.seconds() > 2.0) state = AutoState.DROP;
        break;
    case DONE:
        stopDrive();
        break;
}

Common mistakes and debugging

If auto gets stuck, print state, timer, target, measurement, and transition condition. If a state does many jobs, split it.

Practice

Rewrite a timed auto as DRIVE, DROP, PARK, DONE states.

Checkpoint

  • Each state has one job.
  • DONE stops hardware.
  • Telemetry shows state.
  • The test record includes the setup, prediction, and observed result.
  • A teammate can repeat the check from the saved evidence without guessing.

Reflection check

Check your understanding before moving on.

What should an autonomous state do when its expected sensor condition never becomes true?
Why include a default or DONE state that stops drive output?

0 of 2 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.
Loading lesson progress
Previous lessonEncoder AutonomousNext lessonActions and Sequencing