feat(diagnostics): 双 MID360 静止安装与公共平面检查

只跑雷达驱动、原始数据记录器和离线分析器,不启动 Point-LIO、TF、融合发布、
规划、串口或底盘,不改现场 site.yaml。诊断与正式场地任务解耦。

坐标只声明为局部 body(X 前、Y 左、Z 上 + 安装参考点),不声明已对齐比赛场地。
README 写明两条边界:点云重合只能提供证据,不能代替实物确认;车架空时地面
比落地时更低,该差值不能直接当安装高度误差。
This commit is contained in:
walunt5
2026-11-19 16:44:55 +08:00
parent ed18a1e039
commit 1928e1e3b7
4 changed files with 543 additions and 0 deletions
@@ -0,0 +1,60 @@
"""Synthetic counterexamples for the stationary plane diagnostic."""
import unittest
import numpy as np
from analyze_dual_geometry import compare_planes, extract_planes, fit_plane, yaw_matrix
def one_plane(points):
normal, offset, _ = fit_plane(points)
return {'id': 0, 'normal': normal.tolist(), 'offset_m': offset,
'indices': np.arange(len(points))}
class GeometryDiagnosticTests(unittest.TestCase):
def setUp(self):
self.rng = np.random.default_rng(472)
self.xy = self.rng.uniform(-2, 2, (1200, 2))
def test_configured_yaw_matches_production_projection_and_preserves_time(self):
from br_vehicle_mission.dual_lidar_fusion import project_scan
raw = np.array([[2., 0., .3], [0., -2., .7], [-2., 1., -.5]])
offsets = np.array([0, 1000, 49999000], dtype=np.int64)
mount = np.array([.325, 0., .044])
history = [(1., np.zeros(3), np.array([0., 0., 0., 1.])),
(1.075, np.zeros(3), np.array([0., 0., 0., 1.]))]
xyz, origins, stamps, _ = project_scan(raw, offsets, 1000000000, history,
mount, yaw_matrix(np.pi / 2), False)
expected = np.column_stack([-raw[:, 1], raw[:, 0], raw[:, 2]]) + mount
np.testing.assert_allclose(xyz, expected, atol=1e-14)
np.testing.assert_array_equal(stamps, 1000000000 + offsets)
np.testing.assert_allclose(origins, np.tile(mount, (len(raw), 1)), atol=1e-14)
def test_plane_recovery_with_outliers(self):
plane = np.column_stack([self.xy, -.15 + self.rng.normal(0, .002, len(self.xy))])
outliers = self.rng.uniform(-3, 3, (400, 3))
planes = extract_planes(np.r_[plane, outliers], max_planes=1)
self.assertEqual(len(planes), 1)
self.assertGreater(planes[0]['normal'][2], .999)
self.assertLess(abs(planes[0]['offset_m'] - .15), .002)
def test_parallel_plane_bias_is_reported_not_removed(self):
a = np.column_stack([self.xy, self.rng.normal(0, .002, len(self.xy))])
b = np.column_stack([self.xy, .05 + self.rng.normal(0, .002, len(self.xy))])
pairs = compare_planes([a, b], [[one_plane(a)], [one_plane(b)]])
self.assertEqual(len(pairs), 1)
self.assertGreater(pairs[0]['cross_plane_abs_p50_m'], .045)
self.assertLess(pairs[0]['cross_plane_abs_p50_m'], .055)
def test_same_infinite_plane_without_common_patch_is_rejected(self):
a = np.column_stack([self.xy, np.zeros(len(self.xy))])
b = a + [20., 0., 0.]
self.assertEqual(compare_planes([a, b], [[one_plane(a)], [one_plane(b)]]), [])
def test_line_does_not_establish_a_plane(self):
line = np.column_stack([np.linspace(-2, 2, 600), np.zeros((600, 2))])
self.assertEqual(extract_planes(line), [])
if __name__ == '__main__':
unittest.main()