Our team recently updated to 2023 WPILIB VSCode version and we tried to run our code and it threw us an error with the odometry command. The odometry command used to just require kinematics and gyroscope rotation but now it requires initial position of the motors as well. We tried to figure out how to get position of the swerve modules but found no success. Does anybody know how to get the initial position of the swerve modules for the odometry command?
This is how we get our position for the Swerve Modules. We are using the BaseFalconSwerve from 364 and this method came with that, but if you look through our repository it looks like you can apply it to your code as well.
Looks like the conversion only takes into account the position counts from the falcon, so you would only need to replace that with the NEO position counts.
In your code… you have a folder “frc/lib”. In there you have a copy of the old swerve-lib. You need to replace it with the code from github repo I posted above.
It looks like somebody made some code changes to your old version… really you should put the code at src/main/java/com/swervedrivespecialties/swervelib/ and delete frc/lib
The thing is we cant use the swerve library because we are using mag encoders. We have to just modify 254’s library because as far as I know its the only library that allows swerve to run with mag encoders
Use DutyCycleEncoder (and plug the PWM pin into a DIO input), not AnalogEncoder. It’s specifically designed for this and will give you a very precise reading (by digitally sampling the PWM pulse rather than relying on analog averaging). It also supports up to 8 encoders.