Class Steps

java.lang.Object
com.crossbotics.ftchelper.robot.Steps

public final class Steps extends Object
The steps of one autonomous, read top to bottom (see Auto). Each method adds a step and hands the list back, so they chain:

 s.start("Back wall, 2nd tile from the left, facing the field", 0)
  .menuYesNo("Score", true)
  .run("Hold the piece", robot.claw::close)
  .move("Leave the wall", 4, 0, 0.4)
  .onlyIf("Score")
      .run("Lift up", () -> robot.lift.goTo("high"))       // rises during the next moves
      .move("Drive to the goal", 24, 0, 0.6)
      .turn("Face the goal", 45, 0.5)                      // mirrored for RED
      .waitUntil("Lift at the top", robot.lift::isAtTarget, 2.0)
      .run("Drop", robot.claw::open)
  .end()
  .parkWithSeconds(4)
  .move("Park", 20, 90, 0.7);
 

Moves and turns: directions in degrees, clockwise from forward for moves (0 forward, 90 right), counterclockwise + for turns; written for BLUE and mirrored for RED. Distances in inches, powers 0 to 1. Each move or turn waits until it is done; run starts something and goes on at once (the mechanisms keep moving during the next steps).

The list is read in INIT (to learn the menu, the start position and the park time: no step runs then), again in INIT each time the drivers change a menu line (so a start(...) or parkWithSeconds(...) inside an onlyIf follows the choice), and once after START. So write only steps here, no other code with side effects. Docs: docs/modules/robot.md (section "Autos")

  • Method Details

    • start

      public Steps start(String whereToPlace, double headingDeg)
      Where to place the robot (shown in INIT) and which way it faces, degrees from "straight away from your driver", counterclockwise + (TeleOp's field-centric forward uses it).
    • start

      public Steps start(String whereToPlace, double xIn, double yIn, double headingDeg)
      Where to place the robot: the note for the drive team (shown in INIT), and the spot as seen from your drivers' wall, written for BLUE: xIn inches to the right of the field's centre line, yIn from the centre toward the far wall (negative = your half), heading 0 = facing away from you, counterclockwise +. RED uses it like the routes: mirrored left-right, or (with mirrorForRed() false, a field turned half a turn like BIOBUZZ) the same numbers from the red wall. The simulator puts the robot there.
      
       s.start("Against our wall, 2nd tile from the left, facing the field", -36, -63, 0)
       
    • isYes

      public boolean isYes(String label)
      True if the yes/no choice is "yes".
    • choice

      public String choice(String label)
      The option chosen for this label.
    • onlyIf

      public Steps onlyIf(String yesNoLabel)
      The steps up to end() run only if the yes/no choice is "yes".
    • onlyIf

      public Steps onlyIf(String label, String option)
      The steps up to end() run only if this option was chosen.
    • end

      public Steps end()
      Ends the latest onlyIf(java.lang.String).
    • move

      public Steps move(String label, double inches, double directionDeg, double maxPower)
      Drives a distance in a direction (clockwise from forward: 0 forward, 90 right, 180 back). Waits until done.
    • driveTo

      public Steps driveTo(String label, double xIn, double yIn, double headingDeg, double maxPower)
      Drives to a point on the field, using the odometry, and turns to a heading at the same time (mecanum). Seen from your drivers' wall, written for BLUE like the start spot: xIn inches right of the centre line, yIn inches from the centre toward the far wall, heading 0 = facing away, counterclockwise +. Waits until it is there (within 1 inch).

      Needs an odometry(...) line in Robot.java, and Tunables.Odometry.checked = true on a real robot (the Odometry Tuner); until then the step is skipped and the report says why.

    • driveTo

      public Steps driveTo(String label, double xIn, double yIn, double headingDeg, double maxPower, PathAt... along)
      driveTo(String, double, double, double, double) that also starts things on the way: PathAt.inchesLeft(12, ...), PathAt.fraction(0.5, ...), PathAt.near(...). The "path" is the straight line from where the robot is when the step starts to the point. (PathAt.part(n) needs a path with parts: only part(1) works here.)
    • driveTo

      public Steps driveTo(String label, double xIn, double yIn, double headingDeg, double maxPower, double toleranceIn)
      driveTo(String, double, double, double, double) with your own "close enough", inches.
    • driveTo

      public Steps driveTo(String label, double xIn, double yIn, double headingDeg, double maxPower, double toleranceIn, PathAt... along)
    • follow

      public Steps follow(String label, Object path)
      Follows a path with the robot's path follower (Robot.java's follower(...) line, e.g. Pedro Pathing through the "pedro" module), and waits until it is at the end. The path is written for BLUE like everything else: on RED with mirroring on, the follower mirrors it. At most 10 s. Like driveTo, it is skipped until Tunables.Odometry.checked = true (not in the simulator).
      Parameters:
      path - the path (for Pedro: PedroPath.line(...) or a Pedro Path)
    • follow

      public Steps follow(String label, Object path, PathAt... along)
      follow(String, Object) that also starts things ALONG the path, while the robot keeps driving. Each happens once:
      
       s.follow("To the goal", TO_GOAL,
                PathAt.fraction(0.5, "Intake on", robot.intake::in),     // halfway along the whole path
                PathAt.inchesLeft(12, "Spin up", robot.launcher::spinUp));   // 12 in before the end
       
      If the path ends early, the report says which did not happen. See PathAt.
    • follow

      public Steps follow(String label, Object path, double timeoutSec)
      follow(String, Object) with your own time limit, seconds.
    • follow

      public Steps follow(String label, Object path, double timeoutSec, PathAt... along)
      follow(String, Object, PathAt...) with your own time limit, seconds.
    • turn

      public Steps turn(String label, double degrees, double maxPower)
      Turns by an angle (counterclockwise +). Waits until done.
    • turnTo

      public Steps turnTo(String label, double headingDeg, double maxPower)
      Turns to a heading (0 = the way it faced at the start, counterclockwise +). Waits until done.
    • run

      public Steps run(String label, Runnable command)
      Runs a command now and goes on at once (e.g. () -> robot.lift.goTo("high")).
    • waitSeconds

      public Steps waitSeconds(String label, double seconds)
      Waits this long (the mechanisms keep working).
    • waitUntil

      public Steps waitUntil(String label, BooleanSupplier condition, double timeoutSec)
      Waits until something is true, at most timeoutSec (the report says if it timed out).
    • action

      public Steps action(Action action, double timeoutSec)
      Runs an action from Actions.java and waits until it is done (at most timeoutSec).
    • action

      public Steps action(Action action)
      action(Action, double) with up to 10 seconds.
    • alongside

      public Steps alongside(Action action)
      Starts an action and goes on at once: it runs during the next steps.
    • step

      public Steps step(String label, AutoStep step)
      Any other step (a mechanism's step, or your own: see AutoStep).
    • parkWithSeconds

      public Steps parkWithSeconds(double seconds)
      The steps after this are PARK steps, and they get the last seconds of autonomous: when only that many seconds are left, the step running before it stops at once and the rest before it are skipped; the park steps always run. The report says which were cut short or skipped. Docs: docs/modules/robot.md, "Keep time to park".
      Parameters:
      seconds - how long the park steps take, plus a little (from a timed run)