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

check if topic is being published to without subscribing

asked 2019-01-29 11:12:20 -0600

bearot gravatar image

updated 2019-01-30 08:54:15 -0600

gvdhoorn gravatar image

In our project we want to write a node to check sensor nodes for possible errors. One of the checked criterion is, if the topics of the node are actually published and not just have publisher.

Is it possible to check for published messages or publishing frequency without actually subscribing? The reason behind it is, that some sensors like cameras publishes large amount of data, which slow down the checknode.

Not suitable solutions:

  • "rospy.get_published_topics" does not check, if the publisher is publishing at all.
  • rostopic hz subscribes the topic
  • time saving solutions require subscription at some point

Thank you.


I'm not sure (hence a comment), but there is a chance you could do this using topic statistics.

by gvdhoorn

This is our solution. Thanks.

edit retag flag offensive close merge delete


It is correct that there are already subscribers to the topics. We want to check on a running system.

Thank you for your answer gvdhoorn. It is definitly new to us and what we searched for. I will post it as answer and mark it as correct.

bearot gravatar image bearot  ( 2019-01-30 06:44:35 -0600 )edit

2 Answers

Sort by ยป oldest newest most voted

answered 2019-01-29 11:21:36 -0600

gvdhoorn gravatar image

I'm not sure (hence a comment), but there is a chance you could do this using topic statistics.

edit flag offensive delete link more


topic statistics are still per-connection, so if there are no subscribers, there will not be any statistics.

ahendrix gravatar image ahendrix  ( 2019-01-29 12:02:17 -0600 )edit

If there are no subscribers, it doesn't make sense to want to check for "publishing frequency" anyway :)

I assumed (perhaps wrongly) that the OP had subscribers, but didn't want to add more just to check node liveness.

gvdhoorn gravatar image gvdhoorn  ( 2019-01-30 08:55:08 -0600 )edit

answered 2019-01-29 12:06:10 -0600

ahendrix gravatar image

All of the software that I've worked on does sensor health reporting with the diagnostic_updater library. It includes built-in functions to measuring and reporting the topic publish frequency, and reporting diagnostic errors if the publish frequency is too high or too low. It also provides a framework for reporting any other problems you might want to detect.

The only downside is that you must modify your nodes to use it; but generally the modifications are quite easy. Many of the mature ROS camera and laser drivers already incorporate diagnostics like this.

edit flag offensive delete link more


Thank you for your answer, but it does not work out for us. Not every sensor node is written by us and some are missing diagnostic_updater, but it may be a solution for others.

bearot gravatar image bearot  ( 2019-01-30 06:51:14 -0600 )edit

@bearot: did you find a solution or a hack for your problem?

TinyTurtle gravatar image TinyTurtle  ( 2022-11-08 08:18:01 -0600 )edit

Question Tools


Asked: 2019-01-29 11:12:20 -0600

Seen: 2,499 times

Last updated: Jan 30 '19