Autonomous Consistency with Swerve Drive

Hello FIRST community,

I’m a programming mentor for FIRST Team 5804. This is the teams first year using swerve drive and it’s been a great learning experience so far. We’re using MK3’s and got things driving using the SwerveDriveSpecialties swerve-template as a starting point. Now we are trying to implement PathPlanning for autonomous and are having some challenges.

We are using PathPlanner 2.0 to generate our Trajectory and the PPSwerveControllerCommand to make the robot drive the path. We have had some success with this so far - the robot drives the general shape of the paths generated, but isn’t being consistent on the distance traveled. Some runs it will be spot on, others won’t go far enough or will go too far, and sometimes it drifts, sometimes it doesn’t (all with the same code starting from the same starting spot). Has anyone experienced this before or have any tips for making path planning autonomous more consistent?

We have been tweaking the PID values for the xController, yController, and thetaController, but it has largely been trial and error to get those values. Right now we are only using the P value and have had the most luck using the same value for the x and y controller, but I feel like we are still missing something. How do other teams determine what their PID values should be for each of the PID controllers used by the PPSwerveControllerCommand or the SwerveControllerCommand? Any help or feedback on our approach would be appreciated!

Our codebase is still under heavy development but here is our code for reference. The test code for autonomous is found in the getAutonomousCommand() method in the RobotContainer.

Thank you for any info you can provide!

1 Like

So we are doing pretty much the same thing and the eureka moment is when we added these lines:

Hope this helped!


Eureka! That was it! We weren’t updating our odometry correctly. Once we added this in things fell into place. Thank you so much for your help and speedy response! You saved us a bunch of time and we have working path following now.


Np! Good luck at your comps

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