PedroPathing is an FTC autonomous path-following library. Version 3 is a major rewrite, so use the 3.x API examples on this page only with a Pedro 3 project. Pedro still needs a tuned drivetrain and localizer before its paths can be reliable.

1. Install and prepare

The Pedro Quickstart is the recommended way to start a new project. For a manual install, the current Pedro documentation lists these dependencies in build.dependencies.gradle:

repositories {
    maven { url 'https://repo.dairy.foundation/releases/' }
}

dependencies {
    implementation 'com.pedropathing:revhub:3.0.2'
    implementation 'com.pedropathing:tuning:1.0.0'
}

Sync Gradle and copy the Pedro configuration package from the Quickstart into your TeamCode project. The generated Constants.create(hardwareMap) method must match your drivetrain and localization hardware.

2. Understand poses

A Pose is a field position and robot heading: x, y, and heading. Pedro uses its own field coordinate system. Use one consistent unit (normally inches), confirm the origin and alliance orientation in the official coordinate guide, and make the start pose match the robot's actual placement.

import com.pedropathing.api.PoseFactory;
import com.pedropathing.math.Pose;

private final PoseFactory poses = PoseFactory.degrees();
private final Pose startPose = poses.of(24, 24, 0);
private final Pose parkPose = poses.of(48, 48, 90);

PoseFactory.degrees() makes headings degrees. Use PoseFactory.radians() if your project uses radians instead; do not mix the two.

3. Create a path

Pedro 3 provides path helpers in Paths. A line connects two poses; the interpolation sets how the robot's heading changes along that path.

import com.pedropathing.paths.Path;
import static com.pedropathing.api.Paths.line;

private Path startToPark() {
    return line(startPose, parkPose).linear(startPose, parkPose);
}

For curved routes, use curve(start, control, end) and tune the control pose in the visualizer. Always test the path with the robot safely supported or at low speed before running it on the field.

4. Follow it in an autonomous OpMode

Pedro recommends Ivy to schedule path-following commands. Ivy is an additional library; install and configure it using the official Ivy documentation before using these imports.

import com.pedropathing.follower.Follower;
import com.pedropathing.ivy.Command;
import com.pedropathing.ivy.Scheduler;
import com.qualcomm.robotcore.eventloop.opmode.Autonomous;
import com.qualcomm.robotcore.eventloop.opmode.OpMode;
import org.firstinspires.ftc.teamcode.pedro.Constants;
import static com.pedropathing.ivy.Scheduler.schedule;
import static com.pedropathing.ivy.pedro.PedroCommands.follow;

@Autonomous(name = "Pedro 3 Path Test")
public class PedroPathTest extends OpMode {
    private Follower follower;

    @Override
    public void init() {
        Scheduler.reset();
        follower = Constants.create(hardwareMap);
        follower.setPose(startPose);
    }

    private Command autoRoutine() {
        return follow(follower, startToPark());
    }

    @Override
    public void start() {
        schedule(autoRoutine());
    }

    @Override
    public void loop() {
        follower.update();
        Scheduler.execute();
        telemetry.addData("X", follower.pose().x());
        telemetry.addData("Y", follower.pose().y());
        telemetry.addData("Mode", follower.mode());
        telemetry.addData("Path remaining", follower.remainingDistance());
        telemetry.update();
    }
}

This is a lesson fragment, not a drop-in class: include the pose fields and startToPark() method above in the same OpMode, and use the package path generated by your project for Constants.

5. Tune and debug

Practice

References

Back to training modules | Limelight training