Having trouble with PathPlanner rotations

My team is running into a problem when we try to rotate in our paths. Some rotations will work fine, but others will rotate in the wrong direction, and sometimes rotate different amounts altogether.

We have an “auto” which consists of a path which makes the robot rotate 90 degrees counterclockwise, and another path that makes the robot rotate 90 degrees the other way (here is a screen recording of the path as displayed in PathPlanner).

Instead of doing this, the robot will rotate 90 degrees counterclockwise, then rotate 90 degrees counterclockwise AGAIN (here is a recording). In other words, the first path always works, and the second path always goes 90 degrees as intended, but in the wrong direction.

We tried running the same path, with the only difference being that the second rotation now rotates 45 degrees clockwise. The robot instead chose to rotate 135 degrees clockwise (here is a recording).

Other rotations are also unexpected. For instance, when we draw a path that makes the robot turn 180 degrees, it rotates 90 degrees clockwise THEN 90 degrees counterclockwise, ending in the same heading.
To fix this, we made a path that turns 90 degrees clockwise then another 90 degrees clockwise instead of just turning 180 degrees. This works half the time but fails more often.

Does anybody have any ideas on why this might be happening? My team is stumped.

For reference, here is our code.

@FreddyYu did you ever find a solution to this issue? My team is experiencing the same problem with PathPlanner.

We’ve had similar issues. First, verify that your odometry tracks rotations correctly and that everything is CCW. Then verify the positions on your vision system (photonvision transform3d and ll offsets are correct. I know you don’t use vision, but it could help other teams.) Then, verify everything in your callstack is using the correct, CCW angle. Do this by plotting all of them in glass. Can you also post the telemetry?

Can you take a look to see if your Rotation2D is correct or not? We had a problem where using Rotation2d.fromDegrees() would randomly change the rotation every time. In our case, we were using a navX so we should have done AHRS.getRotation2d() and it was working correctly after doing so.

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