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)
Subsystems
Hardware components and control logic
Commands
Use Runnables (void functions)
The Big Picture: How It All Fits Together
How Command-Based Programming Works
Triggers
Controller buttons, sensors, or custom conditions
"When button A is pressed..."
Commands
Actions the robot performs
"...run the 'Raise Arm' command"
Subsystems
Robot mechanisms (arm, shooter, etc.)
"...which controls the Arm subsystem's motors"
Motors & Sensors
Physical robot hardware
"...to physically move the arm up"
Sensors provide feedback: Position, velocity, and status information flows back up to help Commands make decisions
Real Example: Raising an Arm
1. Trigger: Driver presses button A
2. Command: "RaiseArm" command starts running
3. Subsystem: Arm subsystem receives target position
4. Hardware: Motor spins, encoder measures position
5. Feedback: Encoder reports "target reached!" → Command ends
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
Building Subsystems
Hardware instantiation, motor configuration, and basic control methods
Adding Commands
Command structure and creation methods
Triggers
User input binding and advanced command patterns
PID Control
Precise position control with feedback and tuning
Motion Magic
Smooth profiled motion with acceleration control
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