编写点云代码报错 nodeclaration matches


error: no declaration matches ‘void PlaneGroundFilter::devide_plane(const pcl::PointCloud&, double&, pcl::PointCloud::Ptr, pcl::PointCloud::Ptr)’
  208 |  void PlaneGroundFilter::devide_plane(const pcl::PointCloud &p_sorted,double& x_boundary,
      |       ^~~~~~~~~~~~~~~~~

此段代码如下

void PlaneGroundFilter::devide_plane(const pcl::PointCloud &p_sorted,double& x_boundary,
                    pcl::PointCloud::Ptr plane,
                    pcl::PointCloud::Ptr slope_plane)
    {
            for (int i = 0; i < p_sorted.points.size(); i++){
                int x = p_sorted_points[i].x;
                int y = p_sorted_points[i].y;
                int z = p_sorted_points[i].z;
                if (x < x_boundary){
                    pcl::PointXYZ point1;
                    point1.x = x;
                    point1.y = y;
                    point1.z = z;
                    plane.push_back(point1);
                }
                else{
                    pcl::PointXYZ point2;
                    point2.x = x;
                    point2.y = y;
                    point2.z = z;
                    slope_plane.push_back(point2);
                }
            }
 }

该回答通过自己思路及引用到各个渠道搜索综合及思考,得到内容具体如下:

错误信息提示没有与函数调用中提供的参数匹配的函数`devide_plane`的声明或定义。
查看提供的函数定义,可能会有几个问题导致这个错误:

1. 函数名拼写错误。应该是`divide_plane`而不是`devide_plane`。
2. 在函数定义中,输入点云的参数类型为`pcl::PointCloud<VPoint>`,但错误信息显示函数调用使用的是`pcl::PointCloud<velodyne_pointcloud::PointXYZIR>`。请确保类型匹配。
3. 在函数定义中,输出点云的参数类型为`pcl::PointCloud<VPoint>::Ptr`,但错误信息显示函数调用使用的是`pcl::PointCloud<velodyne_pointcloud::PointXYZIR>::Ptr`。再次确保类型匹配。

要解决这个错误,您应该检查函数调用以确保参数类型与函数定义匹配。如果类型正确,则可能需要检查函数的声明或定义以确保与使用的参数匹配。

修改后的代码如下:

void PlaneGroundFilter::divide_plane(const pcl::PointCloud<velodyne_pointcloud::PointXYZIR>& p_sorted, double& x_boundary,
    pcl::PointCloud<velodyne_pointcloud::PointXYZIR>::Ptr plane,
    pcl::PointCloud<velodyne_pointcloud::PointXYZIR>::Ptr slope_plane)
{
    for (int i = 0; i < p_sorted.points.size(); i++) {
        int x = p_sorted.points[i].x;
        int y = p_sorted.points[i].y;
        int z = p_sorted.points[i].z;
        if (x < x_boundary) {
            velodyne_pointcloud::PointXYZIR point1;
            point1.x = x;
            point1.y = y;
            point1.z = z;
            plane->push_back(point1);
        }
        else {
            velodyne_pointcloud::PointXYZIR point2;
            point2.x = x;
            point2.y = y;
            point2.z = z;
            slope_plane->push_back(point2);
        }
    }
}

如果以上回答对您有所帮助,点击一下采纳该答案~谢谢