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 关于#java#的问题:找一份能快速看完mooc视频的代码
  • ¥15 这种微信登录授权 谁可以做啊
  • ¥15 请问我该如何添加自己的数据去运行蚁群算法代码
  • ¥20 用HslCommunication 连接欧姆龙 plc有时会连接失败。报异常为“未知错误”
  • ¥15 网络设备配置与管理这个该怎么弄
  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!