ROS2 Image publisher slows down on subscription
When I run cam2image
demo on one machine and subscribe to published image topic on another machine (connected over WiFi) using ros2 topic hz
the frequency of the publisher drops from 30 Hz to 6 Hz.
I'm using ROS2 Foxy on Raspberry Pi 4 with Pi OS Buster (first machine) and Ubuntu 20.04 inside a VirtualBox (second machine).
1) I run cam2image demo on the first machine:
ros2 run image_tools cam2image --ros-args -p reliability:=best_effort -p height:=480 -p width:=640 -p frequency:=30.0 -p depth:=1
2) I subscribe on the first machine:
ros2 topic hz image
The frequency is 30 Hz as it should be. The CPU usage of cam2image is 30%.
3) Now I subscribe on the second machine:
ros2 topic hz image
The frequency of the publisher drops to 6 Hz, as measured by subscribers on both machines. The CPU usage of cam2image drops to 17%.
I find the drop of cam2image CPU usage very counterintuitive. If the frequency drops, one would assume CPU usage would increase.
I tried switching DDS from default Fast RTPS to Cyclone DDS on the Raspberry, but it doesnt make any difference.
Do you have any update on this? We currently encountered the same issue, we did not find a solution yet.