Swerve Drive Drift

We have had an issue with our swerve code. When we start driving, the wheels are aligned properly. After driving it for a bit, however, the wheels start to drift in different directions. We have a test button which resets the wheel positions to the offsets, but it doesn’t produce the expected result. The encoder printouts on Shuffleboard say that the wheels are at their correct offset, but the wheels are still pointing in different directions.

Here is our code:
https://github.com/R-venRobotics1288/2023-Code-Template.git

Our most recent tests are in the SwerveTest branch. Dev and Main are not fully up to date. Any suggestions?

1 Like

Are you using an off-the-shelf swerve module? Could you provide some information about your swerve module? Are you using an absolute encoder? Does your feedback control run off of the absolute encoder, or are you using the onboard encoders of falcons or neos?

Depending on what module you have, here are some common issues people have run across this season that meet your symptoms:

  1. Make sure all absolute encoders don’t have any drift (i.e. magnet properly retained)

  2. Make sure motor pinions are not slipping if they are a press on, this may be hard to tell and difficult to do by hand, but putting a mark with a paint pen or something so you can see where the pinions is clocked relative to the shaft, running the modules, then check to see if the clocking mark has moved will give you an idea.

3 Likes

Your code looks fine to me, your drift might be attributable to first order kinematics?

We are using a Neo 21-1650 with a spark max motor controller and we are using an absolute encoder. We are running based off of the absolute encoder.

what kind of modules are you using, could you send a picture of the modules on the chassis, this sounds more like an issue relating to how the magnet on the absolute encoder is retained than a code issue

this was drift with regards to robot position, I believe they were asking about the positioning of the swerve modules

1 Like

The are Mark 4 modules

1 Like

Yeah, make sure the magnet is glued in and your pinions are not slipping ( as in my first response) to me these seem the two most likely culprits.

The covers of the encoders are glued on.

I am more concerned about the magnets in the shaft of the encoder. If those are loose then they move relativ to the shaft and produce the behavior you described.

1 Like

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