Having problem converting sensor_msgs:: Pointcloud2 to pcl

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

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
     pcl::fromPCLPointCloud2(cloud2,cloud);

}

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

Comments

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 imagejayess ( 2019-06-14 00:24:04 -0500 )edit

Otherwise, there's this tutorial too

jayess gravatar imagejayess ( 2019-06-14 00:28:27 -0500 )edit
1
pcl::fromPCLPointCloud2(cloud2,cloud);

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

pcl_conversions::toPCL(..)
gvdhoorn gravatar imagegvdhoorn ( 2019-06-14 02:04:41 -0500 )edit