Very low image publish rate from raspicam_node over WiFi
Hi. I'm facing a problem of very slow forwarding of sensor_msgs::ImageCompressed data between 2 devices in my local network. Sorry if answer to this question is not very ROS related, but I have no idea where the problem is.
It's the slave machine which publishes images (Raspberry Pi 3 with Ubuntu 16.04 and ROS Kinetic using Raspberry Pi Camera v1.3) and the master (my laptop with Ubuntu 16.04 and ROS Kinetic) which subscribes a /raspicam_node/image/compressed topic. Image data will be used in ORB-SLAM2 algorithm which will be executed on master machine.
The problem is that master machine receives new data with very low rates 0.5-3 Hz. I would be content with at least 10 Hz rate. Those are example listings from terminal:
rostopic hz:
average rate: 0.794
min: 0.425s max: 3.632s std dev: 0.76286s window: 19
average rate: 0.813
min: 0.425s max: 3.632s std dev: 0.75262s window: 20
average rate: 0.830
min: 0.425s max: 3.632s std dev: 0.74203s window: 21
rostopic hz:
average rate: 2.487
min: 0.133s max: 1.813s std dev: 0.22539s window: 198
average rate: 2.477
min: 0.133s max: 1.813s std dev: 0.22597s window: 199
average rate: 2.457
min: 0.133s max: 1.813s std dev: 0.22981s window: 200
average rate: 2.453
min: 0.133s max: 1.813s std dev: 0.22879s window: 202
average rate: 2.450
min: 0.133s max: 1.813s std dev: 0.22720s window: 205
rostopic bw:
average: 81.79KB/s
mean: 105.07KB min: 102.39KB max: 107.66KB window: 16
average: 77.99KB/s
mean: 105.07KB min: 102.39KB max: 107.66KB window: 16
average: 83.88KB/s
mean: 105.12KB min: 102.39KB max: 107.66KB window: 18
average: 84.87KB/s
mean: 105.23KB min: 102.39KB max: 107.66KB window: 19
I checked what will happen if I run raspicam_node separately on Raspberry Pi (made RPi master and ran raspicam_node on it) and "rostopic hz" returned 70 Hz (with desired 90 fps) or 30 Hz (with desired 30 fps - set in yaml file). I don't think that it is possible that transmitting such amount of data (640x480 pixels image) would choke bandwidth - rostopic bw shows about 85KB/s which is nothing comparing to RPi possibilities (100Mb/s if I remember correctly).
I'm using UbiquityRobotics' raspicam_node ( https://github.com/UbiquityRobotics/r... ) which uses typical publish message engine. I was trying to change it for image_transport but catkin build threw some errors and I forgot it. I followed all build instructions except network setup, which I've done before.
I also have to admit that if I run rqt_image_view the image shown in gui seems to be delayed few seconds (but I don't think that matters in this situation). I didn't calibrate camera so far too (just wrote some random numbers into .yaml file ...
Compression always takes up resources that would be otherwise used for other things. With everything running, can you check
htop
(ortop
)? If using a from-sources install, did you compile with optimisations enabled?Any difference when not using a compressed topic?
I checked
top
and noticed that raspicam_node takes no more than 15% of CPU. I installed from source but didn't compile with any optimisations. Should I?To tell if there's any difference between raw and compressed I'll have to look into code, because there is no option to switch. I'll check it.
One easy test might be to try over a wired instead of wireless network. It's possible you're just running into bandwidth limitations due to one of your wireless devices. I ran this exact test with the Pi cam and Ubiquity's package last week. For us, when wired, our rate was ~5x as fast as wireless
Of course, we wanted wireless, and we were able to use the quality private param to reduce BW requirements, and achieve our desired sub rat; image quality was still ok
I tested
https://github.com/dganbold/raspicam_node
package which provides direct possibility to publish raw images. It takes less than 3% of CPU usage but from a master point of view I get images at the rate of about 0.5 Hz (with wired connection and desired rate of 5Hz).From a slave (RPi) point of view the
/raspicam_node/image_raw
topic is published at frequency of 5 Hz (rostopic hz
) which is what I set in a launch file. It seems like it's something wrong with a master's buffer? In this moment I don't have any node that subscribes the topic (if that matters).