Preview Streaming¶
Status: Rockchip H.264/SRT path implemented; software x264 remains selectable.
Preview streaming is the optional, on-demand video export path from the robot SBC to operator laptop tools. The robot gateway starts and stops this bounded SRT path through its control API so operators can inspect live perception context. It is a diagnostic surface, not a dependency of perception, command arbitration, or robot behavior.
Implementation¶
The preview path is managed by the robot_diag_control_cpp gateway process. It
is off by default and runs as a gateway-owned worker process only after an
operator calls SetPreviewMode.
Current ROCK 5B Plus camera facts:
/dev/video11isrkisp_mainpath/dev/video12isrkisp_selfpath- both can stream concurrently at
1280x720 NV12 60 fps - neither path currently advertises direct
BGR24orRGB24 mainpathandselfpathprovide the current preview/inference split
Implemented robot-side preview worker:
rkisp_mainpath (/dev/video11, NV12)
|
v
GStreamer preview worker
|
v
selected H.264 encode
|
v
MPEG-TS / SRT
Implemented host-side consumers:
robot_preview_viewerenables preview over gRPC and consumes the configured SRT endpoint withgst-launch-1.0robot_overlay_viewerenables preview, decodes SRT into an OpenCV window, polls gateway overlay snapshots, and draws detections plus telemetry over the live videorobot_monitor_shellpolls gateway status, runs short watch loops, and launchesrobot_preview_viewerrobot_monitor_guipolls status automatically and launches the preview or overlay viewer from a desktop GUI; the viewers manage preview lifecycle
Transport/runtime checks completed on the target SBC:
- GStreamer
v4l2srccaptures fromrkisp_mainpath - GStreamer SRT plugins are installed
- local
mainpath -> x264 -> MPEG-TS -> SRT -> decodeloopback has been validated - the C++ gateway can launch the selectable
x264 -> MPEG-TS -> SRTpreview worker path - packaged Python host tools request preview over gRPC and consume the SRT stream
The gateway preview_encoder parameter has two explicit values:
softwareuses the existingx264encpath and is the portable fallback/A-B option.rockchipusesmpph264encwith each profile's bitrate, one-second GOP, and SPS/PPS headers at each IDR.
Real-hardware bringup defaults gateway_preview_encoder to rockchip.
The gateway does not fall back when the selected encoder fails to start.
Contract¶
Preview control is part of the gateway gRPC API:
SetPreviewMode(enabled=true, profile=...)starts the workerSetPreviewMode(enabled=false)terminates the workerGetSystemStatusreportsPreviewStatusGetOverlaySnapshotreturns source-space detection geometry for host-side overlay scaling
Implemented preview profiles:
off: no preview worker runninglow_bw: 720p, 15 fps, 1000 kbit/sbalanced: 720p, 30 fps, 2500 kbit/shigh_quality: 720p, 60 fps, 4500 kbit/s
Preview lifecycle:
- preview disabled
- operator requests preview
- gateway validates the requested profile
- gateway resolves the profile to a bounded worker command
- gateway spawns the worker
- worker binds the SRT endpoint and exports video
- operator disables preview
- gateway terminates the worker
Operational contract:
- preview is optional and off by default
- preview startup, shutdown, and failure do not terminate mission-critical inference or robot behavior
- preview uses
rkisp_mainpathby default - inference uses
rkisp_selfpathby default - host tooling requires general-purpose decode/render capability, not Rockchip RGA
- decoded preview and detection overlays are approximately aligned, not exact-frame synchronized
Verification Boundary¶
Supported local verification:
scripts/omni test ros
Focused tests cover:
- preview command profile resolution
- preview process lifecycle behavior
- gateway service preview responses
- Python preview viewer helper behavior
- Python overlay viewer helper behavior
- monitor shell and Tk monitor smoke behavior
Target-side preview verification requires the ROCK 5B Plus camera devices, installed GStreamer SRT plugins, the configured SRT endpoint, and representative Wi-Fi conditions.
Limitations¶
- The software x264 backend remains available for portable operation and controlled A/B comparison.
- Hardware H.265 encode is not exposed through the installed userspace stack on the current image.
- FFmpeg exposes
hevc_v4l2m2m, but encode failed withCould not find a valid deviceduring bring-up. - No Rockchip-specific GStreamer H.265 encoder plugin appears to be installed on the current image.
- The gateway API does not publish SRT endpoint metadata.
- The Tk monitor GUI launches preview in a separate helper process and does not embed decoded video.
- Preview frames and detection frames come from separate camera paths and are not exact-frame synchronized.
- Software x265 is too CPU-expensive for the intended SBC mission budget.