Pathplanner on-the-fly generation problems

With our robot, we have been trying to use pathplanner’s on the fly path generation to move in a simple vector to a point with known heading and rotation. The translation always gets from point a to point b within a 15% tolerance or so. However, the rotation is very strange. We have been telling it to move one meter in the X and Y directions, a 0 degree heading and no change in rotation. Most times, it works with minimal error, but occasionally it flips around while driving and ends up being off anywhere from 30 degrees to 180. We don’t know what makes it do that, but we believe the wheel rotation before following a path has something to do with it. Our code can be found here and I will be happy to provide any clarification needed.

1 Like

I’m not sure if I’m looking at the right thing in the code, but it looks like this might not be true. I see you trying to drive a path from the current pose to current position + 1M in the X and Y directions but a hardcoded 0 for the rotation. If you start the path with a non-zero rotation then it will want to rotate back to 0.

Also, setting the starting heading to your current rotation could cause some issues as well. Since if your current rotation is away from the target point then you’re gonna end up with a weird path. GUI example:


That is the correct thing that you are looking at. With the hardcoded 0 for the rotation that is intentional as we want to be square with the grid as we score. For the weird path due to using the current rotation as heading I think that is the issue. I don’t know what to set the heading to though.

1 Like

If you’re going to start it while stationary, you could do something like (targetTranslation - currentPose.Translation()).Angle()

Or, if you won’t be stationary, the PathPoint class has some static methods to create a path point for you based on current pose and chassis speeds.

1 Like

In this case, what would targetTranslation be and how does current_pose.Translation().Angle() differ from the navx angle?

Target translation is just where you want to go. So from your earlier example, current translation + 1 meter in X and Y.

The angle here would be the angle the Translation2d make with the origin. So, if you subtract the current pose from the target and then get the angle, it will set the heading to point to the next point.

Thanks for the suggestion, I’ll try this today when I have the bot

Is the heading of these paths the way your robot starts its path? Or is there a better way to define it?

Heading is direction of travel. So for a PathPoint, the heading will be the direction that the robot moves on the field while crossing the waypoint. This can be very different from your rotation.

We tested this fix and it doesn’t always go to the desired angle, but if we chain a few paths together it always follows the first path. This is an improvement over before this fix was implemented (it didn’t always match the first path). However, it still moves to an inconsistent rotation.

How do you independently define heading AND rotation at a waypoint in code?

PathPoint(translation2d, rotation2dheading, rotation2dHolonomic)

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.