vickyTwan 2023-04-03 10:26 采纳率: 60%
浏览 20
已结题

编写点云代码出错 using ptr=pcl

error: ‘using Ptr = pcl::shared_ptr<pcl::PointCloud<velodyne_pointcloud::PointXYZIR> >’ {aka ‘class boost::shared_ptr<pcl::PointCloud<velodyne_pointcloud::PointXYZIR> >’} has no member named ‘push_back’
  222 |                     plane.push_back(point1);
      |                           ^~~~~~~~~


代码如下

void PlaneGroundFilter::devide_plane(const pcl::PointCloud<VPoint> &p_sorted,double& x_boundary,
 pcl::PointCloud<VPoint>::Ptr plane,
 pcl::PointCloud<VPoint>::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);
                }
            }
 }

  • 写回答

2条回答 默认 最新

  • Leodong. 2023-04-03 10:32
    关注

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

    报错信息显示,plane和slope_plane都是pcl::PointCloud<VPoint>::Ptr类型的智能指针,而不是直接的PointCloud对象,因此不能使用push_back方法。正确的方法是使用pcl::PointCloud<VPoint>的push_back方法。
    

    具体修改后的代码如下所示:

    void PlaneGroundFilter::devide_plane(const pcl::PointCloud<VPoint> &p_sorted,double& x_boundary,
     pcl::PointCloud<VPoint>::Ptr plane,
     pcl::PointCloud<VPoint>::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){
                        VPoint point1;
                        point1.x = x;
                        point1.y = y;
                        point1.z = z;
                        plane->push_back(point1);
                    }
                    else{
                        VPoint point2;
                        point2.x = x;
                        point2.y = y;
                        point2.z = z;
                        slope_plane->push_back(point2);
                    }
                }
     }
    

    在上面的代码中,我们使用了plane->push_back和slope_plane->push_back方法来添加点到PointCloud对象中。另外,我们还将pcl::PointXYZ改为了VPoint,这是因为在函数参数中传入的点云类型为VPoint,而不是pcl::PointXYZ。


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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

问题事件

  • 系统已结题 4月11日
  • 已采纳回答 4月3日
  • 创建了问题 4月3日

悬赏问题

  • ¥15 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)
  • ¥15 Windows11, backspace, enter, space键失灵