0
$\begingroup$

Rosanswers logo

Consider having a publisher publishing at a set rate and a subscriber that calls a callback on the published topic that stores all the data in an array. Is it possible that the publisher publishes mutliple messages before the subscriber callback is called? And if that is possible and happens: Is the callback called on each new message or just on the most recent message?

If that's important here: The publishing node is a rosbag, that I didn't create myself. The subscriber node constructs an object of a class that defines all the callbacks and then calls spin().


Originally posted by max11gen on ROS Answers with karma: 164 on 2019-01-21

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

Your keyword here is the queue: how-do-publishersubscriber-message-queues-work

short version: If you publish faster than the subscriber can process (or queue) the messages, they are discarded.


Originally posted by NEngelhard with karma: 3519 on 2019-01-21

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by max11gen on 2019-01-21:
So if my Publisher and my Subscriber have a queue size of 1000 and I know that the total amount of messages published will never exceed 100, I can be sure, that my subscriber will call its callbacks on every single message, right?!

Comment by NEngelhard on 2019-01-21:
You should get all messages (but there is no guarantee), but only if your publisher's queue also is big enough. If it's so important, then you should also look at the rosbag API, so you have a much better control over what is happening.

Comment by max11gen on 2019-01-21:
Thanks a lot, i‘ll read into the rosbag API but probably „should get“ will be sufficient for me.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.