使用tf对自定义点云类型进行坐标变换

自定义点云数据类型XYZIR后,无法使用pcl_ros::transformPointCloud直接对点云进行坐标变换,预期代码如下

// typedef PointXYZIR PointType;
// typedef pcl::PointCloud<PointType> PointCloud;
// PointCloud::Ptr cloud_from_lidar;
void pointcloudCallback(const sensor_msgs::PointCloud2::ConstPtr &pc)
{
	pcl::fromROSMsg(*pc, *cloud_from_lidar);
	pcl_ros::transformPointCloud(FRAME_ID, *cloud_from_lidar, *cloud_from_lidar, tf_listener);
}

但是会报错

undefined reference to `bool pcl_ros::transformPointCloud<PointXYZIR>(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, pcl::PointCloud<PointXYZIR> const&, pcl::PointCloud<PointXYZIR>&, tf::TransformListener const&)'

因此直接对sensor_msgs::PointCloud2进行处理即可

void pointcloudCallback(const sensor_msgs::PointCloud2::ConstPtr &pc)
{
	sensor_msgs::PointCloud2 pointcloud;
	pcl_ros::transformPointCloud(FRAME_ID, *pc, pointcloud, tf_listener);
	pcl::fromROSMsg(pointcloud, *cloud_from_lidar);
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值