mirror of
https://github.com/azaion/gps-denied-onboard.git
synced 2026-06-21 11:31:13 +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
48 lines
1.4 KiB
Python
48 lines
1.4 KiB
Python
"""Trajectory comparison metrics."""
|
|
|
|
import numpy as np
|
|
import pytest
|
|
|
|
pytestmark = [pytest.mark.unit]
|
|
|
|
from gps_denied.testing.metrics import (
|
|
absolute_trajectory_error,
|
|
relative_pose_error,
|
|
trajectory_rmse,
|
|
)
|
|
|
|
|
|
def test_rmse_identical_trajectories_is_zero():
|
|
est = np.array([[0.0, 0.0, 0.0], [1.0, 0.0, 0.0], [2.0, 0.0, 0.0]])
|
|
gt = est.copy()
|
|
assert trajectory_rmse(est, gt) == pytest.approx(0.0)
|
|
|
|
|
|
def test_rmse_constant_offset():
|
|
# Constant 1m offset in x
|
|
est = np.array([[1.0, 0.0, 0.0], [2.0, 0.0, 0.0]])
|
|
gt = np.array([[0.0, 0.0, 0.0], [1.0, 0.0, 0.0]])
|
|
assert trajectory_rmse(est, gt) == pytest.approx(1.0)
|
|
|
|
|
|
def test_rmse_rejects_length_mismatch():
|
|
est = np.zeros((3, 3))
|
|
gt = np.zeros((4, 3))
|
|
with pytest.raises(ValueError):
|
|
trajectory_rmse(est, gt)
|
|
|
|
|
|
def test_ate_returns_summary_stats():
|
|
est = np.array([[1.0, 0.0, 0.0], [2.0, 0.0, 0.0], [3.0, 0.0, 0.0]])
|
|
gt = np.array([[0.0, 0.0, 0.0], [1.0, 0.0, 0.0], [2.0, 0.0, 0.0]])
|
|
result = absolute_trajectory_error(est, gt)
|
|
assert result["rmse"] == pytest.approx(1.0)
|
|
assert result["mean"] == pytest.approx(1.0)
|
|
assert result["max"] == pytest.approx(1.0)
|
|
|
|
|
|
def test_rpe_identical_trajectories_is_zero():
|
|
traj = np.array([[0.0, 0.0, 0.0], [1.0, 0.0, 0.0], [2.0, 0.0, 0.0]])
|
|
result = relative_pose_error(traj, traj, delta=1)
|
|
assert result["rmse"] == pytest.approx(0.0)
|