CANcoders Absolute vs Relative


I have been using the mk4 swerve modules and have configured the code accordingly, however, our CANCoders seem to stay in relative mode, as in shuffleboard their angle keeps reverting back to zero after a certain amount of time. How do you boot cancoders into absolute mode?

1 Like

Something like this:

`swerveCanCoderConfig.initializationStrategy = SensorInitializationStrategy.BootToAbsolutePosition;`
1 Like

Was this not included in mk4 code? If not, where would it belong?

We are currently using custom swerve code for this. If you are talking about sds swerve-lib, you’ll probably have to go in to the can coder factory and make a modification there.

We tried to do that, but the cancofer values keep resetting

Did you power cycle the robot (turn it on and off again)? It won’t set these config values unless you do that.

1 Like

Yes we did.

Can you see the BootToAbsolutePosition setting in the Phoenix Tuner?


There was an error either in the Java method or the tuner - I can’t remember which - that it reported the incorrect value of some configuration. I think it was when you get the SensorInitializationStrategy. It’s been a long time but I think if it was set to BootToAbsolutePosition it erroneously reported set position to zero; the value was correctly what you want but you couldn’t verify that; it was confusing.

Also, my team does use the Java command to assure it’s exactly right even if someone messes with the tuner. Tuner is great for quick changes when developing but use the Java command to assure correctness.