feat(lidar): admit and benchmark GOOSE baseline

This commit is contained in:
DCCONSTRUCTIONS
2026-07-25 14:14:20 +03:00
parent 881e97312b
commit 951b40c870
20 changed files with 2871 additions and 241 deletions
+42
View File
@@ -157,6 +157,48 @@ def test_local_percentile_ground_is_point_aligned_and_non_mutating() -> None:
np.testing.assert_array_equal(xyzi, unchanged)
def test_local_percentile_grid_index_preserves_exact_radius_result() -> None:
random = np.random.default_rng(42)
xyzi = random.normal(size=(240, 4)).astype(np.float32)
xyzi[:, :2] *= 4
profile = GroundBenchmarkProfile(
current_cell_size_m=0.6,
current_local_radius_m=1.7,
current_lower_percentile=11,
current_maximum_below_ground_m=0.2,
current_maximum_above_ground_m=0.18,
current_minimum_local_points=5,
)
actual = LocalPercentileGroundSegmenter(profile=profile).segment(xyzi)
xyz = xyzi[:, :3].astype(np.float64)
cell_keys = np.floor(xyz[:, :2] / profile.current_cell_size_m).astype(np.int64)
unique_cells, inverse = np.unique(cell_keys, axis=0, return_inverse=True)
expected = np.zeros(xyzi.shape[0], dtype=np.bool_)
global_ground_z = float(np.percentile(xyz[:, 2], profile.current_lower_percentile))
for cell_index in range(unique_cells.shape[0]):
point_indices = np.flatnonzero(inverse == cell_index)
center_xy = np.median(xyz[point_indices, :2], axis=0)
delta_xy = xyz[:, :2] - center_xy
local = xyz[
np.einsum("ij,ij->i", delta_xy, delta_xy)
<= profile.current_local_radius_m**2,
2,
]
ground_z = (
float(np.percentile(local, profile.current_lower_percentile))
if local.size >= profile.current_minimum_local_points
else global_ground_z
)
z = xyz[point_indices, 2]
expected[point_indices] = (
z >= ground_z - profile.current_maximum_below_ground_m
) & (z <= ground_z + profile.current_maximum_above_ground_m)
np.testing.assert_array_equal(actual.ground_mask, expected)
def test_ground_benchmark_is_immutable_diagnostic_evidence(tmp_path: Path) -> None:
replay = _Replay()
output = build_lidar_ground_benchmark(