Commands
A command is one action your robot does: spin a motor, wait half a second, close a claw. Commands let you describe what the robot should do, step by step, and EasyStack runs them for you. You do not write waiting loops, and your OpMode is never blocked.
#The Easy Way in 3 Steps
Step 1. Add the scheduler once, in initialize(). It is the part that runs your commands.
addComponents(new EasyCommandComponent());Step 2. Write what the robot does with a Routine. Read it from top to bottom, one step after the other.
Routine shoot = Routine.start()
.run(() -> shooter.spinUp())
.waitUntil(shooter::atSpeed)
.run(() -> intake.on())
.waitMs(500)
.run(() -> intake.off());Step 3. Start it, for example when a button is pressed.
driver.aButton().onPress(shoot.build());That is all you need to use commands. Everything below is for when you want more.
#Which Tool Should I Use?
- Routine: a list of steps in order. Start here. See the Routine tab.
- Commands class: one-line shortcuts to create a single command or a group, with only one import. See the Commands Class tab.
- Command classes: full control. Write your own commands, use subsystems and requirements. See Custom Commands, Group Commands, Utilities and Decorators.
- Triggers: start commands from buttons or sensors. See the
EasyTriggertab.
#How It Works
Commands only run while the scheduler runs. Every loop the scheduler gives each running command a little time, so many commands can run at once on one thread. This is called cooperative multitasking. A command must never wait inside a loop of its own: it does a little work and returns, and the scheduler calls it again.
A command has four stages:
initialize(): called once, when the command starts.execute(): called every loop while the command runs. This is where it does its main work.isFinished(): called every loop afterexecute(). Return true to finish.end(interrupted): called once when the command finishes, is cancelled or is interrupted. The value is true when it did not finish by itself.
Routine and the Commands class build these commands for you, so you only write them yourself for something very specific.
#Rules to Remember
- The scheduler must run: add an
EasyCommandComponent, or callscheduler.run()once per loop. - Times are in milliseconds: one second is 1000.
- One command per subsystem: two commands that need the same subsystem cannot run together. The newer one interrupts the older one.
- Nothing blocks: while a Routine waits, your
onUpdate()keeps running.
#Common Mistakes
- Nothing happens: you forgot the
EasyCommandComponent. - I pressed the button again and nothing happened: the routine was still running. A command that is already running is not started a second time. When it finishes, the next press starts it again from the first step.
- My wait is too short or too long: times are in milliseconds, so
waitMs(2)is almost nothing andwaitMs(2000)is two seconds.
Last updated 2026-11-16