feat(viewer): add recorded point colors and trajectory follow

This commit is contained in:
DCCONSTRUCTIONS
2026-07-23 13:33:08 +03:00
parent 9f712bf353
commit ecd95a22f0
16 changed files with 1218 additions and 36 deletions
+36 -15
View File
@@ -12,13 +12,15 @@ import rerun as rr
import rerun_bindings as bindings
from rerun import blueprint as rrb
from k1link.viewer.rerun_bridge import RerunSceneSettings, _parse_hex_color
from k1link.viewer.rerun_bridge import RerunSceneSettings
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_SPATIAL_FOLLOW_VIEW_ID = UUID("e96acd7f-1bb8-49e2-bff8-a661e5c6ceab")
RECORDED_SPATIAL_FOLLOW_RESET_VIEW_ID = UUID("f409403d-84ac-4309-82aa-501fc69905f5")
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")
@@ -33,6 +35,8 @@ 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_PERCEPTION_3D_FOLLOW_VIEW_ID = UUID("6bb43236-9507-4e8f-bc54-3a73b31c07b5")
RECORDED_PERCEPTION_3D_FOLLOW_RESET_VIEW_ID = UUID("0e01e3c6-8b7b-47aa-b22b-e413301599eb")
RECORDED_METRICS_VIEW_ID = UUID("f973fc11-0867-4732-ad3c-97008621fab7")
RECORDED_UNIFIED_ROOT_CONTAINER_ID = UUID("e9934ef8-453f-432e-9136-2b0908190253")
RECORDED_UNIFIED_RESET_ROOT_CONTAINER_ID = UUID("2781407d-9f4e-4405-86e8-bbe6065e83df")
@@ -155,6 +159,7 @@ def recorded_blueprint(
show_detections_2d: bool = False,
show_segmentation: bool = False,
show_cuboids_3d: bool = False,
follow_trajectory: bool = False,
) -> rrb.Blueprint:
accumulation = max(0.0, settings.accumulation_seconds)
time_ranges: list[rr.VisibleTimeRange] | None = None
@@ -171,16 +176,10 @@ def recorded_blueprint(
)
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()
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
point_overrides: list[Any] = [
@@ -219,10 +218,21 @@ def recorded_blueprint(
# Log an explicit empty range set so a previous accumulated blueprint
# for this stable view id is cleared instead of surviving in Rerun.
time_ranges=rrb.VisibleTimeRanges([]),
eye_controls=(
rrb.EyeControls3D(
kind=rrb.Eye3DKind.Orbital,
tracking_entity="/world/sensor_pose",
)
if follow_trajectory
else None
),
)
spatial_view.id = (
RECORDED_SPATIAL_RESET_VIEW_ID if view_reset_generation else RECORDED_SPATIAL_VIEW_ID
)
spatial_view.id = {
(False, 0): RECORDED_SPATIAL_VIEW_ID,
(False, 1): RECORDED_SPATIAL_RESET_VIEW_ID,
(True, 0): RECORDED_SPATIAL_FOLLOW_VIEW_ID,
(True, 1): RECORDED_SPATIAL_FOLLOW_RESET_VIEW_ID,
}[(follow_trajectory, view_reset_generation)]
camera_view = rrb.Spatial2DView(
origin="/perception/camera",
name="Оригинальное видео · слои AI",
@@ -269,12 +279,21 @@ def recorded_blueprint(
# native cloud from /world/points.
"/world/perception/lidar": rrb.EntityBehavior(visible=False),
},
eye_controls=(
rrb.EyeControls3D(
kind=rrb.Eye3DKind.Orbital,
tracking_entity="/world/sensor_pose",
)
if follow_trajectory
else None
),
)
perception_3d_view.id = (
RECORDED_PERCEPTION_3D_RESET_VIEW_ID
if view_reset_generation
else RECORDED_PERCEPTION_3D_VIEW_ID
)
perception_3d_view.id = {
(False, 0): RECORDED_PERCEPTION_3D_VIEW_ID,
(False, 1): RECORDED_PERCEPTION_3D_RESET_VIEW_ID,
(True, 0): RECORDED_PERCEPTION_3D_FOLLOW_VIEW_ID,
(True, 1): RECORDED_PERCEPTION_3D_FOLLOW_RESET_VIEW_ID,
}[(follow_trajectory, view_reset_generation)]
metrics_view = rrb.TimeSeriesView(
origin="/metrics/device",
name="Маршрут и время",
@@ -372,6 +391,7 @@ def recorded_blueprint_rrd(
show_detections_2d: bool = False,
show_segmentation: bool = False,
show_cuboids_3d: bool = False,
follow_trajectory: bool = False,
) -> bytes:
"""Serialize a bounded active blueprint update without recorded data."""
@@ -384,6 +404,7 @@ def recorded_blueprint_rrd(
show_detections_2d=show_detections_2d,
show_segmentation=show_segmentation,
show_cuboids_3d=show_cuboids_3d,
follow_trajectory=follow_trajectory,
)
payload: bytes | None
if blueprint_session_id is not None:
+3
View File
@@ -491,6 +491,9 @@ def _point_colors(
rgb: np.ndarray | None,
settings: RerunSceneSettings,
) -> np.ndarray:
if settings.palette == "custom":
color = _parse_hex_color(settings.custom_color)
return np.tile(np.asarray(color, dtype=np.uint8), (positions.shape[0], 1))
if settings.color_mode == "rgb" and rgb is not None:
return rgb
if settings.color_mode == "class":