We are a bit late to the swerve game but are working on our SDS Mk4i base frame. And now comes the fun part … the software.
We are starting with the WPILIB examples and
Our swerve is a little bit different in that we are using Neo motors (not really that different), but are using a CTRE Mag encoder for the absolute encoder and wiring it into the Turning SparkMax. Now the mechanical and electrical components are working and the basis software is working. We can talk through the roboRIO to the modules motors and the absolute encoder and get the angle information. For the CTRE encoder we get a number from 0.0 to 1.0 for the full rotation.
Question 1: What is the ‘standard’ configuration for the starting point of the modules?
We understand that the wheels should be straight, however which orientation (ring gear out or in)? Also from the WPILIB documentation we understand the positive (+) direction is CCW. Correct?
Question 2: How to handle the ‘wrap’ of the analog encoder around the offset point?
When we mount the encoder the zero point is essentially random and there we have to incorporate and offset from the module zero point. However, we have a minor issue in dealing also with the encoder wrap from 359 degrees back to 0 degrees. When dealing with this type of encoder, how should we handle the offset and wrap?
We are just starting here and our first trials are to get basic PID running on the turning motor and then make sure we can move to a given position smoothly and repeatably.
Any help would be appreciated.
Thank You.