Aligning to AMP using Pathplanner

I want to align to the AMP by either defining a pre-planned path and pathfinding to it, creating a path on-the-fly, or just pathfinding from the current robot pose to the amp (from point to point).

I’ve checked the docs, which say that you have no control over the heading for pathfinding between points, which is something I want.

But then, right below on the same page, there is a section on pathfinding to a pose, which involves heading. So which is it?

Also, does anyone recommend one method over another (pathfinding to a path vs pathfinding to a pose vs path on-the-fly by using bezier points from the final position and current pose.

Any help would be appreciated!

I believe the heading mentioned is not the robot’s rotation, but that controller line you have when creating a path that decides from which side to start the motion.

I wouldn’t use path planner. It’s pregenerated and you want to be able to get to the amp from anywhere. Use WPILibs TrajectoryGenerator for on the fly trajec generation directly from any possible robot pose to the amp, with the correct heading

PathPlanner’s on-the-fly paths do get generated, well, on-the-fly. Same for pathfinding.

2 Likes

I would definitely use path planner. We have had great results path planning to a specific pose from the robots current pose, and if you want it will automatically avoid field elements you cannot drive through or under.

Yeah I’m probably also going to path find to a pose.

Thanks for your help everyone!

You might find the new pathfindToPoseFlipped feature helpful as it will flip the pose based on alliance color (the regular one will not). This will prevent you from having to enter in the pose of both the red and the blue amps.

1 Like

Oh how do you use path planner to do OTF generation?

1 Like

PathPlannerLib’s AutoBuilder has a .pathFindToPose() method which can take in a target Pose2d as well as some constant path constraints

This returns a command that drives to the given (field relative) point.

PathPlanner also has a dedicated page on constructing a path on-the-fly from a series of poses here

More information on how to instantiate an AutoBuilder can be found here

1 Like

Also, if I’m using a limelight & odometry for the SwervePoseEstimator, should I align to the amp using just the april tag on the amp in 2d mode, or should my current estimated pose w PathPlanner’s pathfind to a pose to get to the amp?

Estimated pose for sure, the pose estimator is much more stable. You shouldn’t count on seeing the april tag + you can activate the command from further away.

1 Like

Ok thanks!

Thanks - we’ll look at that