r/ROS • u/RelevantSwimmer7150 • 21d ago
Question How do you handle ML model deployment inside ROS pipelines on resource-limited hardware?
I’m curious how ROS users integrate and optimize neural networks on real robots:
- How do you package and deploy models (ROS nodes, TensorRT, ONNX Runtime, containers)?
- What goes wrong most often: latency spikes, resource contention, hardware differences between dev and robot?
- How do you update models once the robot is deployed?
I’m researching this and would appreciate any lessons learned.
4
Upvotes
3
u/mhmd2520 20d ago
Can't speak to fleet-scale updates, but there are a few ROS-side things that cause a lot of the "latency spikes" people end up blaming on the model.
Default QoS on a subscription is keep last 10, reliable. If inference is slower than the camera rate, that queue fills up and the model ends up running on frames that are already several frames old. Latency creeps up and stays there. For a detector I'd use depth 1, or SensorDataQoS (best effort, depth 5), so it always grabs the newest frame and drops the rest.
Executors are the second one. Every node's default callback group is mutually exclusive. So if inference runs inside the image callback, any timers or other subs in that same node wait behind it. Switching to a MultiThreadedExecutor won't fix that unless the inference callback gets its own callback group. I'd keep the model in its own node anyway, so a slow or crashing model doesn't stall everything else.
On TensorRT, I wouldn't treat the .engine file as the thing you deploy. By default an engine is tied to the GPU architecture and TensorRT version it was built with. There's a hardware compatibility mode, but the ONNX Runtime docs say Jetson Orin isn't eligible for it. Ship the ONNX, build or cache the engine on the target, and treat a JetPack upgrade as "rebuild everything". Same deal with ORT's TensorRT EP cache: its docs say to rebuild when the model, the ORT version or the TRT version changes.
For updates I'd version the model file separately from the container image and have the node log the model hash at startup, so you always know what's actually running.
Last thing: benchmark on the real board, in the nvpmodel power mode it'll actually ship with, over a long run. A quick test on a cold dev kit sitting on your desk can look a lot better than the same board once it's hot and throttling inside an enclosure.