自定义点云数据类型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);
}