Subscriber callback not entered after publisher is relaunched

asked 2019-02-27 16:29:47 -0500

ROSer gravatar image

updated 2019-02-27 17:14:32 -0500

I have one publisher and one subscriber. If I launch the publisher first and then subscriber, the callback has been entered with no problem. However, if I launched the subscriber first and then publisher, the callback is not entered immediately. After more than 2 minutes' wait, the callback finally gets entered....

In my subscriber, there is a class, and the subscriber is a member variable. In the main loop, there is a while loop, with ros::spinOnce() and rate.sleep() for each iteration.

If I launched only the subscriber itself, and publish messages in command line, the subscriber works fine. But when I launched the publisher and cut it. Then the subscriber is frozen, and cannot come back to life.

edit retag flag offensive close merge delete

Comments

With the information you provided it is very difficult to tell what the problem is. Could you attach a minimal source code example that produces this effect?

Martin Peris gravatar image Martin Peris  ( 2019-02-27 22:58:43 -0500 )edit

Thanks for commenting. After I commented out all the function code and only left constructor, callback, an empty while loop, spinOnce, and sleep, the problem still happened. So I don't think it's about my code. After a reboot, the problem disappeared....

ROSer gravatar image ROSer  ( 2019-02-27 23:04:32 -0500 )edit

The behaviour is not normal and has never happened to me before. My guess is that at some point the subscriber gets in an unknown state, if you are doing it in C++, there is also the probability of some uncontrolled memory leak that may lead to random behaviours. This is why we need your code to help you. Without it, it is very difficult.

Bernat Gaston gravatar image Bernat Gaston  ( 2021-09-27 05:24:42 -0500 )edit