Pathplanner paths spinning robot

Been trying to use pathplanner for some simple paths, but the robot starts to rotate halfway through the path. By the end it has done a 180 and even does a little wiggle at the end. Is it a problem with the path itself or something deeper?
Example path

Have you confirmed your gyro is measuring CCW+? My guess is your robot is getting a slight error in the gyro, the PID loop is trying to correct it, but because your coordinate system might be incorrect the robot tries to correct in the wrong direction, increasing the error, and it will keep moving farther away from 0 until it reaches a stable equilibrium as far away from 0 as it can reach before the circular range of angles you can be in forces it to stay at 180 degrees

I will double-check this.

1 Like

To add on, check this on every part! We had a ton of problems but took an hour to check every coordinate system possible confusion and fixed almost every problem. Some of them include:
Odometry signs correspond to what you would expect in path planner
If using swerve, wheel turns CCW+ when measuring encoder
Make sure gyro increments in correct direction and fits the [-180,180] range that path planner uses

1 Like

Our gyro wasn’t ccw+ so I inverted it, but now our telep field centric drive is wrong.
I inverted with the variable provided in constants

So then you would need to check the other parts of your code that use coordinate systems, since they all rely on each other to be correct to provide correct outputs. I.e. your swerve kinematics, signs when rotating the modules, etc. additionally, if all else fails, you can put a negative sign when you call your gyro inside your swerve drive command.

Check your module definitions are the modules defined as front left and front right actually right?

Check if you just need to invert your motors.

You say your field oriented in driver isn’t working but is it just you are reading the controller values backwards?

It was working before the inversion.
Now it works until you rotate the robot, then get wonky until you are back at 0 or 180.
I am tempted to change it back and try and inverse whats passed to pathplanner, but they seem to use the same calls.

Did you check the alliance flipping value isn’t causing the problem?

Can you invert what is used in the drive command after you call the method

Hey guys I know I’m late but has anyone solved this problem yet?