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

Get all messages from topic

asked 2012-04-26 23:33:57 -0500

Neostek gravatar image

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.

Thanks a lot for any answering,


edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2012-04-27 01:14:53 -0500

Neostek gravatar image

The point is that I publish on this topic different type of data and I want to store in memory the last X ones since I want to read them only with a certain frequency. I think the best solution is to modify my callback function in such a way it stores data with a simple array. Thanks a lot for your reply!

edit flag offensive delete link more

answered 2012-04-27 01:03:55 -0500

Thomas gravatar image

updated 2012-04-27 01:04:26 -0500

AFAIK there is no direct way.

It may be possible if you can reimplement your own callback queue although. Or play with the existing callback queueus to do that but it will not be straight-forward. See rocpp API for more information

[My impression is that you try to rebuild a communication protocol over the ROS topics. I.e. sending messages in small chunks you reassemble at the end. If this is the case, I highly recommend that you _avoid doing_ that. ROS topics are not designed to work that way. Just send one big message containing all the information you want to transmit. ROS will then do the hard work for you.]

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2012-04-26 23:33:57 -0500

Seen: 1,438 times

Last updated: Apr 27 '12