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

Flush subscription

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

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
4

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

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
2

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

Gayan Brahmanage gravatar image

updated 2017-07-13 13:42:42 -0600

Set subscriber queue_size to one

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

Comments

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 image gvdhoorn  ( 2017-07-14 05:52:18 -0600 )edit

Question Tools

Stats

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

Seen: 2,775 times

Last updated: Jul 13 '17