Engineering & Architecture Brief Published: 2026-11-15
Most pedestrian dead-reckoning engines keep a hard-coded sensor period in a config file. Many of them also integrate gyro rate against that constant instead of against event timestamps. Outdoors nobody notices, because the magnetometer corrects heading every few steps. The bug shows up only when the magnetometer is rejected, and that is the moment the gyro becomes the only thing holding the route together.
Why review lets it through The diff looks clean. There is a constant named for a 20 ms sampling period, a step detector band-pass designed around it, a complementary filter that blends gyro and magnetometer heading, and a unit test that feeds synthetic data at exactly that rate. What the reviewer cannot see is that the platform treats the requested period as a hint: sensor hubs batch events to save power, some chipsets round the request to the nearest native rate, and another app on the same device can raise the shared rate for everyone. The value is correct in the config and wrong on the handset, and a test generated from the config will never disagree with the config.
Where the fallback breaks In a step-and-heading engine, heading normally comes from gyro integration corrected by the magnetometer. The correction is gated off when field magnitude or dip angle moves away from the local reference, which happens near steel framing, escalators and elevator cars. While the gate is closed the integrated gyro carries heading alone, so any gap between the configured and real sample interval scales every turn: a phone that delivers faster than configured over-rotates, one that delivers slower under-rotates, and map matching then snaps the user onto the wrong corridor of the micro-routing graph. The step detector fails at the same time, because its cutoff frequencies move with the real rate, so cadence is miscounted and distance per step drifts. The barometer usually stays correct, which is why these incident reports so often read 'right floor, wrong wing', and when that pattern keeps coming back in buildings with heavy steel or long elevator rides, suspect this configuration before you blame the magnetometer.
A check you can run today On an Android test device, start a navigation session, run adb shell dumpsys sensorservice and read the active connections section. For each client it shows the sampling period actually granted and the batching latency, alongside what other apps have requested from the same sensor. Next, take the event timestamps your own engine logged (the sensor timestamps, not the wall-clock time of your callback) and compute the median interval between consecutive gyro events over a walk that includes an elevator ride. If the granted period or the measured median differs from your configured period by more than roughly ten percent (an estimate, so tune it to how sensitive your filter is), the fallback path is integrating on the wrong time base, and on iOS you can run the same comparison using the timestamps Core Motion attaches to each sample. Then build that median into a startup self-check and a periodic health metric, so the comparison runs on every device in the field and not only on the bench.
The rule that stops the repeat Never take a rate-dependent coefficient from a config constant: integrate on measured timestamp deltas, rebuild the step filter whenever the measured rate drifts past your threshold, and if you cannot rebuild it, degrade honestly by widening the position uncertainty you show the user and report to emergency caller location services under US and European mandates, which costs you a blue dot that looks less sure of itself in exactly the places users most want certainty.
Technical FAQ: Does relying on the hardware step counter avoid the problem? Only partly. The vendor calibrates the sensor hub's step counter for its own rate, so cadence survives a rate mismatch. But it reports late when batched and tells you nothing about heading, so the gyro time-base problem in the fallback path is still there.