传感器数据类型: sensor_msgs::PointCloud2 sensor_msgs::PointCloud
PCL库中标准数据类型:pcl::PointCloud<PointXYZ> pcl::PointCloud<PointXYZI>等等 可自定义
传感器类型和库类型的转换
- ROS转PCL数据格式
- sensor_msgs::PointCloud2转pcl::PCLPointCloud2
pcl_conversions::toPCL(sensor_msgs::PointCloud2, pcl::PCLPointCloud2);
- sensor_msgs::PointCloud2转pcl::PointCloud<pcl::PointXYZ>
pcl::fromROSMsg(sensor_msg::PointCloud2,pcl::PointCloud<pcl::PointXYZ>);
2.PCL转ROS数据格式
- pcl::PointCloud2转sensor_msgs::PointCloud2
pcl::conversions::fromPCL(pcl::PCLPointCloud2,sensor_msgs::PointCloud2);
- pcl::PointCloud<pcl::PointXYZ>转sensor_msgs::PointCloud2
pcl::toROSMsg(pcl::PointCloud<pcl::PointXYZ>,sensor_msgs::PointCloud2);
3.PCL中数据互转
- pcl::PCLPointCloud2转pcl::PointCloud<pcl::PointXYZ>
pcl::fromPCLPointCloud2(pcl::PCLPointCloud2,pcl::PointCloud<pcl::PointXYZ>);
- pcl::PointCloud<pcl::PointXYZ>转pcl::PCLPointCloud2
pcl::toPCLPointCloud2(pcl::PointCloud<pcl::PointXYZ>,pcl::PCLPointCloud2)
点云对象和点云指针对象之间的转换
点云--->点云指针
//点云对象
pcl::PointCloud<pcl::PointXYZ> cloud;
//点云指针对象
pcl::PointCloud<pcl::PointXYZ>::Ptr cloudPtr (new pcl::PointCloud<pcl::PointXYZ>);
//转换
cloud = * cloudPtr;
cloudPtr = cloud.makeShared();