Does anyone have working example code to pull data from the built in encoder.

Thereâ€™s some bits of code in the docs, but not a complete example.

As a learning exercise, could you describe what youâ€™ve tried and how it wasnâ€™t working? Perhaps we could help you troubleshoot that. If you havenâ€™t tried yet, I definitely recommend giving that a go first.

To get you started, you likely have a WPI_TalonFX object, so what methods do you see in the docs that might get you what you need? (hint: you may need to look at the parent class, TalonFX)

I know how to access the encoder values but converting them to meters for RamseteController has been a pain. I am using PathPlanner. The test path is 1.69 m long but the values come up as ~3 meters.

Here is my conversion method:

```
public double encoderTicksToMeters(double currentEncoderValue, double encoderFullRev, double gearRatio, double wheelCircumferenceInInches) {
return (currentEncoderValue * Units.inchesToMeters(wheelCircumferenceInInches)) / (encoderFullRev * gearRatio);
}
```

Any suggestions?

Not sure how you have written your gear ratio and encoderFullRev in code, but I did it like this:

```
((encoderCounts / DRIVE_ENCODER_CPR) / GEARBOX_RATIO_HIGH) * METERS_PER_ROTATION;
```

first, get the motor revolutions by dividing the encoder counts by the â€śCounts Per Revolutionâ€ť of the encoder, then get wheel rotations by dividing by the gearbox ratio, then multiply by the meters per wheel rotation (wheel circumference) to get how far the robot has traveled.

Iâ€™m not sure if this is actually different from your math, Iâ€™m having a hard time figuring out the steps in your code. The other things I can think of are, double check your constants, and also incorrect pid/feedforward gains can cause the robot to overshoot - but youâ€™d probably realize if the robot was going 3 meters instead of 1.69.