Swerve modules odometry deviations

Hi, currently working on odometry and ran into very strange situation - some of the modules deviate more than others.
I created a temporary pose estimator for every module, using it’s SwerveModulePosition. That’s what it thinks after simple back and forth drive (every arrow represents a module):

Sometimes the modules that deviate change, it’s not consistent.

Does anyone know what can cause it?

2 Likes

I suggest you take a look at this thread:

1 Like

How are you calculating the positions of each module? You shouldn’t need to create a pose estimator for each module to get their position, unless you are debugging the swerve drive’s pose. If the pose estimator for the entire robot chassis seems consistent (which already takes into account the position of each module when the pose estimator is updated), then you can get the poses for each module by creating a Transform2d from the module’s Translation2d and current heading and transforming the current robot pose by this to get the module’s position.

Looking on module locations because the whole robot’s location provided by SwerveDriveOdometry is not accurate.
I’m calculating the SwerveModulePosition for each module as normal - using the total distance traveled and rotated. After that, I’m adding the difference between the current position and previous position to another position variable, every periodic (using the robot’s angle and etc. ). This is to know the position of every module on the field and not the total distance traveled by the module.

I understand you are trying to get the position of each module on the field. If you are not getting an accurate SwerveDriveOdometry and the positions of each of the individual modules are also not accurate, then you should look for potential errors in how the SwerveModulePosition is being updated.

  • If you rotate each module by hand one revolution and check the updated angle, do all of the modules increase/decrease by 360?
  • If you turn each swerve wheel by hand and check the updated position, did the wheel rotate by 2pi*R?

Either one of these being wrong can point to a conversion issue in the code or a physical issue with how the modules were assembled. Without knowing either of these, it is hard to determine what might be causing your issues.

Did these tests, looks like the results are good :confused:

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