我们在使用ROS接收Ouster点云数据的对应topic,处理其点云数据时,如果仅使用PCL库中定义的PointXYZ或者PointXYZI等类型,会导致丢失一些非常有用的信息。如每个点的线号(ring),在当前帧中的对应时间等。
因此有必要根据驱动自定义对应的点类型,方便我们使用更全的点云信息。
PCL中自定义点云类型OusterPointXYZIRT的方式如下:
// define the point type of ouster
struct EIGEN_ALIGN16 OusterPointXYZIRT {
PCL_ADD_POINT4D;
float intensity;
uint32_t t;
uint16_t reflectivity;
uint8_t ring;
uint16_t ambient;
uint32_t range;
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
};
// register to PCL
POINT_CLOUD_REGISTER_POINT_STRUCT(OusterPointXYZIRT,
(float, x, x)
(float, y, y)
(float, z, z)
(float, intensity, intensity)
// use std::uint32_t to avoid conflicting with pcl::uint32_t
(std::uint32_t, t, t)
(std::uint16_t, reflectivity, reflectivity)
(std::uint8_t, ring, ring)
(std::uint16_t, ambient, ambient)
(std::uint32_t, range, range)
)
在使用OusterPointXYZIRT时:
// define
pcl::PointCloud<OusterPointXYZIRT>::Ptr tmpOusterCloudIn;
// allocate Memory
tmpOusterCloudIn.reset(new pcl::PointCloud<OusterPointXYZIRT>());
// trans from ROS msg
pcl::moveFromROSMsg(currentCloudMsg, *tmpOusterCloudIn);
之后,我们就可以使用tmpOusterCloudIn中的xyz,intensity,t,reflectivity,ring,ambient,range等一系列属性信息了。