Package com.crossbotics.ftchelper.robot
Class PathAt
java.lang.Object
com.crossbotics.ftchelper.robot.PathAt
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
runstep, it STARTS things. An action keeps running after the step, likealongside. - 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 likedriveTo'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 Summary
Modifier and TypeMethodDescriptionstatic PathAtfraction(double, String, Runnable)with an action from Actions.java.static PathAtWhen this much of the WHOLE path is done (all its parts counted): 0.5 = halfway, 0.25 = a quarter of the way.static PathAtinchesDone(double inches, Action action) inchesDone(double, String, Runnable)with an action from Actions.java (it keeps running after the step).static PathAtinchesDone(double inches, String label, Runnable command) When the robot has driven this far along the path.static PathAtinchesLeft(double inches, Action action) inchesLeft(double, String, Runnable)with an action from Actions.java.static PathAtinchesLeft(double inches, String label, Runnable command) When only this much of the path is left:inchesLeft(12, ...)= 12 in before the end.name()The name shown in the report (the label, or the action's name).static PathAtnear(double, double, double, String, Runnable)with an action from Actions.java.static PathAtWhen the robot (its centre, from the odometry) comes withinwithinInof a field point.static PathAtpart(int, String, Runnable)with an action from Actions.java.static PathAtWhen partnof a path made withthen(...)starts (part 1 = the start).
-
Method Details
-
inchesDone
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
inchesDone(double, String, Runnable)with an action from Actions.java (it keeps running after the step). -
inchesLeft
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
inchesLeft(double, String, Runnable)with an action from Actions.java. -
fraction
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 reportcommand- what to do
-
fraction
fraction(double, String, Runnable)with an action from Actions.java. -
part
When partnof a path made withthen(...)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 reportcommand- what to do
-
part
part(int, String, Runnable)with an action from Actions.java. -
near
When the robot (its centre, from the odometry) comes withinwithinInof a field point. The point is in the same numbers asdriveTo, 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 lineyIn- inches from the centre toward the far wallwithinIn- how close, inches (more than 0; the robot's own path may pass a few inches off)label- a name for the reportcommand- what to do
-
near
near(double, double, double, String, Runnable)with an action from Actions.java. -
name
The name shown in the report (the label, or the action's name).
-