Class PathAt

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

public final class PathAt extends Object
Something to start at a place ALONG a path, while the robot keeps driving: spin up the launcher 12 in before the end, start the intake halfway, stop it where part 2 of the path starts. Give them to a follow (or driveTo) step after the path (and its time limit, if any):

 s.follow("To the goal", TO_GOAL, 15,
          PathAt.fraction(0.5, "Intake on", robot.intake::in),         // halfway along the whole path
          PathAt.part(2, "Intake off", robot.intake::stop),            // where part 2 starts
          PathAt.inchesLeft(12, "Spin up", robot.launcher::spinUp),    // 12 in before the end
          PathAt.inchesLeft(4, Actions.scoreHigh(robot)));             // an action from your Actions.java
 
The part names (robot.intake, robot.launcher) and the action are your own.
  • Each one happens once, and the path goes on: like a run step, it STARTS things. An action keeps running after the step, like alongside.
  • They are checked every loop in the order you write them. Write them in the order they come along the path.
  • At the end of the path, the ones reached there happen (Pedro may stop a little short of the end, so "1 in left" still happens).
  • If the path ends early (timed out, STALLED, NO_ODOMETRY, cut short), the report says which did not happen: To the goal: STALLED, not fired: Spin up.
  • Mirrored for RED like the path: a distance along the path is the same on both sides, and near(double, double, double, java.lang.String, java.lang.Runnable)'s point is mirrored like driveTo's.

A mistake (a fraction of 2, a part 0) stops INIT with a message, not the match. Docs: docs/modules/pedro.md ("Do things along the path")

  • Method Details

    • inchesDone

      public static PathAt inchesDone(double inches, String label, Runnable command)
      When the robot has driven this far along the path.
      Parameters:
      inches - inches from the start of the path (0 = at once)
      label - a name for the report, e.g. "Intake on"
      command - what to do, e.g. robot.intake::in
    • inchesDone

      public static PathAt inchesDone(double inches, Action action)
      inchesDone(double, String, Runnable) with an action from Actions.java (it keeps running after the step).
    • inchesLeft

      public static PathAt inchesLeft(double inches, String label, Runnable command)
      When only this much of the path is left: inchesLeft(12, ...) = 12 in before the end.
      Parameters:
      inches - inches before the end of the path (the whole path, all its parts)
      label - a name for the report, e.g. "Spin up"
      command - what to do, e.g. () -> robot.launcher.spinUp()
    • inchesLeft

      public static PathAt inchesLeft(double inches, Action action)
      inchesLeft(double, String, Runnable) with an action from Actions.java.
    • fraction

      public static PathAt fraction(double fraction, String label, Runnable command)
      When this much of the WHOLE path is done (all its parts counted): 0.5 = halfway, 0.25 = a quarter of the way.
      Parameters:
      fraction - 0 (the start) to 1 (the end)
      label - a name for the report
      command - what to do
    • fraction

      public static PathAt fraction(double fraction, Action action)
      fraction(double, String, Runnable) with an action from Actions.java.
    • part

      public static PathAt part(int n, String label, Runnable command)
      When part n of a path made with then(...) starts (part 1 = the start). Pedro looks ahead: it starts steering along the next part a little before the robot gets to the join.
      Parameters:
      n - the part, counting from 1 (INIT stops if the path has fewer parts)
      label - a name for the report
      command - what to do
    • part

      public static PathAt part(int n, Action action)
      part(int, String, Runnable) with an action from Actions.java.
    • near

      public static PathAt near(double xIn, double yIn, double withinIn, String label, Runnable command)
      When the robot (its centre, from the odometry) comes within withinIn of a field point. The point is in the same numbers as driveTo, written for BLUE and mirrored for RED. If the robot never comes that close, it does not happen (the report says so).
      Parameters:
      xIn - inches right of the centre line
      yIn - inches from the centre toward the far wall
      withinIn - how close, inches (more than 0; the robot's own path may pass a few inches off)
      label - a name for the report
      command - what to do
    • near

      public static PathAt near(double xIn, double yIn, double withinIn, Action action)
      near(double, double, double, String, Runnable) with an action from Actions.java.
    • name

      public String name()
      The name shown in the report (the label, or the action's name).