Having problem converting sensor_msgs:: Pointcloud2 to pcl

asked 2019-06-13 22:00:58 -0600

yuri_chen1995 gravatar image

Hello my friend,

I am trying to put point clouds gathered from Gazebo into PCL. The data format gathered from Block Laser is sensor_msgs::PointCloud, and I have managed to convert it to sensor_msgs::PointCloud2, but having problem convert it further into PCL Point cloud. My code is:

void scanCallback(const sensor_msgs::PointCloud scan)
    pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>);
    sensor_msgs::PointCloud2 cloud2;
    sensor_msgs::convertPointCloudToPointCloud2(scan, cloud2); //point_cloud - msg::pt2


where the last line complains an error which:

 error: no matching function for call to ‘fromPCLPointCloud2(sensor_msgs::PointCloud2&, pcl::PointCloud<pcl::PointXYZ>::Ptr&)

I have been struggling on this for quite a while, hopefully someone could very kindly point out the problem, cheers!

edit retag flag offensive close merge delete


Is this from a tutorial or documentation? If so, can you please post a link to it? It seems like it may be old (I don't know though, I don't have experience with PCL). Have you seen this post?

jayess gravatar image jayess  ( 2019-06-14 00:24:04 -0600 )edit

Otherwise, there's this tutorial too

jayess gravatar image jayess  ( 2019-06-14 00:28:27 -0600 )edit

If you want to go from sensor_msgs/PointCloud2 to a PCL Pointcloud (ie: native type), then I believe you'd use:

gvdhoorn gravatar image gvdhoorn  ( 2019-06-14 02:04:41 -0600 )edit