WestlakeLEARN
FTC · Java

FIRST Tech Challenge

FTC · Java

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

Module 1: Java Foundations for FTCFoundations

In this lesson, you will:

  1. 01Explain enums, lists, and team vocabulary in FTC robot terms.
  2. 02Connect the Java idea to telemetry or hardware behavior.
  3. 03Write 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.

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

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.

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.

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

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.

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

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.

Reflection check

Check your understanding before moving on.

What is the FTC reason to learn enums, lists, and team vocabulary?

0 of 1 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.

Finished reading?

Mark this lesson complete — “LinearOpMode Lifecycle” is up next.

Methods, Classes, and HelpersLinearOpMode Lifecycle