encoder-odometry-math

Compute differential-drive odometry from quadrature wheel encoders for ROS 2 robots.

Updated Aug 16, 2026
One-click install
npx skills add https://github.com/three1324/yeonjinautomotive --skill encoder-odometry-math-three1324
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: encoder-odometry-math
Source: https://github.com/three1324/yeonjinautomotive/tree/main/.claude/skills/encoder-odometry-math
Command: npx skills add https://github.com/three1324/yeonjinautomotive --skill encoder-odometry-math-three1324

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Implementing wheel-encoder odometry involves subtle math errors—wrong counting modes, integration drift, overflow bugs, and miscalibrated wheel parameters—that silently corrupt a robot's pose estimate. This Skill provides the complete formulas and calibration procedures to get it right. ## Core Features & Use Cases - Quadrature Decoding & Kinematics: Covers 1x/2x/4x counting modes, distance-per-count computation, and differential-drive forward kinematics (v, omega from wheel velocities). - Pose Integration Methods: Provides Euler, second-order Runge-Kutta (midpoint), and exact arc integration equations with guidance on when each applies. - ROS 2 Publishing & Calibration: Details nav_msgs/Odometry covariance setup, odom→base_link TF publishing, and step-by-step wheel diameter and wheel separation calibration procedures. - Use Case: You are writing an odometry node for a differential-drive robot and the heading drifts during turns—use the Runge-Kutta midpoint integration and the wheel separation calibration procedure to fix it. ## Quick Start Ask the assistant to implement a ROS 2 odometry node that computes pose from quadrature encoder counts using the encoder-odometry-math formulas.

Frequently Asked Questions about encoder-odometry-math

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I compute odometry from wheel encoders?

Convert encoder count deltas to wheel velocities using distance_per_count, then apply differential-drive kinematics: v = (v_R + v_L)/2 and omega = (v_R - v_L)/L. Integrate v and omega over time to update the pose (x, y, theta).

What is the difference between 1x, 2x, and 4x quadrature counting?

1x counts rising edges of channel A, 2x counts both edges of channel A, and 4x counts both edges of both channels. 4x counting gives the highest resolution: counts_per_rev = 4 × PPR × gear ratio.

Which pose integration method should I use for encoder odometry?

Euler integration works at high update rates with gentle turns. Runge-Kutta midpoint integration reduces error during arcs and S-curves. Exact arc integration is most accurate when omega is nonzero, with Euler fallback near zero.

How do I handle encoder integer overflow in odometry?

Compute deltas as (int32_t)(current - previous); signed subtraction handles wraparound correctly. For long-running robots, compute deltas rather than absolute positions, reset periodically, or use 64-bit counters.

Why does my robot odometry drift during turns?

Drift during turns usually comes from wrong wheel separation, wheel slip, or first-order integration error. Calibrate L by rotating exactly 360 degrees, reduce turn speed, use midpoint integration, and fuse with an IMU gyroscope via EKF.

How do I calibrate wheel diameter and wheel separation?

Push the robot exactly 2.000 m and compute diameter from recorded counts. Rotate exactly 360 degrees in place and compute L from the differential arc lengths. Repeat five times and average, since tire squish and friction affect results.