Intent Command
Base class for intent-based commands that coordinate multiple subsystems.
Combines the clarity of "intent" with the power of WPILib Commands:
Clear semantic meaning (e.g., "ScoreCoralL2Intent")
Automatic requirements management via CommandScheduler
Composable with other commands (sequential, parallel, race, deadline)
Architecture
IntentCommands coordinate state transitions across multiple subsystems:
User Intent → IntentCommand → Transitions State(s) → State Machine Executes
↓ ↓ ↓ ↓
"Score L2" [ScoreCoralIntent] [Set states] [Run motors continuously]The command sets subsystem states, then finishes when the goal is achieved. Subsystem state machines continue running in periodic() to maintain behaviors.
Example Usage
class ScoreCoralIntent(val level: ElevatorState) : IntentCommand(Elevator, Outtake) {
override fun canExecute() = Outtake.hasCoralPiece
override fun onStart() {
Elevator.state = level
Outtake.state = OuttakeState.PREPARE_SCORE
}
override fun isIntentComplete() =
Elevator.isAtTarget() && Outtake.isReady()
}
// Usage
button.onTrue(ScoreCoralIntent(ElevatorState.L2))Parameters
Subsystems required by this intent (passed to Command constructor)
Properties
Functions
Check if prerequisites are met before this intent can execute.
Check if intent goal is achieved.
Schedule this command when the provided condition is true.