點雲數據格式解析 sensor_msgs::PointCloud2

在使用多線激光的時候需要總是會碰到點雲數據,這裏簡單的接受一下點雲數據,並堆數據結構進行分析,方便自己後期對點雲特徵數據進行處理。

Rviz中的點雲數據

本書據採用的經典的 loam_velodyne 算法,跑得是開源的包pcap 包, 有時間會詳細介紹跑包的方法
在這裏插入圖片描述

點雲數據結構分析

具體官方數據分析: http://docs.ros.org/jade/api/sensor_msgs/html/msg/PointCloud2.html

header:  // 點雲的頭信息
  seq: 963 //
  stamp:  // 時間戳
    secs: 1541143772
    nsecs: 912011000
  frame_id: "/camera_init"
height: 1   // If the cloud is unordered, height is 1  如果cloud 是無序的 height 是 1
width: 852578  //點雲的長度
fields:  //  sensor_msgs/PointField[] fields 
  - 
    name: "x"
    offset: 0
    datatype: 7 	// 	uint8 INT8    = 1
			//	uint8 UINT8   = 2
			//	uint8 INT16   = 3
			//	uint8 UINT16  = 4
			//	uint8 INT32   = 5
			//	uint8 UINT32  = 6
			//	uint8 FLOAT32 = 7
			//	uint8 FLOAT64 = 8
    count: 1
  - 
    name: "y"
    offset: 4
    datatype: 7
    count: 1
  - 
    name: "z"
    offset: 8
    datatype: 7
    count: 1
  - 
    name: "intensity"
    offset: 16
    datatype: 7
    count: 1
is_bigendian: False
point_step: 32 // Length of a point in bytes 一個點佔的比特數 
row_step: 27282496 // Length of a row in bytes 一行的長度佔用的比特數
data: [ .......................................................... ] //  Actual point data, size is (row_step*height)
is_dense: True // 沒有非法數據點

!!! data 內部包含的是 包含點雲的二進制數據流! 必須要單獨解析,直接讀取沒有任何意義, 參考這個回答 https://answers.ros.org/question/273182/trying-to-understand-pointcloud2-msg/

點雲數據 python 解析

from sensor_msgs.msg import PointCloud2
from sensor_msgs import point_cloud2

def callback_pointcloud(data):
    assert isinstance(data, PointCloud2)
    gen = point_cloud2.read_points(data)
    print type(gen)
    for p in gen:
      print p 

數據截圖

(看那黑丫丫的一片數據,感覺我的cpu帶不動啊```)
在這裏插入圖片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章