Skip to lesson
Westlake RoboticsLearn
Vault

FIRST Tech Challenge

Loading progress…

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

Command-Based OpModes

Small reusable behaviors scheduled over time.

Command Patterns and Code OrganizationAdvanced

In this lesson, you will:

  • Explain command vs subsystem.
  • Compose sequential and parallel behavior.
  • Avoid 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.

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.

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.

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.

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

What distinguishes a team-defined CommandScheduler from an FTC SDK API?
Why compose ArmToScore and OpenClaw sequentially instead of scheduling both independently?

0 of 2 answered

References

FIRST FTC DocsOfficial SDK, Robot Controller, and programming reference.Game Manual 0FTC community reference for programming, controls, and robot design.
Loading lesson progress
Previous lessonEnums and Finite State MachinesNext lessonInterfaces, Packages, and Code Organization