Merge 2 Pointcloud2s
Hi, I would like to assemble two pointcloud2 : one from a 3D Lidar and the other from a RGBD camera.
First, I thought about point_cloud2_assembler from the package laser_assembler but I don't think it does what I want. I also need that the merged pointcloud to be published more like a topic and not by a service call. Both sensors use their proper frame also. I would like to be transformed to base_link.
Does anyone know how to do that ?
Hi @TomSon, To avoid an xy-problem, can you provide more background info about what you want to achieve with that?
Hi @Weasfas, I would like to merge those two pointcloud and give it as input to rtabmap. To optimize a little, I can transform from one to another sensor to avoid 2 transforms to base_link. I could also change the pointcloud from the 3Dlidar to Laserscan but it would mean a loss of sensor data just for a input compatibility.
I understand, well, since you are dealing with pointclouds I assume you are using PCL. You can merge two pointcloud by using the
+=
operator.Also I do not know how ou are transforming the pointcloud but you can try the Eigen approach:
Hope that helps.
Thanks for your comment, that's food for thought. I didn't want to make a conversion to PCL to avoid loss in performance. I thought to use sensor_msg\pointcloud2 function and tf ones, same as laser_assembler_node.
Mmm, I do not know if the is a huge impact in the performance, as I see either you cope with the permance of pcl functions or, with the performance of STL functions. If you do not want to use PCL a solution would be using STL vector functions to concatenate vector points as well as the channels if you pointclouds have them.
I have always used all my pointcloud callbacks with PCL types and I never noticed an impact in performance:
But I will say that, it depends on you and what you think is most suitable for your implementation.
I try the same code as nodelet laserscan_to_pointcloud, I can transform to the frame but I need to concate both pointcloud on a new one and, then publish it. Useful code :)
Well, since that code is using
message_filter
I assume you will be dealing withsensor_msgs/PointCloud2
so astd::copy
of the vector points will do the trick.Thanks for the advice, I have the main structure of the code. I hope I can test it today.