Record motion sensors, raw GPS and clocks for sensor fusion, and add Ride settings

Phase 1 of GNSS/IMU sensor fusion: record what the filter needs, so it can
be built and tuned offline against real rides before it changes anything
on air (docs/07-sensor-fusion-logging.md).

Settings > Ride replaces Units, whose metric switch did nothing (the app is
metric throughout). It holds the phone position (handlebar, bag or pocket),
written into every V2X log as meta.phone_mount, and "Record motion
sensors", off by default.

With that switch on when a V2X log starts, the log (schema 2, file name
ending in _imu-<mount>) also records:
- accelerometer, gyroscope and gravity at 100 Hz into a new imu table, each
  sample with its own SensorEvent timestamp, collected on a background
  thread;
- raw GPS_PROVIDER fixes as gnss source phone_gps, next to the fused
  location, and for every phone fix its monotonic time, speed and bearing
  accuracy and provider;
- the monotonic, wall and GNSS clocks once a second into a new clock table,
  to line all timestamps up afterwards and show any phone clock step;
- the sensors' names and rates and the GNSS chip in meta.

Both settings are read once at the start, so one log is one mount and one
mode. The logger screen shows the mount, the motion sensor row count and
the raw GPS fix age while it runs.

tools/fusion_log_check.py checks a recorded log (sensor rates and gaps, both
phone sources, clock alignment and steps) and ends in PASS, WARN or FAIL.
Tested on synthetic logs built from V2xLogWriter's own table definitions;
the bench and ride checks on the Pixel 9 Pro are in TODO.
This commit is contained in:
Ashin Walpola
2026-11-19 15:17:02 +01:00
parent 275d382a1d
commit 7dd83dba3d
18 changed files with 971 additions and 64 deletions
+22
View File
@@ -5,6 +5,28 @@ Engineering to-do list. The reviewer-facing open items live in
## Waiting on hardware
### Sensor fusion phase 1: logging and test rides (added 2026-11-18)
Settings > Ride (phone position, Record motion sensors) and the fusion data in the V2X data logger,
described in `docs/07-sensor-fusion-logging.md`. Unit-tested and built; `tools/fusion_log_check.py`
tested on synthetic logs only. On the Pixel 9 Pro:
- [ ] Settings > Ride: Units is gone, Ride is there; the position and the switch survive an app restart.
- [ ] One-minute bench log with Record motion sensors on: the logger screen shows the mount, the motion
sensor count climbing by about 300 a second, and a raw GPS fix age; the file is named
`..._imu-<mount>.db`; `fusion_log_check.py` on it gives no FAIL (accel, gyro, gravity at about
100 Hz, `phone` and `phone_gps` fixes with `elapsed_ns`, `clock` rows with GNSS time).
- [ ] Screen off for 5 minutes during a log: no motion sensor gap over 1 s in the check (the log
service holds the CPU awake; confirm the sensors keep coming too).
- [ ] Record motion sensors off: the log has empty `imu` and `clock` tables, no `phone_gps` rows,
and no `_imu-` in its name, but still `meta.phone_mount`.
- [ ] Rides, 20-30 minutes each, mount set before Start, each with left and right turns, a
roundabout, stops of 10 s or more and if possible a bridge or underpass. Run the check on each
and keep the files for phase 2:
- [ ] handlebar
- [ ] bag (on the bike)
- [ ] pocket or backpack
### 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