1. 程式人生 > 其它 >ROS中PCL的資料型別轉換

ROS中PCL的資料型別轉換

1、ROS中的點雲資料型別

sensor_msgs::PointClous
// 包含 x、y 和 z 點(所有浮點數)以及多個通道; 每個通道都有一個字串名稱和一個浮點值陣列
sensor_msgs::PointCloud2
//表示任意 nD(n 維)資料。 點值現在可以是任何原始資料型別(int、float、double 等),並且可以將訊息指定為“密集”,具有高度和寬度值

2、點雲轉換

  1. 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)

參考部落格:http://wiki.ros.org/pcl/Overview

     https://blog.csdn.net/u010284636/article/details/79214841