My team is using swerve drive with pathplanner for autonomous. While it goes roughly where it should, it often is slightly off in terms of distance and often goes at a slight angle even when it should go straight. What might be happening that makes this the case?
Code:
You may need to re-adjust the offsets for your Swerve Drive chassis. Does the robot drive straight in tele-op mode in robot-relative controls (no gyro)? Are all wheels aligned straight when driving forward? If not, these are signs that you may need to re-align your wheels and get a new offset.
Your P values for the X and Y controllers are doing nearly nothing to correct for error. You should try significantly increasing them, at least 10x.
I readjusted the offsets today and the angle problem remained. I used a straightedge to align the wheels so I think those should be okay too. I wasn’t able to test in tele-op. But I realized that the distance error is incredibly minor and the angle error is far larger.
Another thing that may have an impact is the fact that my team always tests on a carpet. We don’t want to ruin the floor so we use a carpet and weigh it down with chairs. This may impact the angle but I’m not sure to what extent.
What about the theta controller? The distance error is always a lot smaller than the angle error, so should I raise that too?
Try to isolate what might be causing angled driving. Put the robot up on blocks and drive straight. Observe the wheels - do they stay straight or do they veer? That may help separate software from mechanical problems such as bent mechanisms or mismatched motors.