mirror of
https://github.com/azaion/gps-denied-onboard.git
synced 2026-06-21 22:11:12 +00:00
c3650d979d
Provide deterministic geometry/time-sync helpers and structured config, error, health, and telemetry primitives for downstream runtime components. Co-authored-by: Cursor <cursoragent@cursor.com>
42 lines
1.4 KiB
Python
42 lines
1.4 KiB
Python
from shared.geo_geometry import Wgs84Coordinate, distance_m, local_to_wgs84, wgs84_to_local
|
|
from shared.time_sync import check_monotonic_timestamps, select_time_window
|
|
|
|
|
|
def test_wgs84_local_round_trip_is_deterministic() -> None:
|
|
# Arrange
|
|
origin = Wgs84Coordinate(latitude_deg=49.9808, longitude_deg=36.2527, altitude_m=120.0)
|
|
point = Wgs84Coordinate(latitude_deg=49.9811, longitude_deg=36.2531, altitude_m=118.0)
|
|
|
|
# Act
|
|
local = wgs84_to_local(origin, point)
|
|
round_trip = local_to_wgs84(origin, local)
|
|
|
|
# Assert
|
|
assert round(round_trip.latitude_deg, 7) == round(point.latitude_deg, 7)
|
|
assert round(round_trip.longitude_deg, 7) == round(point.longitude_deg, 7)
|
|
assert round(round_trip.altitude_m, 7) == round(point.altitude_m, 7)
|
|
assert distance_m(origin, point) > 0.0
|
|
|
|
|
|
def test_non_monotonic_timestamps_return_explicit_violation() -> None:
|
|
# Act
|
|
violations = check_monotonic_timestamps([100, 200, 150])
|
|
|
|
# Assert
|
|
assert len(violations) == 1
|
|
assert violations[0].category == "timestamp_mismatch"
|
|
|
|
|
|
def test_time_window_reports_gap_instead_of_dropping_silently() -> None:
|
|
# Act
|
|
result = select_time_window(
|
|
frame_timestamp_ns=1_000,
|
|
sample_timestamps_ns=[100, 200, 300],
|
|
tolerance_ns=50,
|
|
)
|
|
|
|
# Assert
|
|
assert result.ok is False
|
|
assert result.sample_timestamps_ns == ()
|
|
assert result.violations[0].category == "gap_exceeded"
|