IntentCommand

abstract class IntentCommand(requirements: Subsystem) : 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

requirements

Subsystems required by this intent (passed to Command constructor)

Constructors

Link copied to clipboard
constructor(vararg requirements: Subsystem)

Properties

Link copied to clipboard
open val interruptionBehavior: Command.InterruptionBehavior?
Link copied to clipboard
override val isFinished: Boolean
Link copied to clipboard
Link copied to clipboard
open var name: String?
Link copied to clipboard
open val requirements: Set<Subsystem?>?
Link copied to clipboard
open var subsystem: String?

Functions

Link copied to clipboard
fun addRequirements(vararg requirements: Subsystem?)
fun addRequirements(requirements: Collection<Subsystem?>?)
Link copied to clipboard
open fun alongWith(vararg parallel: Command?): ParallelCommandGroup?
Link copied to clipboard
open fun andThen(vararg next: Command?): SequentialCommandGroup?
open fun andThen(toRun: Runnable?, vararg requirements: Subsystem?): SequentialCommandGroup?
Link copied to clipboard
open fun asProxy(): ProxyCommand?
Link copied to clipboard
open fun beforeStarting(before: Command?): SequentialCommandGroup?
open fun beforeStarting(toRun: Runnable?, vararg requirements: Subsystem?): SequentialCommandGroup?
Link copied to clipboard
open fun cancel()
Link copied to clipboard
open fun canExecute(): Boolean

Check if prerequisites are met before this intent can execute.

Link copied to clipboard
open fun deadlineFor(vararg parallel: Command?): ParallelDeadlineGroup?
Link copied to clipboard
open fun deadlineWith(vararg parallel: Command?): ParallelDeadlineGroup?
Link copied to clipboard
override fun end(interrupted: Boolean)
Link copied to clipboard
override fun execute()
Link copied to clipboard
open fun finallyDo(end: BooleanConsumer?): WrapperCommand?
open fun finallyDo(end: Runnable?): WrapperCommand?
Link copied to clipboard
open fun handleInterrupt(handler: Runnable?): WrapperCommand?
Link copied to clipboard
open fun hasRequirement(requirement: Subsystem?): Boolean
Link copied to clipboard
open fun ignoringDisable(doesRunWhenDisabled: Boolean): WrapperCommand?
Link copied to clipboard
override fun initialize()
Link copied to clipboard
open fun initSendable(builder: SendableBuilder?)
Link copied to clipboard
operator fun Command.invoke()

Operator invoke implementation for Command.

Link copied to clipboard
override fun isFinished(): Boolean
Link copied to clipboard
abstract fun isIntentComplete(): Boolean

Check if intent goal is achieved.

Link copied to clipboard
open fun onExecute()

Optional: Update during execution.

Link copied to clipboard
open fun onFinish(interrupted: Boolean)

Cleanup/safety when interrupted or finished.

Link copied to clipboard
open fun onlyIf(condition: BooleanSupplier?): ConditionalCommand?
Link copied to clipboard
open fun onlyWhile(condition: BooleanSupplier?): ParallelRaceGroup?
Link copied to clipboard
abstract fun onStart()

Configure subsystem states when intent starts.

Link copied to clipboard
open fun raceWith(vararg parallel: Command?): ParallelRaceGroup?
Link copied to clipboard
open fun repeatedly(): RepeatCommand?
Link copied to clipboard
Link copied to clipboard
open fun schedule()
Link copied to clipboard
fun Command.scheduleIf(condition: Boolean)

Schedule this command when the provided condition is true.

Link copied to clipboard
open fun unless(condition: BooleanSupplier?): ConditionalCommand?
Link copied to clipboard
open fun until(condition: BooleanSupplier?): ParallelRaceGroup?
Link copied to clipboard
open fun withDeadline(deadline: Command?): ParallelDeadlineGroup?
Link copied to clipboard
open fun withInterruptBehavior(interruptBehavior: Command.InterruptionBehavior?): WrapperCommand?
Link copied to clipboard
open fun withName(name: String?): WrapperCommand?
Link copied to clipboard
open fun withTimeout(time: Time?): ParallelRaceGroup?
open fun withTimeout(seconds: Double): ParallelRaceGroup?