ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

PCL自定义点云类型以及出现无法解析的外部依赖项问题

2021-02-16 23:58:58  阅读:724  来源: 互联网

标签:PointXYZT 自定义 NO PRECOMPILE PCL time 点云 gps


自定义点云类型并在PCL中进行使用

定义点云类型

  自定义点云类型很简单,也有很多博客介绍了。这里介绍一种自定义的点云类型,每个点附加了一个 时间,存储于double变量中,如下:

//Point Type: x/y/z/GPS time
struct _PointXYZT
{
	PCL_ADD_POINT4D;
	double gps_time;
	EIGEN_MAKE_ALIGNED_OPERATOR_NEW;
}EIGEN_ALIGN16;

struct EIGEN_ALIGN16 PointXYZT: public _PointXYZT
{
	inline PointXYZT(const _PointXYZT &p)
	{
		x = p.x; y = p.y; z = p.z; data[3] = 1.0f;
		gps_time = p.gps_time;
	}

	inline PointXYZT()
	{
		x = y = z = 0.0f;
		data[3] = 1.0f;
		gps_time = 0.0;
	}
	inline PointXYZT(double _time)
	{
		x = y = z = 0.0f;
		data[3] = 1.0f;
		gps_time = _time;
	}

	friend std::ostream& operator << (std::ostream& os, const PointXYZT& p);
	EIGEN_MAKE_ALIGNED_OPERATOR_NEW
};

不要忘了进行注册。

POINT_CLOUD_REGISTER_POINT_STRUCT(_PointXYZT,
(float, x, x)
(float, y, y)
(float, z, z)
(double, gps_time, gps_time)
)

POINT_CLOUD_REGISTER_POINT_WRAPPER(PointXYZT, _PointXYZT)

至于重载的operator函数,按照分文件类外定义的形式写在另外一个cpp文件中即可。

std::ostream& operator << (std::ostream& os, const PointXYZT& p)
{
	os << std::setprecision(3) << "(" << p.x << "," << p.y << "," << p.z << " - "
		<< static_cast<double>(p.gps_time) << ")";
	return (os);
}

使用PCL中的函数

  • 编译时会出现报错,error2001,无法解析的外部符号xxxx这种的。

解决方案: 是在使用函数模板时,添加一个宏定义#define PCL_NO_PRECOMPILE在调用函数模板之前。一般我就用如下的方式:写在hpp,cpp或.h文件最前面。

#ifndef PCL_NO_PRECOMPILE
#define PCL_NO_PRECOMPILE
#endif // PCL_NO_PRECOMPILE
...e.g. kdtree, voxelfilter balabala

Reference

pcl新版说明文档
原话是:
Then, you need to make sure your code includes the template header implementation of the specific class/algorithm in PCL that you want your new point type MyPointType to work with. For example, say you want to use pcl::PassThrough.

  • Starting with PCL-1.7 you need to define PCL_NO_PRECOMPILE before you include any PCL headers to include the templated algorithms as well.

标签:PointXYZT,自定义,NO,PRECOMPILE,PCL,time,点云,gps
来源: https://blog.csdn.net/qq_38827743/article/details/113829720

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有