Ask Your Question
1

Is there a way to know how many messages are left in a Subscriber's queue, or if it is empty?

asked 2020-11-14 15:37:23 -0500

JoseAB10 gravatar image

I've been digging in the documentation, source code and googling in general and can't seem to find an answer to this. I'm currently experimenting with mapping algorithms and have to run several experiments on the same data due to random sampling. For that purpose, I've created some ROSBags that, after all the important movement and sensor messages have been sent, sends a Bool message to signal the end of the simulation. Most of my nodes shutdown after receiving this message so that everything is reset for the next experiment. (I've created a wrapper for roslaunch that shuts down after the critical nodes are dead). The thing is, one of the nodes might still have some messages in the queue to be handled by the callbacks, and I would like for it to shut down only after the queue is empty.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2020-11-16 09:54:32 -0500

miura gravatar image

ros::getGlobalCallbackQueue()->isEmpty() is true, then the queue appears to be empty.

edit flag offensive delete link more

Comments

1

Thanks miura for your answer. Since I'm calling it from within a callback function, isEmpty() never seems to return true due to the protected calling_ attribute being different than 0. I'll have to re-think my class. Probably implement my own custom spin.

JoseAB10 gravatar image JoseAB10  ( 2020-11-25 05:58:48 -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

Stats

Asked: 2020-11-14 15:35:14 -0500

Seen: 233 times

Last updated: Nov 16 '20