Command-Based Framework

Command-Based Framework - Core Programming Concepts

The Command-Based Framework organizes robot code into three key components: Triggers (inputs), Subsystems (hardware), and Commands (actions). This structure provides clean separation of concerns and reliable robot behavior.

🎯 Key Concept: Command-based programming is the format in which you will write your code.

Triggers

Use BooleanSuppliers (True or False)

Link inputs to commands (e.g., press button to drive forward, or use sensor to run Command automatically). All buttons/triggers on a game controller are considered "Triggers".

Subsystems

Hardware components and control logic

(e.g., Drivetrain, Arm, or Flywheel). Motors and sensors are instantiated. Methods to pull data from sensors within the subsystem are defined.

Commands

Use Runnables (void functions)

Encapsulate robot actions (e.g., DriveForwardCommand, ShootBallCommand).

Progressive Implementation Path

Follow our step-by-step implementation guide to build a complete command-based robot system. Each pull request builds on the previous one, teaching core concepts progressively.

🚀 Implementation Sequence

1

Building Subsystems

Hardware instantiation, motor configuration, and basic control methods

2

Adding Commands

Command structure, lifecycle, and controller integration

3

PID Control

Precise position control with feedback and tuning

4

Motion Magic

Smooth profiled motion with acceleration control

5

Useful Functions

Safety features, diagnostics, and utility functions

📚 Official WPILib Command-Based Documentation

For comprehensive Command-Based Framework reference, advanced patterns, and complete API documentation:

📖 WPILib Command-Based Programming Guide