[ros-users] Get all topic messages

marco.cognetti at libero.it marco.cognetti at libero.it
Fri Apr 27 10:24:20 UTC 2012


Hi all, 
it is a simple question but I see that there is no topic on it. I have a topic 
on which a publisher is publishing data (string) with a queue of 10 messages.

On the other side, I want to subscribe it through a subscriber (with queue 5). 
Is there a way to get all messages (or at least the first 5) published on this 
topic? I tried with a callback function of the subscriber taking a vector with 
no results.
I succeed to do it saving a vector and using the push_back function whenever 
the callback is invoked. I don't like so much this solution since if other 
methods invokes the spinOnce then the same data are saved on the vector....is 
there a smarter way?

Thanks a lot for any answer,

Neostek



More information about the ros-users mailing list