Take the yaw rate about the vertical and stamp fixes with their GNSS time

The phone's CAM and VAM used the gyroscope's z axis as the yaw rate. That
is rotation about the screen's normal, so it only matched the bike's
turning with the phone flat, screen up: tilted on a handlebar it read about
64 % at 50 degrees, upright close to nothing. The gyroscope is now projected
onto gravity (TYPE_GRAVITY), which gives the rotation about the true
vertical however the phone is held, averaged over 100 ms. Gyroscope and
gravity run at SENSOR_DELAY_GAME for this; the yaw rate used to come from a
single sample at SENSOR_DELAY_UI.

Fixes now carry their own monotonic time (Location.getElapsedRealtimeNanos),
speed and bearing accuracy and provider, and sensor samples their own
SensorEvent.timestamp. What goes on air is the GNSS time of the fix itself,
from its monotonic age (GnssTimeSource.atElapsedRealtime), so neither the
phone's clock setting nor a step of it between the fix and transmission
reaches the CAM or GN timestamps. The loop's own intervals (elevated rate,
VAM generation rules) and the GNSS speed differencing for acceleration use
the monotonic clock too, so a clock set back can no longer hold VAMs off.

This is phase 0 of GNSS/IMU sensor fusion: YawRateEstimator is the first
piece of domain/fusion. Unit-tested; the bench and ride checks are in TODO.
This commit is contained in:
Ashin Walpola
2026-11-18 14:56:05 +01:00
parent b4e3385721
commit 727c9116dd
8 changed files with 427 additions and 46 deletions
+19
View File
@@ -5,6 +5,25 @@ Engineering to-do list. The reviewer-facing open items live in
## Waiting on hardware
### Sensor fusion phase 0: yaw rate about the vertical, fix times on GNSS time (added 2026-11-18)
The phone's own CAM/VAM now take the yaw rate from the gyroscope projected onto gravity
(`domain/fusion/YawRateEstimator`, 100 ms average, gyro and gravity at `SENSOR_DELAY_GAME`) instead of
the raw z axis. They stamp the GNSS time of the fix itself, through its monotonic
`elapsedRealtimeNanos` (`GnssTimeSource.atElapsedRealtime`). The loop's own intervals (elevated rate, VAM
rules) run on `SystemClock.elapsedRealtime`. Unit-tested (`YawRateEstimatorTest`), not yet on the phone.
With the CAM pinger on and a listener that decodes yawRate:
- [ ] Turn the Pixel 9 Pro on an office chair at about 90°/s: flat, tilted about 50° as on the
handlebar, and upright. All three should read about the same yaw rate. The old z-axis value
fell to about 64 % tilted and to about 0 upright.
- [ ] Phone still on the desk: yaw rate stays inside the 1 °/s noise floor, so it goes out as 0.
- [ ] Set the phone's clock 10 minutes wrong by hand (automatic time off) with a GNSS fix: the CAM
generationDeltaTime and GN TST still match GNSS time. Then step the clock back mid-run: CAMs and
VAMs keep going at their rate, with no gap and no time_regression on the micrOBU.
- [ ] Ride with the phone on the handlebar, then in a bag: the yaw rate's sign and size match the
turns (left and right, roundabout).
### obu-firmware on Niklas Dathe's microbu-firmware (added 2026-11-10, bench run 2026-11-11)
Flashed on the production XIAO (COM10) and the phone (Pixel 9 Pro, BLE) on 2026-11-11. Done, by hand