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

Clearing all messages on a topic

asked 2013-07-01 05:15:24 -0500

jnj11 gravatar image

updated 2013-11-14 12:32:55 -0500

tfoote gravatar image

I have been reading about the callback queue in roscpp but, I have not found the information I am looking for. I would like to know if there is a way to remove all messages in the callback queue.

As an example: I have a subscriberNode that subscribes to topicFoo and topicInterrupt

5 messages were published to topicFoo from publisherNode.

After the first topicFoo message is processed in topicFooCallback, a topicInterrupt message is published and processed. At this point, I would like all messages in the topicFooCallback to be removed.

Is there a way to do this? Please let me know if any of this is unclear.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2013-07-01 11:44:49 -0500

thebyohazard gravatar image

Interesting question. I didn't see anything in the API that looked like it would do what you want. However, I would think re-initializing your subscriber would clear the queue. Maybe there's a better alternative we could help you figure out if you can tell us what you want to do.

edit flag offensive delete link more

Comments

You can also simply momentarily set the callback to do nothing so that you can drain them very quickly until it's empty. It's not atomic, but you're downstream of an asyncronous link so that isn't any worse.

tfoote gravatar image tfoote  ( 2013-08-12 10:44:03 -0500 )edit

how about if you have a latched publisher that has already published a few messages and you want to cancel/delete those messages not to fall into any subscriber's callback?

azerila gravatar image azerila  ( 2020-08-17 16:16:03 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2013-07-01 05:15:24 -0500

Seen: 5,764 times

Last updated: Jul 01 '13