首页 > 解决方案 > 使用 PCL 的 ROS 表面法线估计

问题描述

我正在尝试使用带有 ROS 的 PCL 来估计已发布的点云形式凉亭模拟器的表面法线;这是我的回调函数,但是,我收到了以下错误。能否请你帮忙..

我按照 PCL 教程进行正常估计,它对我来说很好。

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);    }

错误:没有匹配函数调用 'pcl::NormalEstimation::setInputCloud(pcl::PCLPointCloud2*&)' ne.setInputCloud (cloud);

错误:没有用于调用 'pcl::visualization::PCLVisualizer::addPointCloudNormals(pcl::PCLPointCloud2*&, pcl::PointCloud::Ptr&)' viewer.addPointCloudNormals(cloud, cloud_normals) 的匹配函数;

错误:模板参数的数量错误(2,应该是 1) viewer.addPointCloudNormals(cloud, cloud_normals); ^

错误:没有匹配函数调用'moveFromPCL(pcl::PCLPointCloud2*&, sensor_msgs::PointCloud2&)' pcl_conversions::moveFromPCL(cloud, output);

标签: c++ros

解决方案


我解决了这个问题;我应该将消息类型转换为正确的格式。这个答案 对我帮助很大。


推荐阅读