| name | pedro-pathing |
| description | Helps write autonomous and teleop code using Pedro Pathing library. Use when creating paths, building autonomous routines, setting up path following, working with Follower, PathChain, BezierLine, or heading interpolation. |
| license | MIT |
| compatibility | Claude Code, Codex CLI, VS Code Copilot, Cursor |
| metadata | {"author":"ncssm-robotics","version":"1.1.0","category":"library"} |
Pedro Pathing
Pedro Pathing is a path follower using Bezier curves for smooth autonomous navigation.
Quick Start
Autonomous OpMode Structure
@Autonomous(name = "My Auto")
public class MyAuto extends OpMode {
private Follower follower;
private Timer pathTimer;
private int pathState;
private final Pose startPose = new Pose(7, 6.75, Math.toRadians(0));
private final Pose targetPose = new Pose(24, 48, Math.toRadians(90));
@Override
public void init() {
pathTimer = new Timer();
follower = Constants.createFollower(hardwareMap);
buildPaths();
follower.setStartingPose(startPose);
}
@Override
public void loop() {
follower.update();
autonomousPathUpdate();
telemetry.update();
}
}
Building Paths
Path straightPath = new Path(new BezierLine(startPose, endPose));
straightPath.setLinearHeadingInterpolation(startPose.getHeading(), endPose.getHeading());
PathChain myChain = follower.pathBuilder()
.addPath(new BezierLine(startPose, endPose))
.setLinearHeadingInterpolation(startPose.getHeading(), endPose.getHeading())
.build();
Following Paths
follower.followPath(myPath);
follower.followPath(myChain, true);
State Machine Pattern
public void autonomousPathUpdate() {
switch (pathState) {
case 0:
follower.followPath(firstPath);
setPathState(1);
break;
case 1:
if (!follower.isBusy()) {
follower.followPath(nextPath, true);
setPathState(2);
}
break;
}
}
public void setPathState(int state) {
pathState = state;
pathTimer.resetTimer();
}
TeleOp with Pedro
@Override
public void loop() {
follower.update();
follower.setTeleOpMovementVectors(
-gamepad1.left_stick_y,
-gamepad1.left_stick_x,
-gamepad1.right_stick_x,
true
);
}
Key Concepts
- Pose: Position (x, y) + heading in radians. Field is 144x144 inches, origin bottom-left
- BezierLine: Straight path between two points
- BezierCurve: Curved path with control points (minimum 3 points)
- PathChain: Multiple path segments as one unit
- Follower: Main controller - call
update() every loop cycle
Transition Conditions
Check when path is complete:
!follower.isBusy() - Path finished
pathTimer.getElapsedTimeSeconds() > 1.5 - Time elapsed
follower.getPose().getX() > 36 - Position threshold
Anti-Patterns
Don't: Forget to call update()
@Override
public void loop() {
autonomousPathUpdate();
}
@Override
public void loop() {
follower.update();
autonomousPathUpdate();
}
Don't: Forget to set starting pose
@Override
public void init() {
follower = Constants.createFollower(hardwareMap);
buildPaths();
}
@Override
public void init() {
follower = Constants.createFollower(hardwareMap);
follower.setStartingPose(startPose);
buildPaths();
}
Don't: Use holdEnd when you don't need it
follower.followPath(path1, true);
follower.followPath(path2, true);
follower.followPath(path1);
follower.followPath(path2, true);
Don't: Use degrees for heading
Pose target = new Pose(24, 48, 90);
Pose target = new Pose(24, 48, Math.toRadians(90));
Reference Documentation