WestlakeLEARN
FTC · Java

FIRST Tech Challenge

FTC · Java

  • Subsystem Lifecycle
  • Enums and Finite State Machines

Enums and Finite State Machines

Name robot states and control transitions.

Module 6: Robot ArchitectureIntermediate

In this lesson, you will:

  1. 01Replace raw positions with enum states.
  2. 02Define valid transitions.
  3. 03Print current state.

Concept narrative

Enums give states names; finite state machines define how those names change. This prevents impossible combinations such as intake and deposit being true at the same time.

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

Drivers and programmers should share state vocabulary. If the robot is in HOVER, everyone should know what the arm, wrist, and claw are expected to do.

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

Create an enum with positions, write updateState, and add transition rules only when a mechanism needs sequencing. Print the state before tuning positions.

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.

MechanismState.javaJava

enum ArmState { INTAKE, HOVER, SCORE, SAFE }

void updateState(ArmState next) {
    state = next;
    telemetry.addData("arm state", state);
}

Common mistakes and debugging

If a state name is vague, drivers cannot help debug. If raw positions appear outside the enum, the state machine is incomplete. If transitions are implicit, match bugs become mysteries.

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

Refactor one mechanism to use enum states and document allowed transitions.

Checkpoint

  • State names are driver-readable.
  • Raw targets are centralized.
  • Invalid transitions are handled intentionally.

Reflection check

Check your understanding before moving on.

What is the most important habit in Enums and Finite State Machines?

0 of 1 answered

References

FIRST FTC DocsOfficial SDK, Robot Controller, and programming reference.Game Manual 0FTC community reference for programming, controls, and robot design.

Finished reading?

Mark this lesson complete — “Command-Based OpModes” is up next.

Subsystem LifecycleCommand-Based OpModes