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

What exactly does ros2 topic hz display

asked 2022-10-11 07:05:42 -0600

Zeckurbo gravatar image

updated 2022-10-12 01:35:45 -0600


I made some measurements with ros2 topic hz and ros2 topic bw.

I saw, that bw seems to keep on increasing its data source pool forn its measurements (later output has more messages as input) because it prints MB/s from 18 messages, where the number gets bigger over time.

On the other side, when I change the frequency, hz does not instantly increases its rate, but the average only goes up over time, so I was wondering, if hz also just gathers input data and uses all of it for its output, or only 1 window?

Also why is the deviation in s (not in Hz as I would expect it for a rate dev)?

TLDR Is the last output of hz the best estimation, or do I have to calculate the mean from all outputs myself? Is the standard deviation related to the rate? What does it display?


I thought about it, and maybe min, max and std dev are for the intervals between messages. So the dev is not the one of the rate, but maybe the one of the intervals? Is there a way to get the dev of the rate directly?


edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2022-10-13 02:49:13 -0600

Zeckurbo gravatar image

I found the code under /opt/ros/foxy/lib/python3.8/site-packages/ros2topic/verb/

In the method get_hz() the calculation is as follows:

n = Window = number of message intervals for calculation
mean rate = 1/ mean of intervals between 2 received messages (of all n intervals in the window)
min/ max = min / max interval

Now that I think about it, it is logical that one can not measure the rate directly, but only the intervals between 2 messages. So the standard deviation is only for the intervals (so in seconds), not for the rate (in Hz)!

Also the bigger the window count, the more data was used

edit flag offensive delete link more

answered 2022-10-11 10:22:01 -0600

duck-development gravatar image

The output is in seconds because it it is a SI unit . The output window is the number of samples used for the computing of all statistics parameters. The longer ros2 topic hz runs the more it represent the values

edit flag offensive delete link more


Thanks for your answer. What I dont understand is, why is the rate in Hz (1/s) but the std dev is in s (not Hz). Does it mean, that this deviation is not the one of the measured rate?

Zeckurbo gravatar image Zeckurbo  ( 2022-10-12 01:32:28 -0600 )edit

It has to be in seconds because it deviates around the mean hz period time plus and minus. If you have a 1hz signal then 0.5s stdvdev means you signal around 0.5hz and 1.5hz but the mean is 1hz

And low std div would result in big hz values and misslead.

duck-development gravatar image duck-development  ( 2022-10-12 12:24:12 -0600 )edit

Question Tools



Asked: 2022-10-11 07:05:42 -0600

Seen: 1,430 times

Last updated: Oct 13 '22