[ros-users] Get all topic messages

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: marco.cognetti@libero.it
Date:  
To: ros-users
Subject: [ros-users] Get all topic messages
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