Skip to content

Conversation

@adam-weber
Copy link
Collaborator

@adam-weber adam-weber commented Dec 31, 2025

Summary

  • Add mount calibration system for determining device orientation relative to vehicle using brake-based yaw offset detection
  • Add NVS (Non-Volatile Storage) persistence so calibration survives device reboots
  • Fix speed source for calibration: use EKF velocity (200 Hz) instead of stale GPS speed (5 Hz)

Details

The device can be mounted in any horizontal orientation. The calibration system determines the yaw offset between the device's forward axis and the vehicle's forward axis using a simple brake calibration maneuver.

When braking hard in a straight line, the acceleration vector points directly backward relative to the vehicle. The angle of this vector in the device's body frame is the mounting offset.

State machine flow

  1. User triggers calibration via web UI
  2. System waits for vehicle to reach minimum speed (3 m/s)
  3. System waits for hard braking (>0.25g) while driving straight (<8.6 deg/s yaw
    rate)
  4. Collects 0.5s of acceleration samples
  5. Computes mean acceleration angle, adds 180 degrees to get mount offset
  6. Validates sample consistency (<10 degree variance)

NVS Persistence

New nvs_storage.rs module provides:

  • Generic typed getters/setters (u8, i16, f32)
  • Convenience methods for mount calibration (load/save)
  • Write ordering ensures safety against power loss: data written before validity flag.

Speed Source Fix

Previously the calibrator used GPS speed which updates at 5 Hz and can be stale. Now uses EKF velocity estimate which updates at IMU rate (200 Hz) for responsive state transitions during the calibration maneuver.

@adam-weber adam-weber requested a review from jctoledo December 31, 2025 16:24
@adam-weber adam-weber self-assigned this Dec 31, 2025
@adam-weber adam-weber force-pushed the feat/device-calibration branch from dd34aa0 to cabf1ae Compare December 31, 2025 16:29
@adam-weber adam-weber marked this pull request as draft December 31, 2025 16:30
@adam-weber
Copy link
Collaborator Author

I'll test this in a car later

@adam-weber adam-weber force-pushed the feat/device-calibration branch from cd470e0 to 9858450 Compare January 1, 2026 17:45
@adam-weber adam-weber changed the title Add device orientation calibration mechanism [WIP] Add device orientation calibration mechanism Jan 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants