Zeroing Swerve Modules - HHS-Team670/MustangLib GitHub Wiki
Zeroing Swerve Modules
Authors: Armaan, Aditi
Date: 7/14/23
Steps
- FACTORY RESET ALL MOTOR CONTROLLERS (also make sure your drive and steer motors are set correctly) and make sure that all of the encoders are set correctly.
- if the anything is incorrect, do not change it in code. Rather, change the id numbers of the equipment using Get Or Flash CAN ID and Using Phoenix Tuner.
-
Set all of the *_ANGLE_OFFSET constants to -Math.toRadians(0.0)
-
Deploy the code to your robot. POWER CYCLE. Note: the robot isn’t drivable quite yet, we still have to set up the module offsets
-
Turn the robot on its side or put it on the robot cart with its wheels hanging off the side and align all the wheels so they are facing in the forward direction. NOTE: the wheels will be pointed forwards (not backwards) when modules are turned so the large bevel gears are towards the LEFT side of the robot. When aligning the wheels they must be as straight as possible. It is recommended to use a long straight edge such as a meter stick in order to make the wheels straight.
-
Record the angles of each module using the angle put onto Shuffleboard. The values are names Front Left Module Angle, Front Right Module Angle, etc.
- If the values are not showing up for you on the Shuffleboard application open glass, click on the Shuffleboard in transitory values, scroll to the bottom of the section and use the Current Angle value as the offsets. The current angle will be under the name of the module ex: Front Right.
-
Set the values of the k____ModuleSteerOffsetRadians to -Math.toRadians() NOTE: All angles must be in degrees.
-
Re-deploy, Power Cycle, and try to drive the robot forwards. All the wheels should stay parallel to each other. If not go back to step 3.
- If you are confident that you have the right values you could try power cycling again before going back to step 3
-
Make sure all the wheels are spinning in the correct direction. If not add 180 degrees to the offset of each wheel that is spinning in the incorrect direction. i.e:-Math.toRadians(<angle)+180.0)