MK4 SWERVE PROBLEM (angle)

Hi Everyone,
Today I got mk4 to swerve drive working! I’m talking no drift, no drag, and the ability to figure 8. However, one of my teammates decided to do something to the robot. Usually, we have to manually align the wheels before enabling robot drive (enabling in driver station). One of the team’s goals was to write a program that would do it automatically. So my teammate decided to write this code, and now all the angles on the modules are different and some modules are going in the right direction while others are not. I tried resetting everything and redoing the module angles offsets, however, nothing seems to be working. Additionally, the swerve modules are really jittery now. Can someone please suggest a fix? Thanks!

MK4s have an on-axis absolute encoder, which means that the absolute position reported by them will be the same between power cycles. You’ll want to figure out what the “zero” position of each wheel is, and then set the magnet offset of the CANCoders such that the absolute position is 0 when all wheels are pointed forwards. You’ll also want to make sure that you configure the encoders to boot to absolute position, instead of 0.

I posted some more detailed info about how CANCoders handle setting a magnet offset here.

1 Like

Are you not using the SwerveDriveSpecialties swerve-lib? that takes care of zeroing the swerve modules for you. One issue to note is that it can take up to 10 seconds for the CANcoders to fully calibrate, so trying to run the drivetrain <10s after a code restart (pushing code for example) may result in one or more corners being off.

Also, you don’t say what your team is using to get the swerve drive steering rotation? CANcoder? or something else?

1 Like

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