c++ - 使用 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);
解决方案
我解决了这个问题;我应该将消息类型转换为正确的格式。这个答案 对我帮助很大。
推荐阅读
- php - PHP / CSS:左右站点的聊天功能不会以正确的格式
- python - Eclipse 没有正确编码字符
- excel - 在VBA中将行从工作表复制和删除到多个工作表
- python-3.x - 2to3.6:python转换挂起
- r - 四象限图,R中的4个不同变量
- typescript - How to get keyof individual item in a generic array?
- visual-studio-code - VSCode 终端中的 PHP 版本/可执行文件错误,但在 Mac 终端中完美运行
- alexa - Alexa Direct Skill Connection 触发 Apple Music?
- terraform - Terraform 为每个计数资源迭代地图
- discord - 如何让我的不和谐机器人从短语列表中选择一条消息,然后从该列表中随机选择一个短语发送给特定用户?