How can I recieve two sequential messages from the same publisher before processing the data?

asked 2018-02-01 07:03:55 -0500

Atik gravatar image

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.

edit retag flag offensive close merge delete

Comments

Welcome! Have you gone through the tutorials?

jayess gravatar image jayess  ( 2018-02-02 03:06:41 -0500 )edit

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

gvdhoorn gravatar image gvdhoorn  ( 2018-02-02 04:12:36 -0500 )edit

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.

gvdhoorn gravatar image gvdhoorn  ( 2018-02-02 04:31:41 -0500 )edit

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.

Atik gravatar image Atik  ( 2018-02-02 06:18:35 -0500 )edit

I'm not sure I follow.

gvdhoorn gravatar image gvdhoorn  ( 2018-02-02 09:20:44 -0500 )edit

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?

PeteBlackerThe3rd gravatar image PeteBlackerThe3rd  ( 2018-02-02 10:26:00 -0500 )edit