EasyStack Docs

Custom Commands

Most robots never need this page. Use a Routine or the Commands class first. Write your own command only when you need something very specific, or when you want to reuse the same behavior in many places.

#EasyCommandBase

Extend EasyCommandBase and fill in the four stages. It already stores the requirements for you.

Java
public class SpinToSpeed extends EasyCommandBase {
    private final Shooter shooter;
    private final double rpm;

    public SpinToSpeed(Shooter shooter, double rpm) {
        this.shooter = shooter;
        this.rpm = rpm;
        addRequirements(shooter);
    }

    public void initialize() {
        shooter.setTargetRpm(rpm);
    }

    public void execute() {
    }

    public boolean isFinished() {
        return shooter.isAtTargetRpm();
    }

    public void end(boolean interrupted) {
        if (interrupted) {
            shooter.stop();
        }
    }
}
  • addRequirements(subsystems...): tells the scheduler which subsystems the command uses. Two commands that need the same subsystem cannot run together.
  • getRequirements(): returns the requirements. You rarely call it yourself.

Use your command like any other one:

Java
driver.aButton().onPress(new SpinToSpeed(shooter, 3000));
Routine.start().then(new SpinToSpeed(shooter, 3000)).waitMs(500).schedule();

#CommandGroupBase

The base class of SequentialCommandGroup, ParallelCommandGroup, ParallelRaceGroup and ParallelDeadlineGroup. You only need it to write a new kind of group.

  • getCommands(): a read-only list of the commands inside the group.
  • Same command twice: adding the same command object twice to a group throws an IllegalArgumentException.
  • Shared subsystems: commands that run in parallel cannot share a subsystem. The group throws an IllegalArgumentException if they do.

#Tips

  • Do not wait inside a command: never use sleep or a loop that waits. Return from execute() and let the scheduler call it again.
  • Clean up in end(): the value of interrupted tells you if the command was stopped before it finished. Stop motors there.
  • Reuse is safe: a command can run many times. Put everything that must start fresh inside initialize().

Last updated 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.