Swerve Motors Zero to Different Positions

My team is having an issue with our swerve drive where when we start teleop, the turn motors turn rapidly to what should be the zero position, but with every code restart the position changes. We are using the Team364 base falcon swerve code as a base for our robot and then edited it for our specific robot specs. We tried taking out the joysticks and making the drive wheels constantly move forward to see if it was a joystick issue. We tried the 2023 fix stated in the Team364 GitHub, but it still did not fix the issue. We have our code up on GitHub right now, and any help would be appreciated.

Are your magnets for your absolute encoders glued in? We had this issue before.

Yes, we did encounter that at first too but they are glued in now.

Are the wheels all misaligned by the same amount?
Is the amount they shift consistent every restart?

I just tested it again now, the amount they shift seems to be inconsistent. They shift different amounts every time.

There’s another thread discussing what sounds to be the same thing across a couple teams.

Wouldn’t this be solved by synchronizing the angle motor encoders periodically? As opposed to only on initialization.

Probably, but I haven’t dug into the base code enough. I actually assumed this was already happening but I guess not. Didn’t notice until more recently.

Thank you everyone for the help, I just fixed the issue now. There was just a single letter ‘i’ where it wasn’t supposed to be that caused it all to break. I am still going to take what was said into account though because I can see stuff breaking without the bot synching periodically, but for now everything works. I’ll probably fix up the zero-out button in the code for that. Thanks again for all the help though!

I think democat’s fork of swerve-lib does this… When it detects the drivetrain to be inactive…


I like this and am yoinking it into my library now :smiley: