0
votes

I am trying to use PCL with ROS to estimated the surface normal of published point cloud form gazebo simulator; this is my callback function however, I got the following errors. Could you please help..

I followed the PCL tutorial for normal estimation and it works fine to me.

void     cloud_cb (const sensor_msgs::PointCloud2ConstPtr& cloud_msg)
    { 
 // Container for original & filtered data
 pcl::PCLPointCloud2* cloud = new pcl::PCLPointCloud2; 
 pcl::PCLPointCloud2ConstPtr cloudPtr(cloud);    
//  pcl::PCLPointCloud2 cloud_filtered;


 // Convert to PCL data type
 pcl_conversions::toPCL(*cloud_msg, *cloud);



 // Create the normal estimation class, and pass the input dataset to 
 pcl::NormalEstimation<pcl::PointXYZ, pcl::Normal> ne;
 ne.setInputCloud (cloud);


// Create an empty kdtree representation, and pass it to the normal  estimation object.
 // Its content will be filled inside the object, based on the given input dataset (as no other search surface is given).
 pcl::search::KdTree<pcl::PointXYZ>::Ptr tree (new pcl::search::KdTree<pcl::PointXYZ> ());
 ne.setSearchMethod (tree);

 // Output datasets
 pcl::PointCloud<pcl::Normal>::Ptr cloud_normals (new pcl::PointCloud<pcl::Normal>);

 // Use all neighbors in a sphere of radius 3cm
 ne.setRadiusSearch (0.03);

 // Compute the features
 ne.compute (*cloud_normals);


 // cloud_normals->points.size () should have the same size as the input cloud->points.size ()*
 // visualize normals
 pcl::visualization::PCLVisualizer viewer("PCL Viewer");
 viewer.setBackgroundColor (0.0, 0.0, 0.5);
 viewer.addPointCloudNormals<pcl::PointXYZ,pcl::Normal>(cloud, cloud_normals);

 while (!viewer.wasStopped ())  // THE ORGINAL !viewer.wasStopped () 
         {
           viewer.spinOnce ();
         }







 // Convert to ROS data type
 sensor_msgs::PointCloud2 output;
 pcl_conversions::moveFromPCL(cloud, output);





 // Publish the data.
 pub.publish (output);    }

error: no matching function for call to ‘pcl::NormalEstimation::setInputCloud(pcl::PCLPointCloud2*&)’ ne.setInputCloud (cloud);

error: no matching function for call to ‘pcl::visualization::PCLVisualizer::addPointCloudNormals(pcl::PCLPointCloud2*&, pcl::PointCloud::Ptr&)’ viewer.addPointCloudNormals(cloud, cloud_normals);

error: wrong number of template arguments (2, should be 1) viewer.addPointCloudNormals(cloud, cloud_normals); ^

error: no matching function for call to ‘moveFromPCL(pcl::PCLPointCloud2*&, sensor_msgs::PointCloud2&)’ pcl_conversions::moveFromPCL(cloud, output);

1
It has been a long time since I used ROS, but I think you should also turn to the ROS community for the ROS related questions.Fareanor

1 Answers

0
votes

I solved the problem; I should convert the message type to the correct format. this answer helped me a lot.