Swerve turn motors oscillating rapidly while following a PathPlanner path

We are using PathPlanner with MaxSwerve modules and are trying to tune the PID values for the HolonomicPathFollowerConfig. The Angular Velocity graph in PathPlanner shows us getting pretty close to the target velocities along the path, however the turn motors are oscillating pretty rapidly while doing it. They do not seem to do that during teleop driving. Using AdvantageScope while running the path (which is a “simple” move forward by 2 meters while turning 180 degress), we can see that the set points for the swerve modules are indeed oscillating rapidly with the the measured values following close behind. Our swerve code is based heavily off of the MaxSwerve Java Template. The HolonomicPathFollowerConfig translation P value is 1.6. We got that value by running a path that just goes 4m straight forward. It follows the target velocity very well. We’ve been trying various values for the angular P value and, as I said before, we can get the velocity to pretty closely follow the target in the graph.

Any suggestions for what we need to do to get them to stop oscillating and making all this noise, which seems bad for the motors, would be greatly appreciated.

You didn’t share your code, but there’s a hint in your post. You mentioned the translation PID, but not the theta (the rotationConstants parameter.) If it performs well when there is no heading change (rotation) in the path, maybe you need to adjust the gains for your theta controller.

We had similar-sounding issues when we converted our 2023 maxswerve template over to PathPlanner 2024. Ultimately we ended up adapting the ChassisSpeeds logic and drive() methods from team 2046 (FireBears) drivetrain code:

If you’re still pretty close to the original template, that might work well for you too. Hope that helps! And big thanks to the FireBears for sharing their code! Big help to the students tonight.

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