My team is running into an issue with aligning our SDS MK4i swerve modules using Falcon 500 drive motors, NEO turn motors, and CANCoders. We are able to measure and configure the correct encoder offsets, and the drivetrain can be aligned correctly after deploying code and chasing the angles a bit. The issue comes when the robot is power cycled and the modules seem to drift at least 20-30 degrees on each power cycle. Regardless of alignment, the modules steer correctly and track their setpoints as expected.
After manually aligning and re-zeroing the encoders in Phoenix Tuner X, the zero offsets are extremely consistent, so faulty encoder magnets or mounting don’t seem to be the problem. The swerve modules are quite dirty and full of carpet dust, however. Overall, this issue seems a bit strange as we did not run into any similar issues last year with the same hardware running the API now known as Phoenix 5.
Here is the swerve module code, we are using the AdvantageKit swerve example as our base with some minor modifications to fit Falcon drive and NEO turn motors.
Please let me know if you have any ideas, similar experiences, or tips. Thanks!
I have been encountering the same error, I have not figured out the cause but I believe it is due to changes with Phoenix 6 and CANCoders. Temporarily I have changed back to Phoenix 5 and it is working correctly.
We also found the same problem using the falcon’s integrated sensor where the power on angle isn’t the zero angle. We got around it by setting the encoder’s position to zero in the code before doing anything else. I don’t have any experience with CANCoders, but I assume something similar could work.
With Phoenix 6, I would recommend setting the MagnetOffset property for the CANcoder and then never having to worry about offsets again. In Phoenix 6, the CANcoders always boot absolute. When you read the position it will incorporate the magnet offset; so, you don’t have to make any adjustments.
Update: We are now setting the MagnetOffset in code, but when we deploy and refresh the config in Tuner X the stored magnet offsets don’t seem to match. We have tried power cycling and the discrepancy persists.
Changing the offsets in the code seems to have an effect on the magnet offset viewed in Phoenix Tuner, but we can’t get them to converge. We also tried not setting the MagnetOffset in code and only setting it Tuner X and saw the same issues.
We are having the same problem, but the magnet offset is staying consistent and the cancoders have an accurate reading of their position, so it’s either a code issue or a problem with phoenix 6. probably phoenix 6 because our swerve code is unchanged from last year
The main thing that Phoenix 6 seemed to change on this is reporting CANCoder data in rotations, that is what started tripping us up in getting our swerve drive running this year. Once we figured that out, going through the normal process of aligning the drivetrain worked for us.