Ask Your Question

Learning about pointcloud, pointcloud2 data

asked 2019-11-05 09:01:12 -0600

Sapodilla gravatar image

updated 2019-11-05 13:39:29 -0600

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:

  1. First I convert sensor_msgs::PointCloud2 to pcl::PointCloud<pcl::PointXYZ>
  2. To extract (x,y,z), for example, I just simple read out pt_cloud->points[a].x, pt_cloud->points[a].y and pt_cloud->points[a].z
  3. The index a above, as I understand, is the index of a specific point in the data array. The size is width*height which can be read out from sensor_msgs::PointCloud2. For example, I have width = 10 and height = 1 ( as I know is un-organized) then I can read any a 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::PointCloud2because 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!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2019-11-05 11:01:12 -0600

duck-development gravatar image

Yuo understand it right. pointcloud2 is just the transport container for pcl::PointCloud<t>

edit flag offensive delete link more


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?

Sapodilla gravatar image Sapodilla  ( 2019-11-05 13:44:02 -0600 )edit

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

duck-development gravatar image duck-development  ( 2019-11-05 13:51:17 -0600 )edit

Thanks a lot! That is very helpful. I will keep that in mind.

Sapodilla gravatar image Sapodilla  ( 2019-11-05 14:06:13 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2019-11-05 09:01:12 -0600

Seen: 591 times

Last updated: Nov 05 '19