Encoder to distance
Distance travelled from encoder counts, plus the conversion factors to put in code.
Inputs
Counts, or rotations if your API reports rotations (then set counts per rotation to 1).
Phoenix 6 (Talon FX) and REVLib (SPARK) report rotations: use 1. Phoenix 5 Talon FX: 2048. A quadrature encoder read as raw 4× counts: cycles per revolution × 4.
Encoder rotations per wheel rotation. An encoder on the motor uses the gearbox reduction; one on the wheel uses 1.
Result
Distance
0.4729- Wheel rotations
- 1.481
- Distance per encoder rotation
- 0.04729
- Distance per count
- 0.02309
- CTRE SensorToMechanismRatio for metres (1 ÷ k_rot)Per metre of travel
- 21.15
How it’s calculated
Formula
With your numbers (converted to SI units)
What it means
k_rot is the distance per encoder rotation. For REV, it is the position conversion factor; REV reports velocity in RPM, so use k_rot ÷ 60 as the velocity conversion factor for m/s. For CTRE Phoenix 6, set SensorToMechanismRatio to R to read wheel rotations and multiply by πd, or set it to 1 ÷ k_rot to read metres directly. k_count is the distance per encoder count, for APIs that report raw counts.
Assumptions
- No wheel slip; the measured distance drifts from the real one when the wheel slips or the tread wears.
Learn the concepts behind this on resources.simbotics.org · All formulas
