Robotics StackExchange | Archived questions

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 laser1 then laser2 then laser1 then laser2.

I would like to store laser1 until laser2 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.

Asked by Atik on 2018-02-01 08:03:55 UTC

Comments

Welcome! Have you gone through the tutorials?

Asked by jayess on 2018-02-02 04:06:41 UTC

If you really want to do this manually (instead of using pkgs like laser_assembler), then message_filters - Cache could help here.

Asked by gvdhoorn on 2018-02-02 05:12:36 UTC

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.

Asked by gvdhoorn on 2018-02-02 05:31:41 UTC

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.

Asked by Atik on 2018-02-02 07:18:35 UTC

I'm not sure I follow.

Asked by gvdhoorn on 2018-02-02 10:20:44 UTC

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?

Asked by PeteBlackerThe3rd on 2018-02-02 11:26:00 UTC

Answers