feat(perception): integrate calibrated operator pipeline
Add calibrated K1 projection, recorded and near-live perception qualification, unified Rerun operator layers, bounded replay admission, audited viewer controls, worker experiments, and lab evidence.
This commit is contained in:
+179
-14
@@ -3,7 +3,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from contextlib import suppress
|
||||
from typing import Literal
|
||||
from typing import Any, Literal
|
||||
from uuid import UUID
|
||||
|
||||
import rerun as rr
|
||||
@@ -15,11 +15,29 @@ APPLICATION_ID = "nodedc_mission_core_recorded"
|
||||
SESSION_TIMELINE = "session_time"
|
||||
|
||||
RECORDED_SPATIAL_VIEW_ID = UUID("5f5f11d5-3b0a-4a81-887b-2be767cba1c0")
|
||||
RECORDED_SPATIAL_RESET_VIEW_ID = UUID("1480abcc-a0ae-4287-ab69-4b606d15d947")
|
||||
RECORDED_ROOT_CONTAINER_ID = UUID("b02f2aca-8471-4dcb-b786-53df5a320fc8")
|
||||
RECORDED_SPATIAL_RESET_ROOT_CONTAINER_ID = UUID("27d95ad7-1e72-46ca-b854-d02cd99b7610")
|
||||
RECORDED_PERCEPTION_ROOT_CONTAINER_ID = UUID("70ea9fd5-bbbb-4b23-8ae8-8098af92b997")
|
||||
RECORDED_PERCEPTION_RESET_ROOT_CONTAINER_ID = UUID("d2196c6e-99da-4402-857c-4daea0dd3ae0")
|
||||
RECORDED_PERCEPTION_3D_ROOT_CONTAINER_ID = UUID("81051015-9808-413b-90a4-1cfaacacbc4f")
|
||||
RECORDED_PERCEPTION_3D_RESET_ROOT_CONTAINER_ID = UUID(
|
||||
"3de10822-0274-4a58-8d45-f35d86625303"
|
||||
)
|
||||
RECORDED_METRICS_ROOT_CONTAINER_ID = UUID("374710a2-1d77-4349-bea4-8719e7aa1f09")
|
||||
RECORDED_METRICS_RESET_ROOT_CONTAINER_ID = UUID("1e8ac565-bbd6-4554-9213-dad564e534e3")
|
||||
RECORDED_POINTS_VISUALIZER_ID = UUID("ca037ec0-8761-4417-86ee-846fa2875303")
|
||||
RECORDED_PERCEPTION_POINTS_VISUALIZER_ID = UUID(
|
||||
"ab8db306-6981-49c5-b417-94fe2f01dbf0"
|
||||
)
|
||||
RECORDED_CAMERA_VIEW_ID = UUID("5c1db75b-07cd-479a-903d-f4f2ed554513")
|
||||
RECORDED_CAMERA_RESET_VIEW_ID = UUID("d0618e0c-c889-4222-a643-60a4a882935c")
|
||||
RECORDED_PERCEPTION_3D_VIEW_ID = UUID("0496bd2e-2b4d-4a4f-87b8-3ce4f9f7e114")
|
||||
RECORDED_PERCEPTION_3D_RESET_VIEW_ID = UUID("31f63ab8-ffdd-4751-ae40-e8e7b4462c8f")
|
||||
RECORDED_METRICS_VIEW_ID = UUID("f973fc11-0867-4732-ad3c-97008621fab7")
|
||||
RecordedView = Literal["spatial", "perception", "metrics"]
|
||||
RECORDED_UNIFIED_ROOT_CONTAINER_ID = UUID("e9934ef8-453f-432e-9136-2b0908190253")
|
||||
RECORDED_UNIFIED_RESET_ROOT_CONTAINER_ID = UUID("2781407d-9f4e-4405-86e8-bbe6065e83df")
|
||||
RecordedView = Literal["spatial", "perception", "perception3d", "metrics"]
|
||||
|
||||
|
||||
class RecordedBlueprintError(RuntimeError):
|
||||
@@ -31,6 +49,11 @@ def recorded_blueprint(
|
||||
*,
|
||||
include_initial_playback_state: bool = True,
|
||||
active_view: RecordedView = "spatial",
|
||||
view_reset_generation: Literal[0, 1] = 0,
|
||||
unified_perception: bool = False,
|
||||
show_detections_2d: bool = False,
|
||||
show_segmentation: bool = False,
|
||||
show_cuboids_3d: bool = False,
|
||||
) -> rrb.Blueprint:
|
||||
accumulation = max(0.0, settings.accumulation_seconds)
|
||||
time_ranges: list[rr.VisibleTimeRange] | None = None
|
||||
@@ -42,6 +65,7 @@ def recorded_blueprint(
|
||||
end=rr.TimeRangeBoundary.cursor_relative(),
|
||||
)
|
||||
]
|
||||
latest_time_ranges = rrb.VisibleTimeRanges([])
|
||||
point_visualizer = rr.Points3D.from_fields(
|
||||
radii=rr.Radius.ui_points(settings.point_size),
|
||||
colors=(
|
||||
@@ -51,9 +75,18 @@ def recorded_blueprint(
|
||||
),
|
||||
).visualizer()
|
||||
point_visualizer.id = RECORDED_POINTS_VISUALIZER_ID
|
||||
perception_point_visualizer = rr.Points3D.from_fields(
|
||||
radii=rr.Radius.ui_points(settings.point_size),
|
||||
colors=(
|
||||
[_parse_hex_color(settings.custom_color)]
|
||||
if settings.palette == "custom"
|
||||
else None
|
||||
),
|
||||
).visualizer()
|
||||
perception_point_visualizer.id = RECORDED_PERCEPTION_POINTS_VISUALIZER_ID
|
||||
spatial_view = rrb.Spatial3DView(
|
||||
origin="/world",
|
||||
name="Пространственная сцена",
|
||||
name="Мир · LiDAR и объекты" if unified_perception else "Пространственная сцена",
|
||||
background=[7, 8, 10, 255],
|
||||
line_grid=rrb.LineGrid3D(
|
||||
visible=settings.show_grid,
|
||||
@@ -68,29 +101,151 @@ def recorded_blueprint(
|
||||
"/world/trajectory": rrb.EntityBehavior(
|
||||
visible=settings.show_trajectory,
|
||||
),
|
||||
# Perception is hidden in the mapping-only presentation. Unified
|
||||
# perception below adds explicit per-entity latest-at overrides,
|
||||
# allowing the native cloud to retain this view's accumulation.
|
||||
"/world/perception": rrb.EntityBehavior(visible=False),
|
||||
},
|
||||
time_ranges=time_ranges,
|
||||
)
|
||||
spatial_view.id = RECORDED_SPATIAL_VIEW_ID
|
||||
spatial_view.id = (
|
||||
RECORDED_SPATIAL_RESET_VIEW_ID
|
||||
if view_reset_generation
|
||||
else RECORDED_SPATIAL_VIEW_ID
|
||||
)
|
||||
camera_view = rrb.Spatial2DView(
|
||||
origin="/perception/camera",
|
||||
name="Камера · распознавание",
|
||||
name="Оригинальное видео · слои AI",
|
||||
background=[7, 8, 10, 255],
|
||||
overrides={
|
||||
"/perception/camera/image": rrb.EntityBehavior(visible=True),
|
||||
"/perception/camera/detections": rrb.EntityBehavior(
|
||||
visible=show_detections_2d,
|
||||
),
|
||||
"/perception/camera/segmentation": rrb.EntityBehavior(
|
||||
visible=show_segmentation,
|
||||
),
|
||||
},
|
||||
)
|
||||
camera_view.id = (
|
||||
RECORDED_CAMERA_RESET_VIEW_ID
|
||||
if view_reset_generation
|
||||
else RECORDED_CAMERA_VIEW_ID
|
||||
)
|
||||
perception_3d_view = rrb.Spatial3DView(
|
||||
# Cuboids are expressed in the same calibrated world frame as the
|
||||
# native LiDAR recording. Rooting this view at /world/perception
|
||||
# excluded /world/points and left the operator looking at boxes in an
|
||||
# empty scene. Keep the main point cloud and the derived objects in
|
||||
# one latest-at world view; unlike the mapping tab, this deliberately
|
||||
# has no accumulated time range, so dynamic cuboids never stack.
|
||||
origin="/world",
|
||||
name="Сегментация и объекты · 3D",
|
||||
background=[7, 8, 10, 255],
|
||||
line_grid=rrb.LineGrid3D(
|
||||
visible=settings.show_grid,
|
||||
color=[86, 91, 99, 110],
|
||||
stroke_width=0.75,
|
||||
),
|
||||
overrides={
|
||||
"/world/points": [
|
||||
rrb.EntityBehavior(visible=settings.show_points),
|
||||
perception_point_visualizer,
|
||||
],
|
||||
"/world/trajectory": rrb.EntityBehavior(
|
||||
visible=settings.show_trajectory,
|
||||
),
|
||||
"/world/perception": rrb.EntityBehavior(visible=True),
|
||||
# The overlay already carries the selected fusion support points;
|
||||
# its grey diagnostic LiDAR copy would otherwise double-render the
|
||||
# native cloud from /world/points.
|
||||
"/world/perception/lidar": rrb.EntityBehavior(visible=False),
|
||||
},
|
||||
)
|
||||
perception_3d_view.id = (
|
||||
RECORDED_PERCEPTION_3D_RESET_VIEW_ID
|
||||
if view_reset_generation
|
||||
else RECORDED_PERCEPTION_3D_VIEW_ID
|
||||
)
|
||||
camera_view.id = RECORDED_CAMERA_VIEW_ID
|
||||
metrics_view = rrb.TimeSeriesView(
|
||||
origin="/metrics/device",
|
||||
name="Маршрут и время",
|
||||
)
|
||||
metrics_view.id = RECORDED_METRICS_VIEW_ID
|
||||
active_tab = {"spatial": 0, "perception": 1, "metrics": 2}[active_view]
|
||||
root_container = rrb.Tabs(
|
||||
spatial_view,
|
||||
camera_view,
|
||||
metrics_view,
|
||||
active_tab=active_tab,
|
||||
)
|
||||
root_container.id = RECORDED_ROOT_CONTAINER_ID
|
||||
root_container: Any
|
||||
if unified_perception:
|
||||
# Operator perception is one synchronized composition, not a set of
|
||||
# mutually exclusive modes. The camera keeps the original frame as
|
||||
# its base and overlays 2D detections/segmentation. The paired world
|
||||
# view shows the same cursor in the native LiDAR frame and reveals
|
||||
# semantic points and cuboids independently.
|
||||
spatial_view.visualizer_overrides["/world/perception"] = [
|
||||
rrb.EntityBehavior(visible=True),
|
||||
latest_time_ranges,
|
||||
]
|
||||
spatial_view.visualizer_overrides[
|
||||
"/world/perception/lidar"
|
||||
] = [
|
||||
rrb.EntityBehavior(visible=False),
|
||||
latest_time_ranges,
|
||||
]
|
||||
spatial_view.visualizer_overrides[
|
||||
"/world/perception/support"
|
||||
] = [
|
||||
rrb.EntityBehavior(visible=False),
|
||||
latest_time_ranges,
|
||||
]
|
||||
spatial_view.visualizer_overrides[
|
||||
"/world/perception/semantic_points"
|
||||
] = [
|
||||
rrb.EntityBehavior(visible=show_segmentation),
|
||||
latest_time_ranges,
|
||||
]
|
||||
spatial_view.visualizer_overrides[
|
||||
"/world/perception/boxes3d"
|
||||
] = [
|
||||
rrb.EntityBehavior(visible=show_cuboids_3d),
|
||||
latest_time_ranges,
|
||||
]
|
||||
root_container = rrb.Horizontal(
|
||||
camera_view,
|
||||
spatial_view,
|
||||
column_shares=[0.46, 0.54],
|
||||
name="Единая сцена восприятия",
|
||||
)
|
||||
root_container.id = (
|
||||
RECORDED_UNIFIED_RESET_ROOT_CONTAINER_ID
|
||||
if view_reset_generation
|
||||
else RECORDED_UNIFIED_ROOT_CONTAINER_ID
|
||||
)
|
||||
else:
|
||||
# Keep operator video and 3D cuboids as direct root views. Rerun's nested
|
||||
# Tabs preserve their own active child and cannot be switched reliably by
|
||||
# a live blueprint channel after the operator has visited another child.
|
||||
active_tab = {"spatial": 0, "perception": 1, "perception3d": 2, "metrics": 3}[
|
||||
active_view
|
||||
]
|
||||
root_container = rrb.Tabs(
|
||||
spatial_view,
|
||||
camera_view,
|
||||
perception_3d_view,
|
||||
metrics_view,
|
||||
active_tab=active_tab,
|
||||
)
|
||||
# Rerun persists the active child on a Tabs container and does not reliably
|
||||
# replace it from a later blueprint message. Give every operator mode (and
|
||||
# its explicit reset generation) a stable root identity so the requested
|
||||
# child is authoritative instead of inheriting a previously visited tab.
|
||||
root_container.id = {
|
||||
("spatial", 0): RECORDED_ROOT_CONTAINER_ID,
|
||||
("spatial", 1): RECORDED_SPATIAL_RESET_ROOT_CONTAINER_ID,
|
||||
("perception", 0): RECORDED_PERCEPTION_ROOT_CONTAINER_ID,
|
||||
("perception", 1): RECORDED_PERCEPTION_RESET_ROOT_CONTAINER_ID,
|
||||
("perception3d", 0): RECORDED_PERCEPTION_3D_ROOT_CONTAINER_ID,
|
||||
("perception3d", 1): RECORDED_PERCEPTION_3D_RESET_ROOT_CONTAINER_ID,
|
||||
("metrics", 0): RECORDED_METRICS_ROOT_CONTAINER_ID,
|
||||
("metrics", 1): RECORDED_METRICS_RESET_ROOT_CONTAINER_ID,
|
||||
}[(active_view, view_reset_generation)]
|
||||
|
||||
if include_initial_playback_state:
|
||||
return rrb.Blueprint(
|
||||
@@ -118,6 +273,11 @@ def recorded_blueprint_rrd(
|
||||
application_id: str = APPLICATION_ID,
|
||||
recording_id: str,
|
||||
active_view: RecordedView = "spatial",
|
||||
view_reset_generation: Literal[0, 1] = 0,
|
||||
unified_perception: bool = False,
|
||||
show_detections_2d: bool = False,
|
||||
show_segmentation: bool = False,
|
||||
show_cuboids_3d: bool = False,
|
||||
) -> bytes:
|
||||
"""Serialize a bounded active blueprint update without recorded data."""
|
||||
|
||||
@@ -133,6 +293,11 @@ def recorded_blueprint_rrd(
|
||||
settings,
|
||||
include_initial_playback_state=False,
|
||||
active_view=active_view,
|
||||
view_reset_generation=view_reset_generation,
|
||||
unified_perception=unified_perception,
|
||||
show_detections_2d=show_detections_2d,
|
||||
show_segmentation=show_segmentation,
|
||||
show_cuboids_3d=show_cuboids_3d,
|
||||
),
|
||||
make_active=True,
|
||||
make_default=False,
|
||||
|
||||
Reference in New Issue
Block a user