Here is a simple C++ replacement for `ros2 topic hz`.
It is more accurate than the native ros2 command for high frequency / high bandwidth topics. It should work for any RMW (though I tested it for Zenoh only).
After building the workspace, run it like this:
ros2 run ros2topic_hz ros2topic_hz --topic <topic_name> [--topic-type <topic_type>] [--interval ]
4 Likes
Is there any reason we couldn’t/shouldn’t just call this from the ros2 topic hz Python implementation? Using subprocess or whatever. I can’t think of any.
2 Likes
Yeah, it may make sense to just gut the hz implementation in favor of something like this. I think it’s been spitballed before but never actually written down in a “we should do this” format somewhere.
1 Like
I like the idea of having an implementation like this in the core that just works correctly instead of having to tell some of my more junior coworkers “don’t use ros2 topic hz, measure some other more accurate way”.
Having had a quick glance at the code, there are also potentially some latency improvements to be had by using the new events executor instead of rclcpp::spin()