Enums and Finite State Machines
Name robot states and control transitions.
Name robot states and control transitions.
In this lesson, you will:
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.
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.
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);
}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.
Refactor one mechanism to use enum states and document allowed transitions.
Check your understanding before moving on.
0 of 2 answered