Skip to content
learnFRC.org
programmingmodule90 min

Stage 02 - Code Foundations & Command Framework

Modern Java for robotics, the WPILib Units library, Command-Based architecture, and event-driven trigger bindings.

What you will learn

  • Bridge core Java programming principles into real-time robotics code.
  • Enforce hardware encapsulation and type-safe physics using the WPILib Units library.
  • Master the 4-phase Command lifecycle (initialize, execute, isFinished, end).
  • Bind controller buttons and sensor thresholds using event-driven Triggers.

Prerequisites:Stage 01 - Hardware & Bench Tuning (Phoenix Tuner X)

After verifying and tuning hardware on the bench in Phoenix Tuner X, the next step is structuring robot software to orchestrate mechanisms during teleoperated and autonomous match play.

Stage 2 establishes the programming conventions, strongly typed physical units, command lifecycle rules, and event-driven triggers that form the backbone of modern FRC robotics code.

To write clean robotics code, maintain this fundamental division of responsibility:

  • Subsystem = Capability: Defines what the robot is and what hardware it owns (for example, “Arm Subsystem owns CAN ID 12 and controls its angle”).
  • Command = Action: Defines what the robot does over time (for example, “Run intake until stator current spikes above 30A, then hold position”).
  • Trigger = Event: Connects user input or physical sensors to commands (for example, “When right bumper is pressed, run the intake command”).
[ Xbox Controller / Sensors ] --> [ Triggers ] --> [ CommandScheduler ] --> [ Subsystems ] --> [ Hardware ]
No while(true) Loops

In FRC software, never write a while(true) loop. The roboRIO executes on a strict 20 millisecond loop cycle managed by the CommandScheduler. Any blocking loop starves the motor safety watchdog and freezes the robot.

Verified Sources & Standards

Evergreen Standard Verified: Sep 25, 2026

Lessons