Ask Your Question
1

How to notify from publisher to subscriber before stopping publishing data.

asked 2017-06-02 12:29:57 -0500

can-43811 gravatar image

How to know from subscriber's end that publisher stopped the publishing data. in my subscriber code i am performing clean up operations and would like to know if publisher stopped publishing the data.Here i am publishing the data based on topic not a service so how to create link or notification between publisher and subscriber in case publisher stopped publishing data. Usually if publisher node is not publishing the data then subscriber node callback itself won't be called.

edit retag flag offensive close merge delete

Comments

Can you confirm whether you are actually trying to determine whether publishers are still on-line (ie: not terminated), instead of just publishing messages?

gvdhoorn gravatar image gvdhoorn  ( 2017-06-03 01:08:44 -0500 )edit

if publisher are alive and publishing the data , in this case i don't want any bookkeeping.. i just wanted to know from subscriber's end if publisher got stopped due to crash or ctrl+c operation and not publishing anything.

can-43811 gravatar image can-43811  ( 2017-06-03 02:33:51 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2017-06-02 12:41:43 -0500

NEngelhard gravatar image

updated 2017-06-03 01:18:08 -0500

There is get_num_connections which is the number of publishers for a subscriber. So if the last connection is terminated (e.g. by shutting down the publisher or the publishing node), this value is going to be zero.

Edit: For cpp, have a look the docu of the Subscriber class and find getNumPublishers

edit flag offensive delete link more

Comments

Thanks but it looks like python API and my subscriber code is written in roscpp. i am asking this question cpp context only. Does ros provide any external API interface through which we can call python API directly in roscpp node. As per my observation most of things are available in python only.

can-43811 gravatar image can-43811  ( 2017-06-02 20:16:37 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2017-06-02 12:29:57 -0500

Seen: 387 times

Last updated: Jun 03 '17