Pedro 3 has been released!
Pedro Pathing LogoPedro Pathing

Following a Path

How to follow a path with Ivy

Now that we have a path, we can make the robot follow it.

If you need help creating Poses, see Creating a Pose. If you need help creating a path, see Creating a Path.

A path can be followed directly with the Follower or by using Ivy.

Following a Path

Ivy provides a follow() command that lets path following be used like any other Ivy command.

The advantage of this is that you don't have to manually check if the path has finished before running more paths or commands.

Ivy does not come included by default, so make sure it is installed before using this method.

Add the imports (after installing Ivy):

import com.pedropathing.ivy.Scheduler;

import static com.pedropathing.ivy.Scheduler.schedule;
import static com.pedropathing.ivy.pedro.PedroCommands.follow;

Reset the scheduler inside init():

@Override
public void init() {
    Scheduler.reset();

    follower = Constants.create(hardwareMap);
    follower.setPose(startPose);
}

Then schedule the path when the OpMode starts:

@Override
public void start() {
    schedule(follow(follower, park()));
    // using the same park path from the last page
}

Both the follower and scheduler need to be updated:

@Override
public void loop() {
    follower.update();
    Scheduler.execute();
}

The Ivy follow() command finishes when the follower is no longer busy.

Tip

Ivy is useful when you want to combine paths with other robot commands. See the Ivy documentation for more information.

Using other command libraries

We strongly recommend using Ivy for its simplicity. Creating a custom follow command takes time and can introduce bugs. If you are new to Pedro Pathing and command frameworks, stick with Ivy. We also recommend using Pedro Pathing with a command framework rather than a manual state machine.

Next Step

We now know how to create and follow a path.

Next, we'll use these pieces to build a larger autonomous routine.

Continue to Autonomous Usage.

Last updated on