Skip to content

Carry partial encoder ticks between wheel odometry samples - #10

Merged
JaidenAGrimminck merged 1 commit into
mainfrom
fix-wheel-odometry-ticks
Oct 16, 2026
Merged

JaidenAGrimminck merged 1 commit into
mainfrom
fix-wheel-odometry-ticks

Conversation

@clmazzac

Copy link
Copy Markdown
Member

Problem

buildWheelOdometryMeasurement rounded each sample's wheel travel to whole ticks with quantizeTravel and dropped the remainder. A real encoder counts the total rotation, so partial ticks add up. Here they were lost or gained on every sample.

The distance error then depended on speed. Measured over 30 s at 50 Hz with the default 0.15 m wheel and 1024 ticks per revolution:

Speed Error
3 m/s -0.3%
1 m/s +1.2%
0.2 m/s -8.0%
0.04 m/s +15.1%

Below half a tick per sample, about 0.046 m/s at 50 Hz, the odometry read zero.

Fix

The measurement state keeps each wheel's total travel (leftTravelM, rightTravelM). Each sample rounds the total to whole ticks. The travel it reports is the change in that tick count. leftTicks and rightTicks now hold the encoder count directly.

The position error stays below one tick (0.92 mm with the defaults) at any speed.

Tests

  • New test in tests/localization-sensors.test.js: 30 s straight runs at 0.01, 0.2, 1 and 3 m/s with pose noise off. Each final distance is within one tick of truth. Without the fix, 0.01 m/s reports 0 m against 0.3 m.
  • npm test on a clean checkout: all pass except Python decodes retained RGB, depth, and CameraInfo SFLog messages, which also fails on main.

Related

#9 fixes the integration interval in the same function. The two PRs merge cleanly in either order; I checked the combined result with npm test.

The measured wheel odometry values change for every run. deterministic-state-sensors stays at version 1. Bump it if recorded runs must reproduce exactly across this change.

🤖 Generated with Claude Code

Each sample rounded its own wheel travel to whole ticks and dropped the
remainder. The distance error then depended on speed: -8% at 0.2 m/s and
+15% at 0.04 m/s. Below half a tick per sample the odometry read zero.

The model now keeps the total travel of each wheel and quantizes that
total, as an encoder count does. The error stays below one tick.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@JaidenAGrimminck
JaidenAGrimminck merged commit eecd860 into main Oct 16, 2026
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants