Interface AutoStep


public interface AutoStep
One step of an autonomous routine: "drive 24 inches", "raise the lift", "wait 1 second".

A step BLOCKS on purpose: it runs from start to finish, then the next step starts. While a step waits, it must call ctx.loop() (or ctx.waitUntil/ctx.waitFor) so the mechanisms keep working and the routine can stop it when the match ends.

An interface with just one method can be written as a lambda: ctx -> { ... } is a small piece of code that the routine runs later, when its turn comes. ctx is the AutoContext the routine hands to it.


 // A custom step, as a lambda:
 AutoStep dropPiece = ctx -> {
     claw.open();
     ctx.waitFor(0.3);                            // keeps every mechanism updating
 };
 AutoStep liftUp = ctx -> {
     lift.goTo("HIGH");
     ctx.waitUntil(lift::isAtTarget, 2.0);        // done, or 2 s, or the match ends
 };
 

Mechanism helpers give you ready-made steps, e.g. lift.goToStep("HIGH"). Docs: docs/modules/auto.md, docs/guides/easy-autos.md

  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Does the step.
  • Method Details

    • run

      void run(AutoContext ctx)
      Does the step. Returns when it is finished, or as soon as ctx.isActive() turns false.