Skip to content
This repository has been archived by the owner on Oct 27, 2021. It is now read-only.

TalonFX encoder inversion not working #168

Open
ValerieBG opened this issue Jan 23, 2021 · 2 comments
Open

TalonFX encoder inversion not working #168

ValerieBG opened this issue Jan 23, 2021 · 2 comments

Comments

@ValerieBG
Copy link

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.

@prateekma
Copy link
Member

Is this actually an issue when analyzing the data? The analyzer takes the absolute value of the encoder measurements and applies the sign of the voltage to compensate for these weird scenarios.

@pietroglyph
Copy link
Contributor

In addition to what Prateek said, as far as I know you should still be able to get all the inversions right, it's just that the right side might be flipped in a way that it isn't if you don't use DifferentialDrive.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants