How much does the drive wheel turn when the swerve module rotates?

I have SDS mk4i L2 swerve modules, with the Kraken X60 motors. I’m currently developing swerve code, and I’m encountering a problem. Whenever a swerve module rotates, the drive wheel turns a small amount, due to the way the modules are geared. This small amount of drive wheel turn creates inaccuracies with driving, which compound over time and result in unwanted change in robot orientation. My plan is to add a compensation velocity to the drive motor speed, based on how fast the swerve module is rotating. I need to know the ratio to apply though, and I can’t find the gearing calculation anywhere. How many times does the swerve module have to rotate to cause one full drive wheel rotation? Thanks for any help you can give.

Are you writing fully custom swerve code?

Yes, although I am basing the structure off of 6328’s swerve code. My team made the decision to develop our code from scratch because we wanted to understand how everything worked from the ground up and we value the ability to easily change any underlying code more than having every single feature of the advanced swerve libraries. We used the CTRE library last year, and had a lot of trouble fixing issues because we didn’t know how it worked under the hood.

I can’t say I’ve ever seen that effect before.

Before you delve down this path, are you sure your modules are assembled correctly?

I haven’t seen this issue on a REV MAXSwerve module, and I haven’t seen any teams using SDS complaining about this issue before either.

This has been a thing on every swerve module I’ve seen. Sometimes it is hard to notice, but its obvious-ish on SDS.

2 Likes

It happens due to the way that the SDS module gearing works. If the drive motor is held still, but the turn motor spins, the planetary gear connecting to the drive wheel is pulled around the center gear connecting to the drive motor, and so the drive wheel spins slowly as the module rotates.

2 Likes

Huh, TIL. I guess it’s very minimal on MAXSwerve.

This effect is due to the offset drive gear and the fact that it would rotate around the double gear:

Since you’re running an L2 ratio, those gears are 27T and 17T so I’d expect a ~1:1.588 ratio (the offset gear rotates 360 1.588 revolutions per turn of the wheel assembly). That is then geared 3:1 to the drive wheel, so divide that number by 3.

(It’s probably be a good idea to sanity check this math on a real module)

6 Likes

Thanks—this appears to be correct. I just experimented with a swerve module, and it seems to take about 1.75 turns for the drive wheel to make 1 full rotation. 1.75 module turns / 1 wheel turns * 1 wheel turn / 3 offset gear turns = 0.53333 module turns / 1 offset gear turn, or a ratio of 1:1.875, which is fairly close to your ratio of 1:1.588. I don’t want to code in a ratio just based on experimental data, so I will trust your ratio.

So, in conclusion, the drive wheel will rotate 0.529333 rotations every 1 module rotation. I will try adding “-currentState.rotationRadPerSec * 0.529333” to the applied drive motor velocity, and hopefully that will fix the problem.

1 Like

Is this happening when the module is on the ground or just when it’s in the air?

It happens in both situations.

We ran L2 with neos. We never had an issue with our pose getting too far away, but we used April tags to get it to be accurate again. Do you guys have a camera for pose correction?

There’s an explanation here for how to measure what CTRE calls the “coupling ratio,” which I think is what you’re after. It sounds like you took a fairly similar approach to measure it empirically.

Determining the best way of accounting for this effect is certainly an interesting project, though I’ll note that 6328’s testing suggests that the impact on odometry in practice is extremely minimal (and essentially nonexistent if you’re doing any kind of vision-based pose estimation). That doesn’t necessarily mean it isn’t worthwhile though, and the impact will vary depending on exactly what you’re doing. Just food for thought.

7 Likes

I’ve seen this too, perhaps I’m wrong from what others are saying about it, but from what I’ve noticed when placing weight on the wheel while turning, it no longer moves?

Maybe I’m crazy, I’ll have to check once I get my hands on a drive train again, but I think it’s essentially a non- issue

nah it doesnt just dssappear when you put weight on it, either the wheel turns without the motor turning, causing “wiggle” or the motor turns but not the wheel, causing negligible odometry noise. doesnt completely dissappear but is mostly negligible.

i can see some situations where a lineup has to be extremely precise that would require compensation.

1 Like