Atlas Robotics
Hardware AMRIntermediate

Encoders: how a robot measures wheel rotation

Atlasbot · 17/8/2026 · 11 min read

Encoders: how a robot measures wheel rotation
Quadrature encoder: two channels 90° out of phase indicate both speed and direction of rotation

Lesson Odometry in Localization assumes that the robot already has the data "how many revolutions the wheel just rotated". The Encoder is a sensor that generates exactly that data — attached to the motor shaft or wheel, counting the number of pulses emitted to deduce the rotation angle.

Key concepts

The two types of encoders differ in the way they know angular position:

  • Incremental encoder — only counts relative pulses, knows "how much more has been rotated" since last reading — does not know absolute angular position at first power on. Cheaper, much more popular in AMR because the wheel only needs to know how far it has rotated (enough for odometry), no need to know the absolute angle
  • Absolute encoder — each angle position has a separate binary code, the absolute angle can be read immediately even when the power is turned on, no need to "zero" first. More expensive, mainly used in machine arm joints (where the exact joint angle needs to be known immediately upon start-up, cannot wait for adjustment)

The vast majority of encoders mounted on AMR wheels are incremental — because the odometry problem only requires "how far has it gone", not "what absolute angle the wheel is at".

How it works

A rotating disc attached to the motor shaft, with grooves or lines evenly divided around the circumference. A fixed sensor (optical or magnetic) detects each time a track/line passes, emitting an electrical pulse. Count the number of pulses in a period of time, know in advance the number of pulses per rotation (encoder resolution), and deduce the rotation speed.

An encoder with only 1 pulse channel only knows speed of rotation, not direction of rotation (cannot distinguish whether it is rotating forward or backward just from counting the number of pulses). Quadrature encoder solves this problem by using two channels A and B, set 90° out of phase:

Forward rotation: channel A changes level BEFORE channel B
Reverse rotation: channel B changes level BEFORE channel A

Comparing the rising/falling edge order between two channels immediately indicates the direction of rotation — this is why nearly all encoders used in AMR odometry are 2-channel quadrature types, not simple 1-channel types.

In short: Encoder resolution (number of pulses/revolution) determines the smoothness and accuracy of odometry — the higher the resolution, the smoother the position estimation at low speeds. But high resolution cannot fix the core problem mentioned in the Odometry article: errors still accumulate over time no matter how accurate the encoder is, because odometry is essentially still dead reckoning.

Technical details

Formulas

Rotation speed is calculated from the number of pulses counted in a period of time:

rotation_speed (rps) = (count_pulses / number_of_pulses_per_revolution) / time (seconds)

For example: encoder 360 pulses/rev, counts 90 pulses in 0.1 second
rotation_speed = (90 / 360) / 0.1 = 2.5 rpm = 150 rpm

Parameters

The position of the encoder directly affects the effective resolution and data reliability:

Mounting locationAdvantagesDisadvantages
On motor shaft (before gearbox)Higher effective resolution (multiply transmission ratio)Slippage between gearbox and wheel cannot be detected
On the wheel shaft (after the gearbox)Correctly reflects the actual movement of the wheelLower effective resolution

Most DIY robots mount the encoder right on the motor shaft for mechanical simplicity and to take advantage of higher resolution — as long as the gearbox is reliable enough, not slipping teeth under normal operating conditions.

Practical applications

Encoder data from all 4 wheels (in robots using differential/mecanum drive configuration) is continuously read by the MCU (at the correct Driver Layer location mentioned in the AMR Architecture article), combined into an odometry estimate, then published to ROS2 as message nav_msgs/Odometry for AMCL/Nav2 to use for localization. This is why the encoder — despite being the smallest and cheapest hardware component in the entire system — is at the starting point of the entire localization and navigation chain of the robot.

Practical example

Encoder mounted on motor shaft, native resolution 11 pulses/revolution,
through a transmission ratio of 1:34, using quadrature type (multiplied by 4 thanks to reading both channels)

Effective number of pulses/revolution at wheel = 11 × 34 × 4 = 1496 pulses/revolution

If the MCU counts 374 pulses in 0.1 second:
rotation_speed = (374 / 1496) / 0.1 = 2.5 rpm

With wheel diameter 6.5cm (circumference ≈ 20.4cm):
Wheel speed = 2.5 × 0.204 ≈ 0.51 m/s

This example shows that the actual effective resolution (multiplying both the gearbox gear ratio and the quadrature coefficient) is much larger than the original parameter "11 pulses/revolution" recorded on the motor datasheet - easily causing confusion if not calculated correctly when writing code to read the encoder.

Common mistakes

  • Using a 1-channel encoder for odometry — cannot distinguish the direction of rotation, causing completely wrong distance estimates when the robot reverses or oscillates back and forth.
  • Forgot to multiply the transmission ratio and quadrature coefficient when calculating effective resolution — as in the example above, mistakenly using the original "11 pulses/rev" instead of 1496 effective pulses/rev makes the entire speed/distance estimate wrong by dozens of times.
  • Expect high resolution encoder to correct the accumulated drift of odometry — resolution only improves smoothness, does not solve the dead reckoning nature of accumulating errors over time (mentioned in Odometry article).
  • Install the encoder in front of the gearbox but do not check the gear slippage/retraction — if the gearbox slips under heavy load, the encoder in front of the gearbox will not detect it, leading to incorrect odometry without any warning signs from the sensor itself.

Conclusion

The encoder — even a simple pulse counting sensor — is the source of data for the entire odometry and localization chain behind it. Choosing the right type (2-channel quadrature), calculating the correct effective resolution, and understanding the limits (accumulated error over time) are the foundations before trusting the position data the robot reports. The next article in the column goes into LiDAR — sensors that help robots "see" their surroundings, making up for what odometry alone cannot do.

Get new articles and lessons by email

When a new technical article or course module is published, Atlas Robotics sends you a short email. No spam.

Unsubscribe any time with the link in each email. See our Privacy policy.

Encoders: how a robot measures wheel rotation — Atlas Robotics