EasyStack Docs

Commands Class

Esta página aún no está traducida. Se muestra la versión en inglés.

Commands is a class of one-line shortcuts. It creates any common command or group with a single import, so you do not need to remember the name of every class. Use it when you need one command, or a group made of simple pieces.

Java
import dev.easyfamily.EasyStack.Commands.Commands;

Every method returns an EasyCommand, so you can start it with schedule(), give it to a button, or put it inside a group.

#Single Commands

  • Commands.none(): does nothing and finishes at once. Useful as a placeholder.
  • Commands.once(action, subsystems...): does the action once.
  • Commands.loop(action, subsystems...): repeats the action on every loop until something stops it.
  • Commands.runFor(ms, action, subsystems...): repeats the action on every loop for a fixed time.
  • Commands.startEnd(onStart, onEnd, subsystems...): runs onStart when it begins and onEnd when it ends. Good for things that must be turned off, like an intake while a button is held.
  • Commands.waitMs(ms): waits for a time in milliseconds. It is called waitMs because Java already uses the name wait.
  • Commands.waitUntil(condition): waits until the condition is true.

#Groups

  • Commands.sequence(commands...): one after another.
  • Commands.parallel(commands...): all at the same time, until all are done.
  • Commands.race(commands...): all at the same time, until the first one is done. The others are stopped.
  • Commands.deadline(main, others...): all at the same time, until the main command is done. The others are stopped.

#Choosing

  • Commands.either(condition, ifTrue, ifFalse): picks one of two commands when it starts.

#Starting and Stopping Other Commands

  • Commands.schedule(commands...): starts other commands and continues at once, without waiting for them.
  • Commands.cancel(commands...): stops other commands.

#Examples

Run the intake while a button is held:

Java
driver.rightBumperButton().whileHeld(
        Commands.startEnd(() -> intake.on(), () -> intake.off(), intake));

Do two things at the same time, then wait a bit:

Java
Commands.sequence(
        Commands.parallel(
                Commands.once(() -> lift.up()),
                Commands.once(() -> claw.close())),
        Commands.waitMs(300),
        Commands.once(() -> claw.open())).schedule();

Choose by a sensor:

Java
Commands.either(
        () -> distance.getDistance(DistanceUnit.CM) < 10,
        Commands.once(() -> claw.close()),
        Commands.once(() -> claw.open())).schedule();

#Commands or Routine?

If you are writing a list of steps in order, a Routine is shorter and easier to read. Use the Commands class for single commands, for pieces you pass to then(...) and parallel(...), and for groups that do not fit a simple list.

Última actualización 2026-11-16

EasyStack - FTC Java library

This site records page views of visitors to understand how the documentation is used. Nothing is sold or shared with third parties.