Learning about pointcloud, pointcloud2 data
Hi everyone,
I am doing a project implementing VLP-16 lidar from Velodyne. First of all, this is my first project working with both ROS and Lidar. Therefore, forgive me if I ask such an obvious or inappropriate question.
I know that the lidar gives out the PointCloud2
on the topic /velodyne_points
. In order to understand and analyze the data, I have researched on PointCloud2
. This is how I understand and extract the XYZ from the data:
- First I convert
sensor_msgs::PointCloud2
topcl::PointCloud<pcl::PointXYZ>
- To extract (x,y,z), for example, I just simple read out
pt_cloud->points[a].x
,pt_cloud->points[a].y
andpt_cloud->points[a].z
- The index
a
above, as I understand, is the index of a specific point in the data array. The size iswidth*height
which can be read out fromsensor_msgs::PointCloud2
. For example, I have width = 10 and height = 1 ( as I know is un-organized) then I can read anya
point as long as it is in range from 0 to 10*1.
This is how I understand after few days of studying about it. It will be nice if someone can help me confirm or correct it. Also, it is still very difficult for me to understand all the parameter inside sensor_msgs::PointCloud2
because it is not explained that clearly. So far, I see it as the Lidar sends a message packet every specific interval ( in sensor_msgs::PointCloud2
type). The packet contains the width and height (as mentioned above) and the data after rotating 360 degree. I still do not understand the meaning of data
and field
in sensor_msgs::PointCloud2
.
To come this point, I have read several topics, tutorials, examples, etc. about this problem. It is still vague for me. Every comment, recommendation or solution is welcomed.
Thanks in advance!