Enums, Lists, and Team Vocabulary
Use enums and collections to express robot states and groups of devices.
Use enums and collections to express robot states and groups of devices.
In this lesson, you will:
Enums give a fixed set of names to robot states. Lists let the team apply one rule to a group, like setting brake mode on every drive motor. Together they reduce magic values and duplicated setup code.
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.
Students should see an enum as team vocabulary. DOWN, INTAKE, SCORE, and SAFE are easier to discuss than 0.17, 0.42, and some boolean called ready. A list is a way to say all these motors share a setup rule.
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.
Start with a servo position enum, then use a method to move to that state. Next, create a list of motors and apply zero-power behavior in one loop. Keep raw numbers near the enum, not scattered through TeleOp.
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.
EnumsListsandTeamVocabulary.javaJava
enum ClawState {
OPEN(0.35),
CLOSED(0.08);
final double position;
ClawState(double position) { this.position = position; }
}
void updateClaw(ClawState state) {
clawServo.setPosition(state.position);
telemetry.addData("claw state", state);
}Enums fail when the names are vague or when raw numbers are still used elsewhere. Lists fail when one device needs different behavior but is silently included. Review group setup carefully.
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.
Check your understanding before moving on.
What is the FTC reason to learn enums, lists, and team vocabulary?
0 of 1 answered
Mark this lesson complete — “LinearOpMode Lifecycle” is up next.