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

Queue full: chose drop actions?

asked 2023-07-08 04:52:47 -0500

JoshE gravatar image

Is it possible to decide what action should be taken when the queue size of a publisher or subscriber is reached? e.g. to let the newest message drop instead of the oldest, or to not drop anything at all,...?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2023-07-11 03:26:57 -0500

bluegiraffe-sc gravatar image

Hi!

To the best of my knowledge, and as confirmed by rospy and rosccp documentation, there is no option to do such a thing. As for the not to drop anything at all part, you can try to achieve such a behavior by increasing a lot your queue, though I would not advise you to do so.

Alternatively, you could implement your own queue. E.g. in Python you could use the queue library to implement your own queueing method. The idea would be to have a subscriber that just receives the message (maybe unpacks it), and adds it to the queue. You can check if the queue is full via the Queue.full() method, and, for example, decide to discard the newest instead of the older message. Be aware that this will work smoothly if and only if the operations described above are faster than the rate at which messages are sent to the subscriber.

Then, you will have a forever loop in your node that looks into your queue, selects the message to process (based on your preferred criteria), and do your awesome stuff!

TL;DR: such option(s) do not exist, but you can implement your own logic to achieve the same result!

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2023-07-08 04:52:47 -0500

Seen: 65 times

Last updated: Jul 11 '23