import importlib.util import json import math from pathlib import Path import pytest ROOT = Path(__file__).resolve().parents[1] spec = importlib.util.spec_from_file_location( "rover_motion", ROOT / "simulation/ai-polygon/rover_motion.py" ) module = importlib.util.module_from_spec(spec) spec.loader.exec_module(module) MOTION = json.loads( (ROOT / "apps/control-station/public/rover-scene/dcd006-v020-motion.json").read_text() ) def test_independent_tracks_stop_reverse_and_pivot(): phase = module.TrackPhase(MOTION) phase.step(0.1, 0.3, -0.3) left, right = dict(phase.distances), dict(phase.wheel_angles) phase.step(0.1, 0, 0) assert phase.distances == left assert phase.wheel_angles == right phase.step(0.1, -0.3, 0.3) for side in ("L", "R"): assert min(phase.distances[side], MOTION["length_m"] - phase.distances[side]) < 1e-9 for angle in phase.wheel_angles.values(): assert abs(math.sin(angle)) < 1e-9 def test_motion_matches_exported_gltf_rest_pose(): import struct data = (ROOT / "apps/control-station/public/rover-scene/dcd006-v020-motion.glb").read_bytes() size = struct.unpack_from("