MK3 Swerve Drive Autonomous Odometry Issues

Good afternoon,

We have been encountering an issue programming odometry for our swerve drive modules. I can set coordinates and angles but the robot seems to inconsistently follow the path and will rotate wildly. It also sounds like the drive is rapidly changing directions unexpectedly.

I wanted to ask if anyone else has encountered this issue or if anyone has an idea as to what the source of this is. Is it just some PID tuning or something extra?

Here is the source code for the robot. Everything involving the drive should be in Constants, robotcontainer, drive subsystem, or the autonomous taxi command.

Also here is a video of the behavior we are experiencing.

https://drive.google.com/file/d/1gJ5TrxAX0Dh79eexZKosS9lS99wrKbdC/view?usp=sharing

Any help is appreciated, thanks.

1 Like

While I couldn’t access your video (not shared with everyone with a link), your issue sounds similar to one that we were debugging yesterday.

The resetPosition method of the SwerveDriveOdometry class resets the odometry based on the supplied pose, including the pose’s rotation. It then calculates the difference between the pose rotation and the specified rotation and uses that result as an offset in the future. We incorrectly thought that the method resets the odometry to the position of the supplied pose and the supplied rotation. As a result since our supplied rotation was different than the rotation in the pose, the robot was rotating unexpectedly. From looking at your code, it appears that your gyro will be at 270° while the pose will be at 0°.

On a related note, I don’t believe that the SwerveDriveOdometry handles holonomic drivetrains. We are using the PathPlanner and its PPSwerveControllerCommand class to enable rotation while following a path.

2 Likes

The link should now be accessible but thanks, we will take a look at that tomorrow.

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