feat: finalize corrected-route planning and Rerun recording review
This commit is contained in:
+45
-13
@@ -25,9 +25,6 @@ from k1link.device_plugins.xgrids_k1.rrd_export import (
|
||||
RECORDED_POINTS_VISUALIZER_ID,
|
||||
RECORDED_ROOT_CONTAINER_ID,
|
||||
RECORDED_SPATIAL_VIEW_ID,
|
||||
RECORDED_VIEW_POINT_DECIMATION_THRESHOLD,
|
||||
RECORDED_VIEW_POINT_FRAME_STRIDE,
|
||||
RECORDED_VIEW_POINT_STRIDE,
|
||||
SESSION_TIMELINE,
|
||||
RrdExportCancelled,
|
||||
RrdExportError,
|
||||
@@ -59,9 +56,8 @@ def _point_payload(x: float) -> bytes:
|
||||
)
|
||||
|
||||
|
||||
def test_recorded_operator_projection_thins_only_dense_point_batches() -> None:
|
||||
assert RECORDED_VIEW_POINT_FRAME_STRIDE == 5
|
||||
count = RECORDED_VIEW_POINT_DECIMATION_THRESHOLD + 3
|
||||
def test_recorded_operator_projection_preserves_all_points_and_attributes() -> None:
|
||||
count = 100_003
|
||||
positions = export_module.np.arange(
|
||||
count * 3,
|
||||
dtype=export_module.np.float32,
|
||||
@@ -78,16 +74,16 @@ def test_recorded_operator_projection_thins_only_dense_point_batches() -> None:
|
||||
assert projected_rgb is not None
|
||||
assert export_module.np.array_equal(
|
||||
projected_positions,
|
||||
positions[::RECORDED_VIEW_POINT_STRIDE],
|
||||
positions,
|
||||
)
|
||||
assert export_module.np.array_equal(
|
||||
projected_intensities,
|
||||
intensities[::RECORDED_VIEW_POINT_STRIDE],
|
||||
intensities,
|
||||
)
|
||||
assert export_module.np.array_equal(projected_rgb, rgb[::RECORDED_VIEW_POINT_STRIDE])
|
||||
assert export_module.np.array_equal(projected_rgb, rgb)
|
||||
|
||||
small_positions = positions[:RECORDED_VIEW_POINT_DECIMATION_THRESHOLD]
|
||||
small_intensities = intensities[:RECORDED_VIEW_POINT_DECIMATION_THRESHOLD]
|
||||
small_positions = positions[:2400]
|
||||
small_intensities = intensities[:2400]
|
||||
same_positions, same_intensities, no_rgb = _recorded_view_points(
|
||||
small_positions,
|
||||
small_intensities,
|
||||
@@ -98,18 +94,54 @@ def test_recorded_operator_projection_thins_only_dense_point_batches() -> None:
|
||||
assert no_rgb is None
|
||||
|
||||
|
||||
def test_recorded_operator_projection_uses_stable_two_hz_point_cadence() -> None:
|
||||
def test_recorded_operator_projection_preserves_every_point_frame() -> None:
|
||||
published = [
|
||||
frame_number
|
||||
for frame_number in range(1, 13)
|
||||
if _should_publish_recorded_point_frame(frame_number)
|
||||
]
|
||||
|
||||
assert published == [1, 6, 11]
|
||||
assert published == list(range(1, 13))
|
||||
with pytest.raises(ValueError, match="positive"):
|
||||
_should_publish_recorded_point_frame(0)
|
||||
|
||||
|
||||
def test_export_logs_every_frame_not_just_counts_them(tmp_path: Path, monkeypatch) -> None:
|
||||
capture = _write_capture(tmp_path, [
|
||||
("RealtimePointcloud", _point_payload(float(index)), index * 100_000_000)
|
||||
for index in range(12)
|
||||
])
|
||||
logged_counts = []
|
||||
original_log_points = export_module._log_points
|
||||
|
||||
def log_points(recording, frame, settings, **kwargs):
|
||||
logged_counts.append(frame.point_count)
|
||||
return original_log_points(recording, frame, settings, **kwargs)
|
||||
|
||||
monkeypatch.setattr(export_module, "_log_points", log_points)
|
||||
summary = export_k1mqtt_to_rrd(capture, tmp_path / "all-frames.rrd")
|
||||
assert logged_counts == [1] * 12
|
||||
assert sum(logged_counts) == summary["points"]
|
||||
|
||||
|
||||
def test_thirty_minute_settings_keep_small_screen_space_points() -> None:
|
||||
blueprint = viewer_recorded_blueprint(
|
||||
RerunSceneSettings(point_size=0.5, accumulation_seconds=1800),
|
||||
update_eye_controls=False,
|
||||
)
|
||||
spatial_view = blueprint.root_container.contents[0]
|
||||
_, visualizer, ranges = spatial_view.visualizer_overrides["/world/points"]
|
||||
values = {
|
||||
str(batch.component_descriptor()): batch.as_arrow_array().to_pylist()
|
||||
for batch in visualizer.overrides
|
||||
}
|
||||
assert values["Points3D:radii"] == [-0.5]
|
||||
assert ranges.ranges.as_arrow_array().to_pylist()[0]["range"] == {
|
||||
"start": -1_800_000_000_000, "end": 0,
|
||||
}
|
||||
assert "EyeControls3D" not in spatial_view.properties
|
||||
|
||||
|
||||
def _pose_payload(x: float) -> bytes:
|
||||
return struct.pack("<ffffffff", x, 2.0, 3.0, 99.0, 1.0, 0.0, 0.0, 0.0)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user