Utilities
#3. Utilities
Ready-made commands and helpers for common robot tasks, grouped by purpose.
#Waiting Commands
WaitCommand(ms): Waits a fixed time.
WaitUntilCommand(cond): Waits until the condition is true.
WaitUntilStableCommand(cond, ms): Waits until the condition stays true continuously for ms. Useful for noisy sensors.
#Selection
The choice is made when the command starts, not while it runs.
ConditionalCommand(onTrue, onFalse, cond): Picks one of two commands.
SelectCommand<K>(map, selector): Picks by key (for example an enum). If the key is missing, runs a NoOpCommand. Requirements are computed in the constructor.
ToggleCommand(first, second): Alternates between the two each time it starts. The first run uses first.
DeferredCommand(supplier, subsystems...): Builds the command at start time. Subsystems are declared up front; if the built command needs others, it throws IllegalArgumentException.
Repetition
Usually reached through the repeatedly() and repeat(n) decorators.
RepeatCommand(cmd[, times]): Repeats N times, or forever when times is omitted.
RepeatUntilCommand(cmd, cond): Repeats until the condition is true.
Control and motion
AxisCommand(axis, deadband, output, subsystems...): Reads an axis, applies a deadband and rescales so the output starts at 0 right after the dead zone. Sends 0.0 on end.
ClosedLoopCommand(controller, measurement, setpoint, output, ...): Closed-loop control. Three constructors: with a BooleanSupplier finish condition, with a numeric tolerance, or without a condition (never finishes). Sends 0.0 on end.
MecanumDriveCommand(forward, strafe, turn, output, ...): Robot-centric mecanum drive. Normalizes the four powers and delivers them as frontLeft, frontRight, backLeft, backRight. Document which direction a positive turn means on your robot.
RampCommand(from, to, ms, output, ...): Linear interpolation from from to to over ms. For servo sweeps and power ramps.
TrapezoidProfileCommand(start, goal, maxVel, maxAccel, output, ...): Delivers desired position and velocity every loop until the goal is reached. start and goal are read once, at start.
TelemetryCommand(telemetry, caption, supplier[, update]): Shows a value on telemetry every loop. With update = true it calls telemetry.update(); use that only if your OpMode does not already.
#Basic Commands
InstantCommand(Runnable, subsystems...): Runs the action once and finishes. The no-argument constructor does nothing.
RunCommand(Runnable, subsystems...): Runs the action every loop and never finishes by itself.
StartEndCommand(onStart, onEnd, subsystems...): Runs onStart at the beginning and onEnd when it ends. It runs until it is cancelled or interrupted.
FunctionalCommand(onInit, onExecute, onEnd, isFinished, subsystems...): A complete command written with lambdas. onEnd receives true when the command was interrupted.
NoOpCommand(): Finishes immediately. Useful as a placeholder.
RunForCommand(Runnable, ms, subsystems...): Runs the action every loop for a fixed time.
PulseCommand(on, off, ms, subsystems...): Runs on, waits the time, then runs off.
#Scheduling Commands
ScheduleCommand(commands...): Schedules other commands without waiting for them, then finishes.
CancelCommand(commands...): Cancels the given commands, then finishes.
#Beginner Shortcut
Just starting? A Routine writes the same sequence as a simple list of steps, with no classes to remember. See the Routine tab at the beginning of Commands.
Last updated 2026-11-16