Skip to content
IncredibotsAcademy
Incredibots playbook

PedroPathing Setup

Introduction to PedroPathing and initializing the Follower inside a CommandOpMode.

20 minintermediate

By the end you can

  • Understand what PedroPathing is.
  • Learn where to find the official tuning documentation.
  • Initialize the Follower in a Command-Based Autonomous.

Once your odometry hardware is physically installed and wired, you need software to translate those spinning wheels into movement on the field.

Our team uses PedroPathing.

What is PedroPathing?

PedroPathing is an incredibly fast, highly accurate path follower built specifically for FTC. It allows you to draw Bezier curves and splines on a virtual field, and it will automatically calculate exactly how much power to send to your Mecanum wheels to follow that path perfectly.

It handles acceleration, deceleration, and heading correction dynamically. If your robot is bumped off course, PedroPathing will instantly recalculate and drive the robot back onto the path!

Tuning PedroPathing

[!CAUTION] You cannot write autonomous paths until your robot is tuned! If you skip tuning, the robot will drive erratically and crash.

Before you can use PedroPathing in your code, you must tune it to your specific robot's weight, motors, and odometry setup. The tuning process involves running several pre-made OpModes (like ForwardVelocityTuner and TurnTuner) and adjusting variables in your Constants.java file.

Because PedroPathing is updated frequently, you should always use the official documentation for the installation and tuning process: Official PedroPathing Tuning Guide

Make sure to select the correct Localizer (e.g., goBILDA Pinpoint) in the docs!

Initializing PedroPathing in FTCLib

Once your robot is fully tuned, we can start writing our Autonomous OpMode.

Because we use FTCLib's Command-Based architecture, we don't write our logic in a standard LinearOpMode. Instead, we use a CommandOpMode.

In PedroPathing, the core object that handles all movement is called the Follower. We need to initialize this Follower when the OpMode starts, and we must constantly tell it to update itself in our main loop.

Here is the basic shell of our Autonomous OpMode:

package org.firstinspires.ftc.teamcode.opmodes.auto;
 
import com.arcrobotics.ftclib.command.CommandOpMode;
import com.pedropathing.follower.Follower;
import com.qualcomm.robotcore.eventloop.opmode.Autonomous;
 
import org.firstinspires.ftc.teamcode.Incredibot;
import org.firstinspires.ftc.teamcode.pedroPathing.Constants;
 
@Autonomous(name = "Basic Auto", group = "Autonomous")
public class BasicAuto extends CommandOpMode {
    
    // 1. Declare our Robot and Follower
    private Incredibot robot;
    private Follower follower;
 
    @Override
    public void initialize() {
        // Initialize our hardware subsystem
        robot = new Incredibot(hardwareMap, telemetry);
        robot.initialize(Incredibot.OpModeType.AUTO, null, null);
        
        // 2. Initialize the PedroPathing Follower
        // We use a helper method from our Constants file
        follower = Constants.createFollower(this.hardwareMap);
 
        // Tell PedroPathing where the robot is starting on the field
        // (We'll cover Poses in a later lesson!)
        // follower.setStartingPose(new Pose(0, 0, 0)); 
    }
 
    @Override
    public void run() {
        // 3. CommandOpMode MUST call super.run() to update the FTCLib Command Scheduler!
        super.run();
        
        // 4. We MUST call follower.update() every single loop so PedroPathing 
        // can recalculate the math based on the new odometry readings.
        follower.update();
        
        // Optional: Send the current position to telemetry for debugging
        telemetry.addData("X", follower.getPose().getX());
        telemetry.addData("Y", follower.getPose().getY());
        telemetry.update();
    }
}

The Golden Rules

  1. Never forget super.run(). Without it, your FTCLib Commands (like your intake or shooter) will never execute.
  2. Never forget follower.update(). Without it, PedroPathing is blind and will not send any power to the drive wheels!

Check Your Understanding

Check yourself

Why must we call follower.update() inside the run() loop?