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.