WestlakeLEARN
FTC · Java

FIRST Tech Challenge

FTC · Java

  • Command-Based OpModes
  • Interfaces, Packages, and Code Organization

Command-Based OpModes

Small reusable behaviors scheduled over time.

Module 7: Command Patterns and Code OrganizationAdvanced

In this lesson, you will:

  1. 01Explain command vs subsystem.
  2. 02Compose sequential and parallel behavior.
  3. 03Avoid blocking commands.

Concept narrative

Commands request subsystem behavior. They are small units of robot action that can be triggered by TeleOp or composed into autonomous routines.

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

The scheduler is the heartbeat. Commands can only progress if run is called repeatedly, and commands should finish quickly enough to let other robot work continue.

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 InstantCommand-style state changes, then add a sequential group, then a command that waits for a condition. Reuse one command in both TeleOp and auto.

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.

CommandSnippet.javaJava

CommandScheduler.getInstance().run();
if (pressedScore) {
    scheduler.schedule(new SequentialCommandGroup(
        new ArmToScore(),
        new OpenClaw()
    ));
}

Common mistakes and debugging

If a command never finishes, inspect the finish condition. If parallel commands starve each other, remove blocking sleeps. If two commands fight, check subsystem ownership.

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

Make a claw command and an arm command, then combine them into a score sequence.

Checkpoint

  • Scheduler runs once per loop.
  • Commands are reusable.
  • No command blocks for long periods.

Reflection check

Check your understanding before moving on.

What is the most important habit in Command-Based OpModes?

0 of 1 answered

References

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 — “Interfaces, Packages, and Code Organization” is up next.

Enums and Finite State MachinesInterfaces, Packages, and Code Organization