mirror of
https://github.com/azaion/gps-denied-onboard.git
synced 2026-06-21 17:31:14 +00:00
5744ff65ac
- Add pytestmark = [pytest.mark.<category>] to all 23 root test files and 14 e2e test files - Marker distribution: 22 unit, 7 integration, 1 blackbox, 1 sitl, 5 e2e + 2 e2e integration - Add import pytest to test_models.py, test_download.py, test_synthetic_adapter.py (were missing) - Convert test_sitl_integration.py's bare pytestmark to list form preserving skipif guard - Union of all 5 markers = 298/298 = 100% coverage; 216 tests pass with --strict-markers
53 lines
1.8 KiB
Python
53 lines
1.8 KiB
Python
"""SyntheticAdapter produces a deterministic straight-line trajectory."""
|
|
|
|
import numpy as np
|
|
import pytest
|
|
|
|
from gps_denied.testing.datasets.base import PlatformClass
|
|
|
|
pytestmark = [pytest.mark.unit]
|
|
from gps_denied.testing.datasets.synthetic import SyntheticAdapter
|
|
|
|
|
|
def test_synthetic_has_raw_imu():
|
|
adapter = SyntheticAdapter(num_frames=10, fps=5.0)
|
|
assert adapter.capabilities.has_raw_imu is True
|
|
assert adapter.capabilities.platform_class == PlatformClass.SYNTHETIC
|
|
|
|
|
|
def test_synthetic_iter_frames_count():
|
|
adapter = SyntheticAdapter(num_frames=10, fps=5.0)
|
|
frames = list(adapter.iter_frames())
|
|
assert len(frames) == 10
|
|
assert frames[0].frame_idx == 0
|
|
assert frames[-1].frame_idx == 9
|
|
|
|
|
|
def test_synthetic_frame_timestamps_monotonic():
|
|
adapter = SyntheticAdapter(num_frames=10, fps=5.0)
|
|
ts = [f.timestamp_ns for f in adapter.iter_frames()]
|
|
assert ts == sorted(ts)
|
|
# 5 fps → 200 ms spacing
|
|
deltas = np.diff(ts)
|
|
assert np.allclose(deltas, 200_000_000)
|
|
|
|
|
|
def test_synthetic_imu_samples_cover_frames():
|
|
adapter = SyntheticAdapter(num_frames=10, fps=5.0, imu_rate_hz=100.0)
|
|
imu = list(adapter.iter_imu())
|
|
# 10 frames at 5 fps = 2 s of data, at 100 Hz = 200 samples
|
|
assert len(imu) == 200
|
|
# Static trajectory → gravity on z, zero gyro
|
|
assert abs(imu[0].accel[2] + 9.81) < 1e-6
|
|
assert imu[0].gyro == (0.0, 0.0, 0.0)
|
|
|
|
|
|
def test_synthetic_ground_truth_matches_frames():
|
|
adapter = SyntheticAdapter(num_frames=10, fps=5.0)
|
|
poses = list(adapter.iter_ground_truth())
|
|
assert len(poses) == 10
|
|
# Straight-line east at 10 m/s → position at t=0.2s is 2m east of origin
|
|
# (synthetic puts GT at same timestamps as frames)
|
|
assert abs(poses[1].lat - poses[0].lat) < 1e-9 # no latitude change
|
|
assert poses[1].lon > poses[0].lon # moving east
|