Ivy is released! Learn more
Pedro Pathing LogoPedro Pathing

Pedro Commands

Ivy includes built-in commands for controlling your robot's movement using Pedro Pathing. To use them, add the following static import:

import static com.pedropathing.ivy.pedro.PedroCommands.*;

All Pedro commands take a Follower as their first argument. Usually your Follower is one created from your Constants file's createFollower() method.

Follow

Makes the robot follow a PathChain. The command finishes when the follower is no longer busy (i.e. the path is complete).

Command goToBasket = follow(follower, basketPath);

You can optionally specify whether the robot should hold its position at the end of the path, and a maximum power between 0 and 1:

Command goToBasket = follow(follower, pickupCloseSpikemark, true);          // hold at end
Command goToBasket = follow(follower, pickupCloseSpikemark, 0.5);           // cap max power at half
Command goToBasket = follow(follower, pickupCloseSpikemark, true, 0.5);     // both

If you don't pass holdEnd, it defaults to your follower's automaticHoldEnd setting. If you don't pass maxPower, it defaults to the follower's current max power.

Hold

Makes the robot hold a position. The command finishes when the robot is within tolerance of the target (based on translational and heading error).

To hold the robot's current position:

Command stayHere = hold(follower);

To hold a specific pose:

Command holdAtBasket = hold(follower, new Pose(50, 30, Math.toRadians(90)));

You can also pass custom PathConstraints to control how tight the completion tolerance is:

Command preciseHold = hold(follower, targetPose, new PathConstraints(
    0.995,  // tValueConstraint
    100     // timeoutConstraint (ms)
));

Turn To

Makes the robot turn in place to a specified heading (in radians). The command finishes when the follower is no longer busy.

Command faceForward = turnTo(follower, Math.toRadians(0));
Command faceLeft = turnTo(follower, Math.toRadians(90));

As with hold, you can pass custom PathConstraints:

Command preciseTurn = turnTo(follower, Math.toRadians(180), customConstraints);

Composing Pedro Commands

Since Pedro commands are regular Ivy commands, you can compose them with everything else. For example:

Command auto = sequential(
    follow(follower, shootPreloads),
    Shooter.shoot(), // the shoot method here would be a command
    instant(() -> claw.open()),
    parallel(
        follow(follower, pickupCloseSpikemark),
        instant(() -> intake.activate())
    )
/* ... */
);

Last updated on