robot_stream: low-latency WebRTC video + Nav2/teleop for ROS 2 in Flutter (deadman-protected, open source)
The author released robot_stream, an open-source BSD-3-Clause tool comprising a ROS 2 Humble gateway and Flutter/Dart packages for low-latency WebRTC/WHEP video streaming, telemetry, Nav2 navigation, and deadman-protected teleoperation.
Hi everyone,
I just open-sourced robot_stream (BSD-3-Clause) — an end-to-end ROS 2 Humble gateway + Flutter/Dart package suite for low-latency WebRTC/WHEP robot video streaming, telemetry, Nav2 navigation, and deadman-protected teleoperation.
(A short demo video — Wheeltec R550 on Jetson Orin Nano streaming H.264 over WebRTC/WHEP to an Android phone while driving to a Nav2 waypoint, plus Wi-Fi cutoff triggering the deadman goal cancel — is embedded at the top of the GitHub README linked below.)
Why I built this
While building a mobile teleop app for a ROS 2 robot (Jetson Orin Nano, which has no NVENC hardware encoder), I kept hitting the same practical issues:
- MJPEG (
web_video_server) is easy to start with, but on 5 GHz Wi-Fi it used ~5.6 Mbps per viewer at 640×480 q50, added ~229 ms glass-to-glass latency, and re-encoded JPEG separately for each viewer (4 viewers dropped raw camera FPS from 29.5 → 18 fps). - Android Wi-Fi power saving quietly batched incoming WebRTC UDP packets, inflating
libwebrtc’s receiver jitter buffer to 85–150 ms even on a 2–5 ms LAN. Holding an AndroidWIFI_MODE_FULL_LOW_LATENCYWifiLockbrought it down to 10–20 ms at 30 fps without dropping frames (unlikeForcePlayoutDelay(0, 0)). rosbridge_serveron Humble has no authentication, doesn’t cancel Nav2 goals when a phone drops off Wi-Fi, and withsend_action_goals_in_new_thread=Falsean active Nav2 goal can block a cancel/stop request on the same WebSocket connection.
What’s included
-
Robot side (
robot_node/robot_stream_ros, ROS 2 Humble,amd64&arm64):stream_node+ MediaMTX (WHEP): GStreamerx264enc(zerolatency,vbv-buf-capacity=100,sliced-threads=true) → local RTP/UDP → MediaMTX. Single encode for all viewers, auto-matched camera QoS, and on-demand streaming (~1–1.5% CPU when idle on Jetson Orin Nano).deadman_node: per-session heartbeat tracking (1.0 s timeout cancels active Nav2 goals even if another view-only client stays connected) + teleop velocity gate (0.3 s command timeout outputs zero/cmd_vel+ velocity clamping).rosbridge_guard: wraps localrosbridge_server(127.0.0.1:9090) on:9091with per-robot bearer token auth, optional self-signed TLS, and rotating JSON-line command audit logs.waypoints_node: serves named waypoints from YAML over/robot_stream/waypoints.- Includes a
nav2_standardprofile (tested on a simulated TurtleBot3 (fake node) + Nav2/AMCL) and a one-command setup script (bash robot_node/scripts/install_robot.sh).
-
Flutter / Dart side (published on pub.dev):
- All-in-one umbrella package:
robot_stream(flutter pub add robot_stream) - Or modular packages if you want a smaller app / pure-Dart CLI:
robot_stream_core— pure-Dart models, interfaces, SHA-256 TLS certificate pinningrobot_stream_webrtc— WHEP signaling +WhepSource+RobotVideoView+ Android low-latencyWifiLockplugin (iOS/macOS stubs)robot_stream_mjpeg— MJPEG fallback with JPEG marker framing and stall detectionrobot_stream_rosbridge— pure-Dart rosbridge v2 client with map+odom SE(2) pose fusion, non-blocking STOP over a dedicated action WebSocket, Nav2 goals, teleop, and heartbeats
- All-in-one umbrella package:
Measured performance (LAN, 5 GHz Wi-Fi, 640×480 camera)
| Stream / Client | FPS | Bandwidth | Latency / Jitter Buffer |
|---|---|---|---|
WebRTC/WHEP (RTP + vbv100/sliced) → Mac Chrome |
~30 fps | ~1.3–1.5 Mbps | Driver header.stamp → display: p50 66–69 ms / p95 93 ms, jitter buffer 11 ms |
WebRTC/WHEP → Samsung A33 (Android 15, WifiLock on) |
29–30 fps | ~1.3–1.5 Mbps | header.stamp → decoded: ~33–43 ms p50 (~110–120 ms est. glass-to-glass), jitter buffer 10–20 ms (vs. 85–150 ms without WifiLock) |
| WebRTC/WHEP → iPad 5th gen (iPadOS 16.7) | 25–29 fps | ~1.3–1.5 Mbps | header.stamp → decoded: ~41 ms p50, jitter buffer p50 17 ms / p95 19 ms |
MJPEG (web_video_server, raw 640×480 q50) |
28–30 fps | 5.6 Mbps | Glass-to-glass (Mac Chrome): median 229 ms |
In alternating A/B load tests on Jetson Orin Nano with YOLO11m running on GPU, CPU H.264 streaming did not slow YOLO down. In the GitHub README demo (robot driving to a Nav2 waypoint), the deadman canceled the goal ~0.7 s after the phone’s Wi-Fi was cut (1.0 s heartbeat timeout, robot at 0.20 m/s) and the robot coasted ~20–25 cm. During hold-to-drive teleop, the velocity gate also zeroes /cmd_vel after 0.3 s without commands.
Links
- GitHub (code,
robot_node/README.mdsetup guide, reference Flutter app, demo video): GitHub - robot-stream/robot_stream: Low-latency ROS 2 robot video streaming (WebRTC/WHEP & MJPEG), telemetry, Nav2 navigation, and deadman teleop for Flutter & Dart. · GitHub - pub.dev (
robot_streamumbrella + sub-packages): robot_stream | Flutter package
Current limitations (Free edition)
- LAN / VPN only out of the box — do not port-forward
:8889or:9091to the public internet (use WireGuard/Tailscale or an authenticated TURN relay for remote access). - Token auth only covers the
robot_streamendpoints (:9091, WHEP). DDS traffic on the LAN is not protected: any machine with ROS 2 on the same network can still publish/cmd_vel(useROS_LOCALHOST_ONLY=1or SROS2). A vendorrosbridge_serveralready exposed on:9090also stays open. - Without
tls:=true, the bearer token travels in cleartext on Wi-Fi. - No 2D
OccupancyGridmap / tap-to-goal widget yet (currently supports named waypoints, forward steps, and hold-to-drive teleop). - Software deadman is an added safety layer, not a replacement for a hardware E-stop.
I’d really appreciate feedback from folks running ROS 2 mobile / tablet teleop in practice:
- What client stack are you using today for operator UIs (web app, Flutter, Qt, Foxglove)?
- What’s the biggest gap you’d want next: remote access over 4G/TURN, multi-camera, 2D Nav2 map + tap-to-goal, security (SROS2 / per-user auth), or hardware encoder presets (Jetson NVENC / VAAPI)?
Thanks for taking a look — happy to answer questions or hear bug reports on GitHub Issues / Discussions!