Ask Your Question

Flush subscription

asked 2012-06-24 06:54:52 -0500

Saphrosit gravatar image

I have a Ros::Subscriber that receives messages from a topic. Since I'm doing some computations on the data I receive (and it requires some time), the delay with which I read new messages tend to increase.

Is there a way to "flush" all the unread messages in a topic so that I can read directly the newest one? (I'm using electric on ubuntu 11.10)

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2012-06-24 07:06:47 -0500

Lorenz gravatar image

If you set the buffer size to 1 in the call to subscribe, you drop all but the newest message.

edit flag offensive delete link more

answered 2017-07-13 13:42:05 -0500

Gayan Brahmanage gravatar image

updated 2017-07-13 13:42:42 -0500

Set subscriber queue_size to one

rospy.Subscriber("/scan", LaserScan, scanCb,queue_size = 1)
edit flag offensive delete link more


I admire your enthousiasm, but it would seem your answer is a duplicate of the answer by @Lorenz. Did you feel something was not clear enough in his answer?

gvdhoorn gravatar imagegvdhoorn ( 2017-07-14 05:52:18 -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


Asked: 2012-06-24 06:54:52 -0500

Seen: 1,351 times

Last updated: Jul 13 '17