Today my team was trying to take a characteristic of our robot using the FRC Characterization tool, but are having issues getting proper encoder readouts.
When we got the project generated using the CTRE template and drove the robot forward, we discovered that our right side drive encoders were reading negative values, so we tried to use the Tool’s function to invert the encoder. It turns out, the change that the tool makes in the code was
setSensorPhase() which doesn’t work for the TalonFX per this topic: Talon .setSensorPhase issues - Programming - Chief Delphi
When we found this post, I looked in the code and verified that it is using
setSelectedSensorPosition, so there isn’t a problem there, but while digging around in the code, we found that is makes use of the WPILib DifferentialDrive class which automatically inverts the right side drive power.
This function of DifferentialDrive seems to cause an issue where the right side drive will always drive opposite of the internal encoder’s value.
Is it okay to modify DifferentialDrive to tell it not to invert the right side drive power and then use the CTRE library to invert the right side? Or is there a better way to fix it so the encoder sign lines up with the drive direction?