Swerve not following pathplanner trajectories accurately

My code for following trajectories works, so I don’t think this is a code issue, but my robot is wildly inconsistent when it comes to following paths. It follows the general path, but can be off by up to a foot when it reaches its destination. How can I fix this?

The first thing I’d ask is if your robot can handle the trajectory you’re asking it to follow. What I mean by that is if your velocity and acceleration constraint are reasonable given your robots gearing and weight because that could cause your robot to fall behind the trajectory and lead to inaccuracies. You could try and go to the extreme and set them low to like 1 m/s and 1 m/s^2 and see what the robot does then.

You also want to confirm that your odometry is working correctly. Something as trivial as using the wheel radius vs diameter or vice versa could screw the whole process up so I’d go ahead and double check all your code, conversions and whatnot, and then experimentally drive your robot a meter and see if that’s what it’s registering.

Apart from that, using closed loop velocity control on your drive motors, making sure your wheels are zeroed properly and a few other things, you might just be running into the limitations of dead-reckoning and wheel odometry. Depending on how long your trajectory is, how much turning you do, and various other factors, your robot will lose its place on the field.

1 Like

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