Overview
The Command Framework helps you:- Organize robot code into reusable commands
- Manage subsystem resource allocation
- Schedule concurrent and sequential operations
- Create complex autonomous routines
- Bind commands to driver inputs
- Implement state machines and behaviors
Architecture
Core Concepts
Commands
Reusable robot actions and behaviors
Subsystems
Robot hardware groupings
Command Scheduler
Manages command execution
Command Composition
Combine commands into complex behaviors
Subsystems
Subsystems represent distinct robot mechanisms.Creating a Subsystem (Java)
Creating a Subsystem (C++)
Commands
Commands are actions that use subsystems.Command Lifecycle
Inline Commands (Java)
Command Factories (C++)
Built-in Command Types
InstantCommand
Runs once and finishes immediately.RunCommand
Runs continuously until interrupted.FunctionalCommand
Full control over command lifecycle.StartEndCommand
Runs one action at start, another at end.Command Composition
Sequential Commands
Run commands one after another.Parallel Commands
Run commands simultaneously.Parallel Race
Run until first command finishes.Parallel Deadline
Run until deadline command finishes.Command Decorators
Timeouts
Conditions
Repeat
Before/After Actions
Command Scheduler
Manages command execution.Running Commands
Periodic Execution
Default Commands
Button Bindings
Bind commands to controller buttons.Trigger Types
POV/D-Pad Bindings
Advanced Features
PID Commands
Profiled PID Commands
Proxy Commands
Defer command creation until execution.Deferred Commands
Select Commands
Choose command based on selector.Command Composition Patterns
Complex Auto Routine
Robot Container
Organize subsystems and commands.Source Code
View the full source code on GitHub:Related Documentation
WPILibJ
Java robot API
WPILibC
C++ robot API
WPIMath
Controllers and trajectories