Skip to lesson
Westlake RoboticsLearn
Vault

FIRST Tech Challenge

Loading progress…

  • Subsystem Lifecycle
  • Enums and Finite State Machines

Enums and Finite State Machines

Name robot states and control transitions.

Robot ArchitectureIntermediate

In this lesson, you will:

  • Replace raw positions with enum states.
  • Define valid transitions.
  • Print 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.

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.

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.

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.

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.
  • 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.

Why use named mechanism states such as INTAKE, SCORE, and SAFE?
What should happen when a requested state is unsafe for the current mechanism condition?

0 of 2 answered

References

FIRST FTC DocsOfficial SDK, Robot Controller, and programming reference.Game Manual 0FTC community reference for programming, controls, and robot design.
Loading lesson progress
Previous lessonSubsystem LifecycleNext lessonCommand-Based OpModes