当前位置: 首页 > news >正文

ros的pcl库中对于自己定义的消息,调用pcl库时总是报错 c++

首先定义自己的消息类型

struct CustomPoint { // 定义点类型结构PCL_ADD_POINT4D; // 该点类型有4个元素float intensity = 0.0;uint32_t zone;uint32_t ring;uint32_t sector;EIGEN_MAKE_ALIGNED_OPERATOR_NEW // 确保new操作符对齐操作
} EIGEN_ALIGN16; // 强制SSE对齐POINT_CLOUD_REGISTER_POINT_STRUCT( // 注册点类型宏CustomPoint,(float, x, x)(float, y, y)(float, z, z)(float, intensity, intensity)(uint32_t, zone, zone)(uint32_t, ring, ring)(uint32_t, sector, sector)
)// typedef pcl::PointXYZI VPoint;
typedef CustomPoint VPoint;
typedef pcl::PointCloud<VPoint> VPointType;

在定义完自己的消息类型之后,调用pcl::removeNaNFromPointCloud等自带的函数时会报错:

(.text+0x14631): undefined reference to `pcl::PCLBase<CustomPoint>::PCLBase(
cl::removeNaNFromPointCloud<CustomPoint>(pcl::PointCloud<CustomPoint> const&, pcl::PointCloud<CustomPoint>&, std::vector<int, std::allocator<int> >&)'
collect2: error: ld returned 1 exit status

代码如下:

 void PatchWorkpp::pointcloud_callback(const sensor_msgs::PointCloud2::ConstPtr &input){VPointType::Ptr cloud_in = boost::make_shared<VPointType>();VPointType::Ptr src_cloud(new VPointType);pcl::fromROSMsg(*input, *cloud_in);std::vector<int> mapping;pcl::removeNaNFromPointCloud(*cloud_in, *cloud_in, mapping); // 必须要移除NAN点}

此时需要添加头文件如下:

#include <pcl/impl/pcl_base.hpp>
#include <pcl/filters/impl/crop_box.hpp> 
#include <pcl/filters/impl/filter.hpp>
#include <pcl/kdtree/impl/kdtree_flann.hpp>
#include <pcl/search/impl/organized.hpp>
#include <pcl/surface/impl/convex_hull.hpp>

参考文章:
https://blog.csdn.net/qq_43427457/article/details/125052803

http://www.lryc.cn/news/353267.html

相关文章:

  • DataFrame—数据汇总6
  • Java入门基础学习笔记41——实体类
  • 【Linux】信号之信号的保存和处理详解
  • 基于Django的图书管理系统
  • js实现元素根据鼠标滚轮滚动向左右上下滑动着从模糊到清楚显示出来
  • yocto学习
  • 【IC设计】牛客网-序列检测习题总结
  • python爬虫登录到海康相机管理页面
  • 9.Docker网络
  • Windows VS2022 C语言使用 sqlite3.dll 访问 SQLite数据库
  • java库和包的概念
  • mysql内存结构
  • Python | Leetcode Python题解之第111题二叉树的最小深度
  • c++二进制输出
  • 5. C++网络编程-UDP协议的实现
  • Altium Designer 中键拖动,滚轮缩放,并修改缩放速度
  • python从入门到精通04
  • tomcat三级指导
  • 不知道是该怎么引用多个函数片段?具体示例如代码
  • P3128 [USACO15DEC] Max Flow P题解(树上差分,最近公共祖先,图论)
  • 在Linux上面部署ELK
  • Langchain-Chatchat的markdownHeaderTextSplitter使用
  • 掩码生成蒸馏——知识蒸馏
  • 【C#实战】Newtonsoft.Json基类子类解析
  • 表达式求值的相关语法知识(C语言)
  • 开发中遇到Electron自定义窗口的问题
  • c# sqlite使用
  • 39、Flink 的窗口剔除器(Evictors)详解
  • Flutter 中的 DefaultTabController 小部件:全面指南
  • C++技能进阶指南——多态语法剖析