IMU + encoder yaw fusion: a timestamp experiment Thomas Thelliez — locally validated 2026-12-03 Requires Python 3.9 or later and its standard library. No packages to install. Actual local interpreter and checks are recorded in the publication evidence. Download fusion_demo.py and run: python3 fusion_demo.py --self-test python3 fusion_demo.py --output-dir demo-output The second command regenerates deterministic CSV inputs, results.csv, metrics.json and yaw-error.svg. There is no random seed because the sensor errors are explicit sine functions. To replay the generated input CSV files: python3 fusion_demo.py --input-dir demo-output --output-dir replay-output You can instead download imu.csv, encoders.csv and truth.csv into one folder and pass that folder with --input-dir. Input CSV files are never overwritten in replay mode. Output files in --output-dir are replaced on repeat runs. INPUTS AND UNITS imu.csv: time_s, gyro_z_rad_s. 1,201 samples at 100 Hz, 0 to 12 seconds. The rate at time t represents the preceding 10 ms interval; the initial row initializes time and its rate is not integrated. encoders.csv: capture_s, arrival_s, left_m, right_m. 241 packets at 20 Hz. Distances are cumulative since t=0, after conversion from encoder ticks using assumed correct wheel radii. Arrival is capture + 0.2 seconds. The final four packets arrive after the 12-second evaluation horizon. truth.csv: time_s, yaw_rad. Simulator truth used ONLY to evaluate errors, never by estimate(). All headings use the known initial yaw of zero. MODEL Differential drive on a plane, track width b=0.4 m, forward speed 0.5 m/s. Positive yaw is counterclockwise about the upward z-axis. Code uses radians; published errors use degrees. Yaw is unwrapped, not normalized to +/-pi. True turn rate is 0 deg/s (0-2 s), +60 (2-5 s), 0 (5-7 s), -45 (7-10 s), then 0 (10-12 s). Abrupt transitions are a teaching simplification. Gyro error: +0.8 deg/s bias + 0.1*sin(2*pi*0.9*t) deg/s. Encoder heading error: 0.6*sin(2*pi*1.3*t) + 0.25*sin(2*pi*0.7*t) degrees. This bounded encoder error is deliberately favorable: no wheel slip, wheel-radius/track calibration drift, missed ticks or correlated drift. The generator maps that heading error to opposite left/right distance errors. It is an invented input signal, not a sensor noise specification. ESTIMATOR AND FAULT Predict yaw by integrating the gyro at 100 Hz. At each encoder arrival, obtain wheel_yaw=(right_m-left_m)/b. Correct 15% toward the wheel reference. Aligned: reference = wheel_yaw + gyro integral between capture and arrival. Fault: reference = wheel_yaw, treating the old heading as if measured now. Both runs receive the identical packets, delays and sensor errors. For a constant 60 deg/s turn, 0.2 s of uncompensated age is 12 degrees. This is a fixed-gain complementary update, not an EKF. Propagation and the time-aligned reference reuse gyro increments; no independent-measurement covariance or statistical optimality is claimed. The code only supports acquisition/arrival timestamps on the IMU time grid, finite inputs, ordered unique acquisition times, and known delay in a shared clock. It does not estimate unknown clock offsets or calibrate gyro bias. EXPECTED OUTPUT (rounded to three decimals, from the published CSV inputs) run RMSE deg max absolute deg final error deg gyro_only 5.559 9.612 +9.612 aligned_fusion 0.444 0.801 +0.683 wrong_time_fusion 7.071 11.993 +0.544 RMSE includes every one of the 1,201 samples, including initialization. These are synthetic yaw errors, not position errors or hardware benchmarks. Final error alone hides the large timing-fault errors during turns. Floating-point/libm differences may affect trailing digits across platforms. LIMITS No camera, GNSS, accelerometer integration, 3D orientation, position estimate, map, ROS node, actuator command or hardware validation. No absolute heading is observed: both encoders and gyro can drift on a real robot. A long-run shared bias or wheel slip can defeat this example's favorable result. PRIMARY REFERENCES (documentation checked 2026-12-03) Differential-drive kinematics (ros2_control Rolling documentation): https://control.ros.org/rolling/doc/ros2_controllers/doc/mobile_robot_kinematics.html Coordinate conventions (REP-103 source): https://github.com/ros-infrastructure/rep/blob/master/rep-0103.rst Avoid double-counting encoder-derived measurements (robot_localization): https://github.com/cra-ros-pkg/robot_localization/blob/rolling-devel/doc/configuring_robot_localization.rst Temporal calibration and timestamps (Kalibr camera-IMU calibration): https://github.com/ethz-asl/kalibr/wiki/camera-imu-calibration These references support conventions and engineering cautions. The small synthetic experiment and its results are original to this tutorial; it does not implement or benchmark any of those software projects.