How can I get a SwerveModule's SwerveModulePosition?

The swervemodule.getPosition() method does not seem to be there despite being the the wpilib example. Am I just overlooking something here? Please help.

There isn’t a WPILIB implementation of SwerveModule. That is up to you or a your library vendor to implement. If you are using old code you will need to add getPosition so you can pass it to all the places that now require it.

1 Like

Thanks for clearing that up. Do you know what it means exactly when it asks for “distance”? Is it referring to the total distance the wheel has traveled?

Yes it wants the total distance the wheel has travelled in meters. So make sure to convert whatever encoder units you are using to meters and be mindful of the gear ratio of your swerve modules.

1 Like

Ok nice, thank you :slight_smile:

Is the get position you are looking for return a double or a SwerveModulePosition, if it is a double it is most likely talking about steer position, if it is a SwerveModulePosition it is a new object with the drive distance and the steer position

Hi!
If you use the SwerveModule class from the following library you will be able to use getPosition(). Make sure to use all files in the lib file along with the SwerveModule file.

Are you using SDS or just the WPILib example?

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