WestlakeLEARN
FTC / Java

First Tech Challenge

FTC / Java

01 · Java for FTC
  • OpMode Anatomy and Hello Robot
  • Variables, Math, and Decisions
  • Methods, Classes, and Robot Helpers
02 · FTC Hardware Essentials
  • Hardware Map and RobotHardware
  • Motors, Servos, and Sensors
  • IMU, Encoders, and Bulk Caching
03 · TeleOp and Mecanum
  • Robot-Centric Mecanum Drive
  • Field-Centric Driving
  • Driver Ergonomics and Safe TeleOp
04 · Subsystems and Commands1/3
  • Subsystem Lifecycle
  • Enums and Finite State Machines
  • Command-Based OpModes
05 · From Timed Steps to Actions
  • Timed and Encoder Autonomous
  • Autonomous State Machines
  • Actions and Sequencing
06 · PID and Feedforward
  • PID Basics
  • Feedforward and PIDF
  • Dashboard Tuning Workflow
07 · Motion Profiling
  • Motion Profile Concepts
  • Implementing a Profiled Mechanism
  • Testing Profiles and Failure Modes
08 · OpenCV and AprilTags
  • VisionPortal Camera Setup
  • OpenCV Color and Region Processors
  • AprilTags and Field Pose
09 · Setup and Tuning
  • Road Runner 1.0 Install and Drive Class
  • Feedforward Tuning
  • Localization and Validation
10 · Trajectories, Actions, and MeepMeep
  • Action Builder and Trajectories
  • MeepMeep Preview
  • Full Road Runner Autonomous
11 · Git, Debugging, and Competition Readiness
  • Git Workflow for FTC Teams
  • Telemetry-First Debugging
  • Competition Readiness Checklist
12 · Driver Control
  • Driver Control
13 · Autonomous Build
  • Simple Autonomous
14 · Debugging
  • Debugging with Telemetry

04 / Subsystems and Commands

Subsystem Lifecycle

Use read, periodic, write, and reset methods to organize mechanism code.

65 minIntermediateSubsystems and Commands

You will

  1. 01Explain what belongs in a subsystem.
  2. 02Separate sensor reads, state updates, and hardware writes.
  3. 03Use reset methods to return to known states.

Why Subsystem Lifecycle matters

This lesson is about making robot code scale. Architecture should reduce repeated decisions, not bury logic. Students should see why RobotHardware, subsystems, enums, state machines, and commands make the robot easier to test, reuse, and repair at an event.

Starting point

Subsystems own mechanisms

A subsystem should represent one mechanism or tightly related mechanism group. It stores the current target, reads sensors, calculates outputs, writes to hardware, and exposes simple commands to OpModes.

Lifecycle methods reduce chaos

The centerstage code uses a wrapper with read, periodic, write, and reset methods. That pattern makes it clear when data enters the subsystem, when decisions happen, and when outputs leave.

Build path

Introduce structure after students have felt the pain of duplication. Move one mechanism into a subsystem, one repeated behavior into a command, and one set of raw positions into named states. The final code should read more like robot intent and less like a wiring diagram.

For this specific lesson, students should first restate the goal in robot terms, then identify the value or behavior they expect to observe, then run the smallest test that proves the idea. The lesson should feel like a guided lab: predict, run, observe, explain, and only then extend.

WSubsystem.java · Java

public abstract class WSubsystem {
    public abstract void read();
    public abstract void periodic();
    public abstract void write();
    public abstract void reset();
}

public class LiftSubsystem extends WSubsystem {
    private int targetTicks;
    private int currentTicks;

    public void goToHigh() {
        targetTicks = 1800;
    }

    @Override public void read() {
        currentTicks = RobotHardware.getInstance().lift.getCurrentPosition();
    }

    @Override public void periodic() {
        telemetryError = targetTicks - currentTicks;
    }

    @Override public void write() {
        RobotHardware.getInstance().lift.setTargetPosition(targetTicks);
    }
}

Debugging and failure modes

Architecture fails when responsibilities are unclear. If hardware is written from several places, commands fight. If states are scattered across booleans, impossible combinations appear. If lifecycle methods run out of order, telemetry and behavior disagree. The debugging path should follow ownership: input, command, subsystem state, hardware write.

Practice

Convert one mechanism into a subsystem with read, periodic, write, and reset methods. Call those methods from your main loop.

Checks

  • The OpMode no longer contains raw mechanism math.
  • The subsystem has named target states.
  • Reset puts the mechanism into a known safe target.

Check your understanding

Module check

What is the main job of a subsystem?

0 of 1 answered

References

FIRST FTC DocsOfficial FTC SDK and robot programming documentation.Game Manual 0Community FTC programming, control, and robot design reference.

Finished reading?

Mark this lesson complete.

You'll move on to “Enums and Finite State Machines” next.

Driver Ergonomics and Safe TeleOpEnums and Finite State Machines