Skip to lesson
Westlake RoboticsLearn
Vault

FIRST Tech Challenge

Loading progress…

  • What an OpMode Does
  • Variables, Types, and Units
  • If Statements and Loop Flow
  • Methods, Classes, and Helpers
  • Enums, Lists, and Team Vocabulary

Enums, Lists, and Team Vocabulary

Use enums and collections to express robot states and groups of devices.

Java Foundations for FTCFoundations

In this lesson, you will:

  • Explain enums, lists, and team vocabulary in FTC robot terms.
  • Connect the Java idea to telemetry or hardware behavior.
  • Write a small test that proves the concept before using it in match code.

Concept narrative

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.

Robot mental model

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.

Implementation walkthrough

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.

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);
}

Common mistakes and debugging

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.

Practice

Define a two- or three-state enum for one mechanism and replace direct position writes in TeleOp with updateState calls.

Checkpoint

  • Enum names match driver vocabulary.
  • Raw positions are centralized.
  • Telemetry prints the state name.
  • 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 is ClawState.SCORE safer than passing 0.42 through an OpMode?
Before adding motors to one setup list, what must be true?

0 of 2 answered

References

Learn Java for FTCFTC-focused Java book and exercises by Alan G. Smith.FIRST FTC DocsOfficial SDK, Robot Controller, and programming reference.Game Manual 0FTC community reference for programming, controls, and robot design.
Loading lesson progress
Previous lessonMethods, Classes, and HelpersNext lessonLinearOpMode Lifecycle