ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
2

[ROS2] topic hz provides wrong rate for larger msgs

asked 2020-04-27 07:40:42 -0500

Phgo gravatar image

updated 2020-05-06 03:48:24 -0500

While testing the ros2_intel_realsense package on ROS eloquent (Ubuntu 18.04, ROS middleware FastRTPS) I realized, that ros2 topic hz reports far lower rates for a pointcloud2 topic than an explicit C++ subscriber. The rgbd point cloud has about 5MB/frame and is published at 30Hz.

C++ subscriber:

[INFO] [pointcloud2_subscriber]: Recived 27 messages in 1.00 s (27.00 Hz)
[INFO] [pointcloud2_subscriber]: Recived 28 messages in 1.00 s (28.00 Hz)
[INFO] [pointcloud2_subscriber]: Recived 30 messages in 1.00 s (30.00 Hz)
[INFO] [pointcloud2_subscriber]: Recived 27 messages in 1.00 s (27.00 Hz)

ros2 topic hz:

average rate: 12.106
    min: 0.022s max: 0.641s std dev: 0.09745s window: 100
average rate: 11.019
    min: 0.022s max: 0.641s std dev: 0.10628s window: 100
average rate: 10.903
    min: 0.022s max: 0.641s std dev: 0.10630s window: 100
average rate: 11.917
    min: 0.022s max: 0.572s std dev: 0.09033s window: 100

This difference is quite significant. Moreover, ros2 topic hzseems to cause a considerable load on the system, so that the rate of the C++ subscriber drops from ~25Hz to ~15Hz (ros2 topic hz drops to about 8Hz in this case).

As ros2 topic hz is written in python I also tried setting PYTHONOPTIMIZE=0 as suggested here, however with no effect on the results. For comparison reasons, I tested a similar setup with ROS(1) melodic, where rostopic hz provides accurate and stable results.

Which leads me to the following questions:

  1. What could cause this significant difference of the measured rates? (related to QoS settings?)
  2. Is it possible to improve the performance of ros2 topic hz in some way?
  3. What is the recommended way of measuring rates of larger messages such as point clouds or images in ros2?
edit retag flag offensive close merge delete

Comments

1

ros2 topic hzcausing an unexpected load on the system and outputing a seemingly lower/bad rate is "known." I thought I had seen work being done on it in the past 6 months, but I can't find anything. Not sure what can be done though. It might be worth opening a bug and see what the maintainers say: https://github.com/ros2/ros2cli/issues

christophebedard gravatar image christophebedard  ( 2020-05-06 07:08:54 -0500 )edit

@christophebedard thank you very much for your reply. It is good to know, that I am not the only one facing this issue and that this is not caused by my specific setup/configuration. I will go forward and open an Issue on GitHub as you suggested.

Phgo gravatar image Phgo  ( 2020-05-06 07:33:52 -0500 )edit

Hello, the subscriber "pointcloud2", was it developed by you or does it already exist in a package? I need to subscribe to a topic to get the message rate, but without using the "ros2 topic HZ" command due to its latency.

Bruno Arieira gravatar image Bruno Arieira  ( 2020-11-16 05:04:58 -0500 )edit
1

@Bruno Arieirapointcloud2_subscriber is just a simple C++ subscriber that increments a counter whenever a new message is received with an additional timer callback that logs the number of received messages in a given time interval. It was actually very similar to the Simple Cpp Publisher and Subscriber Tutorial (which also includes a timer in the publisher) except that I additionally specified the required QoS when creating the publisher.

It was meant just as a quick comparison to topic hz. Depending on your use case you might need something more advanced (e.g. include filtering etc.)

Phgo gravatar image Phgo  ( 2020-11-17 03:03:03 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2020-06-12 06:49:38 -0500

Phgo gravatar image

After some further testing I think I finally found the reason for the considerable difference in the message rate between ros2 topic hz and my custom C++ subscriber.

As it turns out, ros2 topic hz uses Sensor data QoS profile, while I used Default QoS in my C++ Subscriber. If i change the QoS setting to match ros2 topic hz, the results are comparably low.

So this issue appears to be more related to proper choice of QoS settings and not specific to ros2 topic hz. However, it points out, that measuring message rates with ROS2 CLI might be ambiguous, as the actual rate depends on the QoS settings of the subscriber.

edit flag offensive delete link more

Comments

does changing your subscriber's QoS setting to match ros2 topic hz's QoS cause a high system load as well? Because, while they may match, a high system load (for either of them) is still not normal.

christophebedard gravatar image christophebedard  ( 2020-06-15 07:25:40 -0500 )edit

Question Tools

6 followers

Stats

Asked: 2020-04-27 07:40:42 -0500

Seen: 3,250 times

Last updated: Nov 16 '20