CanCoder setting to absolute value not consistent

This is not our first year using swerve but it is our first year using Java and the roadblock to get it working with swerve has been huge. We are using the swerve template provided by SDS (https://github.com/SwerveDriveSpecialties/swerve-template) and followed the README and adapted the code to our hardware (see below) but when we enable the wheels don’t go to their specified values. The driving using a joystick looks consistent but it’s hard to tell when their all going different directions. I have checked using Phoenix Tuner and the BootToAbsVal is on and the correct value is there but it doesn’t boot to that position. Any workarounds or help would be appreciated.

Here is the hardware we are using on our robot:
4x SDS Mk4i with Falcon 500s
4x CANCoders
1x Pigeon 2.0

1 Like

We delt with a similar issue for a while while developing our swerve. On our swerve it was caused by the magnets on the CANCoders not being adhered probably. As long as you are setting module offsets per the readme and the magnets are glued down, it should work.
Edit: also make sure that there are no electrical/can issues present.

2 Likes

Just to be clear, you do realize that the offset value will be different for every wheel and that you will have to determine these values empirically? This is because the magnets are randomly inserted into the center shaft for each wheel. If it isn’t your first year using these, you probably had to work this out sometime in the past.

We have an alignment procedure we use to check and adjust these values. This is needed any time you disassemble/reassemble a module and is a good thing to check periodically. We also have a test mode command which simply sets each module to position “0”, so that you can quickly check that things are good.

2 Likes

I checked our magnets earlier and they were secured to the module but the actual encoder PCB wasn’t very secure, could this be an issue?

Yes, we followed the magnet offset procedure detailed in the README and got varying results for each module which we then placed into the Constants file. We also experienced twitching which I believe to be just PiD as we were using the preset ones already configured and haven’t tuned our own yet as we can’t get the modules to be parallel to one another.

1 Like

I guess if the wire connections aren’t secure it could present a potential issue but I doubt that is the cause of the entire issue.

We have a panel that shows up in test mode and displays the readings from each swerve sensor (it’s based on Shuffleboard and uses the little gyro widget to display. This type of thing is really helpful – it let’s us verify the sensor just by powering up and manually turning a module.

A simpler version would just print these numbers every so often (we try not to print stuff except temporarily)…

1 Like

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