How can I recieve two sequential messages from the same publisher before processing the data?
I have a topic which publishes data from two laser scanners. So the data that I receive is first laser_1 then laser_2 then laser_1 then laser_2.
I would like to store laser_1 until laser_2 is receive where i want to transform the two scans into point clouds and then combine them. I cannot however find a good way to store the first scan. I have been thinking about a queue and when it reaches two elements i can compute but as I am kinda new to ROS I am unaware of any solutions.
Welcome! Have you gone through the tutorials?
If you really want to do this manually (instead of using pkgs like laser_assembler), then message_filters - Cache could help here.
Btw: is this an xy-problem? @Atik: from your question text it would seem you're actually interested in combining laser scans. Not necessarily how to "recieve two sequential messages from the same publisher before processing the data".
I suggest a title fix.
The laser scans come from the same publisher but not from the scanner. So I need some way to collect them in sequence and then combine them into one on the base_link frame.
I'm not sure I follow.
Are you saying that laser scans from two different sensors are being interleaved onto the same topic? Wouldn't it be better to publish them on different topics?