Can I use CTRE Swerve project generator with Mk4i swerve modules?

Our team is attempting a swerve drive again, because it was kind of a fail last year. During comp this past season, we asked teams how they programmed their swerve drive; most said either YAGSL, or CTRE’s Swerve Project Generator (I will abreviate this to SPG).

It looks like CTRE’s SPG would be the easiest path. We already have all the parts for a swerve: CANCoders, Falcons/Krakens, Pigeon 2.0. However, we bought (pre-assembled) Mk4i Swerve Modules on the L2 ratio with colson wheels.

So it appears that we fill the requirements for the SPG, but will it work with Mk4i swerve modules? The only problem that I could see happening is that the gear ratios between the Swerve X modules and the Mk4i’s.

If this poses a problem, then is it possible to edit the gear ratios according to our swerve modules? Or perhaps we can change some variables in the code?

It should have preset options for the MK4i’s as my team used the CTRE SPG last year with no issues.

The SPG should work fine, but you’ll need to adjust a few things to account for differences in the gear ratios between the Swerve X modules and your Mk4is. Specifically, the drive gear ratio for the Mk4i with the L2 configuration is 8.14:1, and the steering ratio is 12.8:1 (correct me if I’m wrong). These numbers are different from the defaults in the SPG, so you’ll want to update those constants in the generated code to match your setup.

Another thing to check is the wheel diameter. Since you’re running Colson wheels, make sure the code is the same as the actual diameter of your wheels, this directly affects odometry and speed calculations. If the default in SPG assumes a different wheel size, you’ll need to update that to avoid issues.

You’ll also want to keep an eye on the feedforward and PID constants. These are probably tuned for Swerve X modules, so they might not work perfectly with the Mk4is right out of the box. It’s worth starting with the defaults to see how close they get, but you’ll likely need to adjust them, especially for the drive velocity and steering position controls.

For the CANCoders, make sure the offsets are properly calibrated. SPG includes a setup process for this, but the specific offsets will depend on how your Mk4i modules are assembled. Double-check the mechanical alignment and follow the initialization process carefully to avoid any weird alignment issues when the modules start rotating.

Once you’ve updated those details, run some simple tests to verify everything, like straight-line driving, rotation, and small maneuvers. If anything seems off (e.g., speed mismatches, inconsistent steering), revisit the gear ratio and PID tuning first. SPG is pretty flexible, so even if something doesn’t line up perfectly, you can probably tweak the code to make it work.

Overall, it’s definitely doable with the Mk4is, and the SPG makes a lot of the heavy lifting easier.!

Thanks a lot for the help! @David_IsMe mentioned that there is a preset for our modules, but if there isn’t I can get that info off the internet.

Another thing you mentioned were the CANCoder offsets, but our modules were bought pre-assembled, and iirc the offsets on the CANCoder’s should be 0 because they use precise factory machines to calibrate and install it on the module.

Only thing I am unsure about now is the PID Tuning, is there a guide for tuning PID for swerves that you could share?

Here is a good guide for tuning swerve.