ROS中PCL数据转换

PCL的点云数据的各种转换,里面的数据确实有点乱,现总结如下:

  1. ROS转PCL数据格式

sensor_msgs::PointCloud2转pcl::PCLPointCloud2 ^2

1
pcl_conversions::toPCL(sensor_msgs::PointCloud2, pcl::PCLPointCloud2)

sensor_msgs::PointCloud2转pcl::PointCloudpcl::PointXYZ ^1

1
pcl::fromROSMsg (sensor_msgs::PointCloud2, pcl::PointCloud<pcl::PointXYZ>);
  1. PCL转ROS数据

pcl::PCLPointCloud2转sensor_msgs::PointCloud2^2

1
pcl_conversions::fromPCL(pcl::PCLPointCloud2, sensor_msgs::PointCloud2);

pcl::PointCloudpcl::PointXYZ转sensor_msgs::PointCloud2^1

1
pcl::toROSMsg (pcl::PointCloud<pcl::PointXYZ>,sensor_msgs::PointCloud2);
  1. PCL中数据互转 ^3

pcl::PCLPointCloud2转pcl::PointCloud pcl::PointXYZ

1
pcl::fromPCLPointCloud2(pcl::PCLPointCloud2,pcl::PointCloud<pcl::PointXYZ>);

pcl::PointCloudpcl::PointXYZ转pcl::PCLPointCloud2

1
pcl::toPCLPointCloud2(pcl::PointCloud<pcl::PointXYZ>, pcl::PCLPointCloud2);

Reference: