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

how to monitor topic, when a certain topic not exist?

asked 2016-10-28 07:59:15 -0500

jxl gravatar image


I want to do a such thing : To monitor a topic . When everything is OK, a certain topic is always published by node A at a rate. when something wrong ,the node A is died,and the topic does not exist .At this time ,how can i know this topic exist or not ?

Does ROS has such API to monitor a topic ,when it does not exist ,notify me and i can use this signal to do something i want.

Any suggestions will be appreciated ,thank you very much !!!

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted

answered 2016-10-31 17:43:43 -0500

NEngelhard gravatar image

The subscriber knows to how many publishers it is connected to: getNumPublishers Or you use rospy to directly get a list of published topics: get_published_topics.

edit flag offensive delete link more


Wow! I learn something new every day! Sorry about giving a completely wrong answer!

Kurt Leucht gravatar image Kurt Leucht  ( 2016-11-01 08:56:30 -0500 )edit

Thanks a lot ~~

jxl gravatar image jxl  ( 2016-11-09 02:34:55 -0500 )edit

answered 2016-10-31 12:43:27 -0500

ROS is designed, as far as I know, to not care whether Topics exist or not. ROS will let Subscribers sit all day waiting for data on non-existant Topics.

One solution is to set up a watchdog style timer that looks for data on the topic and lets you know if a certain period of time occurs without any new data coming in.

edit flag offensive delete link more


The messages are sent via TCP so that there is an open connection to every publisher. The subscriber therefore has to know who is currently publishing.

NEngelhard gravatar image NEngelhard  ( 2016-11-01 13:10:11 -0500 )edit

Question Tools



Asked: 2016-10-28 07:59:15 -0500

Seen: 1,094 times

Last updated: Oct 31 '16