Point Cloud Library §
- 没有比较好的Python移植,只支持CPP
- 头文件
#include <pcl_conversions/pcl_conversions.h>
#include <pcl/point_types.h>
#include <pcl/PCLPointCloud2.h>
#include <pcl/conversions.h>
- 创建点云
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>);
pcl::PointXYZ p(x,y,z);
cloud->push_back(p);
- 与ROS消息的数据类型转换
sensor_msgs::PointCloud2 point_cloud2;
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>);
// create your point cloud here
pcl::toROSMsg(*cloud, point_cloud2);
point_cloud2.header.frame_id = "world";