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.
The Command-Based Mental Model
Section titled “The Command-Based Mental Model”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 ]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
- WPILib Command-Based Programming Documentationdocs.wpilib.orgWPILib Standard
Lessons
Java Foundations for FRC Robotics
Master Java fundamentals, object encapsulation, private final hardware handles, lambdas, and type-safe WPILib Units before writing subsystem code.
Command Lifecycle & Subsystem Requirements
The CommandScheduler loop, subsystem requirement locking, and the initialize, execute, isFinished, and end lifecycle methods.
Triggers & Controller Bindings
Event-driven robot control using CommandXboxController, whileTrue, onTrue, toggleOnTrue, and sensor-based Triggers.