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

Rate time of ROS code

asked 2018-02-23 06:08:07 -0500

JuanTelo gravatar image

updated 2018-02-23 06:17:40 -0500

Hi, is there a way to see how much time my code is taking to run? I don't mean elapsed time but the rate it is working. For example, I have three topics being published and one subscriber and I want to know how the rate at which they are being published.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2018-02-23 06:14:11 -0500

You can use rqt_graph to find out the frequency at which messages are being published to your topics. First enable statistics with the following command:

rosparam set enable_statistics true

Then execute rqt_graph as described here.

I'm not quite sure what time you're trying to measure when you say "how much time it takes for the topics to be published" if you don't mean elapsed time. can you clarify this.

edit flag offensive delete link more


You're right, sorry for not being clear in the question, I've edited and will try your answer

JuanTelo gravatar image JuanTelo  ( 2018-02-23 06:18:08 -0500 )edit

Should I write that command in the command line? while rqt is open? because I tried it and still the same, nothing has appeared

JuanTelo gravatar image JuanTelo  ( 2018-02-23 06:19:16 -0500 )edit

While your code is running open a new terminal and enter the first command I described. Then on the next line start rqt_graph. This should show a graph of all the nodes, which topics they're publishing and the frequency at which they're being published.

PeteBlackerThe3rd gravatar image PeteBlackerThe3rd  ( 2018-02-23 13:46:38 -0500 )edit

answered 2018-02-23 07:05:06 -0500

Delb gravatar image

updated 2018-02-23 07:07:09 -0500

Just run all your topics and then execute rostopic hz /topic_name. You can also have multiple topics at the same time : rostopic hz /topic_0 /topic_1 /topic_2

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2018-02-23 06:08:07 -0500

Seen: 571 times

Last updated: Feb 23 '18