The problem
ROS 2 topics are designed for robot software, not directly for a mobile
Flutter app. Exposing the entire ROS graph to a phone can create
security, bandwidth, and compatibility problems.
What this guide covers
This tutorial focuses on practical architecture and performance
engineering for production systems. The central principle is to measure
the complete pipeline, keep latency-sensitive work close to the
hardware, and make failure states visible to the operator.
Reference architecture
ROS 2 nodes → selected topic adapter/bridge → authenticated gateway →
WebSocket messages → Dart repository → Flutter widgets. Use a
schema-controlled API and expose only the topics the app needs.
Implementation plan
- List required topics and define message contracts before implementing the UI.
- Use rosbridge or a dedicated ROS 2 gateway when appropriate, but place it behind authentication and network controls.
- Convert high-rate messages into sampled summaries for display; retain raw-rate processing inside ROS where possible.
- Use timestamps and sequence numbers to detect stale or out-of-order telemetry.
- Make reconnect and resubscribe behavior explicit, and display data freshness.
Example
class RobotTelemetry {\n const RobotTelemetry({required this.receivedAt, required this.batteryPct, required this.mode});\n final DateTime receivedAt;\n final double batteryPct;\n final String mode;\n\n bool get isStale => DateTime.now().difference(receivedAt) >\n const Duration(seconds: 2);\n} The snippets are illustrative starting points, not drop-in integrations.
Match APIs and version requirements to the exact SDK, OS image, hardware
revision, and runtime in your project.
Performance checklist
- Measure end-to-end latency, not only one function or model invocation.
- Report p50 and p95/p99 latency alongside throughput, memory use, and dropped work.
- Bound queues and define what happens when consumers fall behind.
- Avoid repeated frame copies and expensive work on Flutter's UI isolate.
- Test sustained workloads after the device reaches thermal equilibrium.
- Keep UI state, device state, and robot state distinct.
- Add timeouts, cancellation, reconnection, and explicit stale-data indicators.
- Profile on the actual target hardware using a reproducible build.
Common pitfalls
- Do not let a UI disconnect stop a robot safety node.
- Do not trust messages from arbitrary clients on a flat Wi-Fi network.
- Use the ROS 2 distribution and bridge version supported by your robot image.
Hands-on exercise
Display battery, mode, and connection freshness. Simulate a 3-second
network outage and verify that stale values are visibly marked.
Further reading
- Flutter performance best practices
- Flutter DevTools
- Android Developers
- NVIDIA Developer
- ROS 2 documentation
Useful Links
Website: www.v-modal.com
SDK Flutter: https://github.com/v-modal/vmodal_sdk_flutter
SDK Android: https://github.com/v-modal/vmodal_sdk_android
Discord: https://discord.gg/K72z28KUx

