MotorSignal-App/docs/architecture/telemetry-validation.md

2.8 KiB

MotorSignal — Telemetry Validation & Quality Model

This document outlines the validation rules, confidence algorithms, and diagnostic flags used to evaluate telemetry samples in MotorSignal.


1. Validation Statuses

Every sample processed by TelemetryValidator is assigned one of three strongly typed statuses:

Status Definition Action Taken
VALID Sensor readings satisfy all physical plausibility, continuity, and accuracy requirements. Stamped with high confidence; used for real-time UI, database history, and personal records.
SUSPECT Minor anomalies detected (e.g. degraded GPS accuracy >35\text{m}, sample gap >2\text{s}, roll rate >180^\circ/\text{s}). Allowed for map rendering, but confidence is discounted (<0.60) and ignored for personal records.
REJECTED Impossible physical values (e.g. speed >220\text{ MPH}, acceleration >25\text{ m/s}^2, NaN/Infinity, position teleportation >110\text{ m/s}). Flagged with 0.0 confidence, logged to black box diagnostics, and blocked from personal records.

2. Validation Checks & Thresholds

A. Numeric Sanity

  • Any sample containing NaN or Infinity in latitude, longitude, speed, lean, pitch, or G-forces is immediately REJECTED.

B. Timestamp Continuity & Gap Detection

  • Normal Delta: 50\text{ms} (\pm 20\text{ms}).
  • Gap Threshold: \Delta t > 300\text{ms} increments the timestampGapCount.
  • Severe Gap: \Delta t > 2000\text{ms} marks the sample as SUSPECT with a baseline reset warning.

C. GPS Accuracy & Position Teleportation

  • Accuracy \le 5\text{m}: GPS Confidence = 1.0.
  • Accuracy \le 15\text{m}: GPS Confidence = 0.85.
  • Accuracy \le 35\text{m}: GPS Confidence = 0.60 (SUSPECT).
  • Accuracy > 35\text{m}: GPS Confidence = 0.25 (SUSPECT).
  • Teleportation: If distance between consecutive fixes > 50\text{m} at derived speed > 110\text{ m/s}, the sample is marked REJECTED.

D. Vehicle Dynamics & Physical Limits

  • Maximum Speed: 220\text{ MPH} (100\text{ m/s}).
  • Maximum Acceleration: 25\text{ m/s}^2 (\approx 2.5\text{g}).
  • Maximum Lean Angle: 65.0^\circ (MotoGP knee/elbow down physical limit).
  • Maximum Roll Rate: 180^\circ/\text{s} (flags loose mount or dropped phone).
  • IMU Saturation: Raw acceleration > 120\text{ m/s}^2 flags sensor saturation.

3. Telemetry Confidence Scoring

The composite telemetry confidence is calculated as:

\text{Overall Confidence} = 0.40 \cdot C_{\text{GPS}} + 0.30 \cdot C_{\text{Speed}} + 0.20 \cdot C_{\text{Lean}} + 0.10 \cdot C_{\text{G-Force}}

Personal records and performance timing require \text{Overall Confidence} \ge 0.65 and ValidationStatus.valid.