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!
Asked by Sapodilla on 2019-11-05 10:01:12 UTC
Answers
Yuo understand it right. pointcloud2 is just the transport container for pcl::PointCloud
Asked by duck-development on 2019-11-05 12:01:12 UTC
Comments
Thanks for your confirmation! How about my question about data and field in pointcloud2? By the way, I checked the width and height of the message and realize that the width of each packet is different to each other. Is that because the Lidar cannot always cover all the points?
Asked by Sapodilla on 2019-11-05 14:44:02 UTC
Meybe some points are filters out because those did not reflect so the scanner can not measure the distance. Or some point are to near so it is also not Abe to get the distance. So this is the cause WY your number of point does variate
Asked by duck-development on 2019-11-05 14:51:17 UTC
Thanks a lot! That is very helpful. I will keep that in mind.
Asked by Sapodilla on 2019-11-05 15:06:13 UTC
Comments