# How to know Ring/Layer/Laser(/Color) from PointCloud2

Hi, friend. I am using Ubuntu 14.04 and ROS Indigo for the sensor Velodyne VLP-16. I am trying to extract the useful Information form PointCloud2 and reorder them to the format that I needed.

Now I can extract the x,y,z coordinates in python, but my current question is:

How can I know the layer of points? (How can I know which laser of 16 lasers measured that point?)

--> Contain the colors (r,g,b values.) those info? How can I from the color values like below know the layers? Sorry i don´t find the definition of rgb or examples.

r = (pack & 0x00FF0000)>> 16
g = (pack & 0x0000FF00)>> 8
b = (pack & 0x000000FF)


--> Should I calculate the elevation angles then get the layer information?

I am so confusing now....

I would appreciate if you could put some Python codes examples.

edit retag close merge delete

I found this file: colors.cc, but there is only 6 colors defined, for VLP-16 there should have 16 colors for rings, right? Sorry for the stupid question.

( 2018-11-25 05:53:10 -0600 )edit

Calculating the elevation of each point would seem like the most robust way of going about this. What is the problem you're having?

( 2018-11-25 06:14:55 -0600 )edit

Thank you for reply. I am totally new to ROS and python, so I always have problem by transforming and calculating the data in array (or struct? or numpy array?) and then putting them in new custom message in the way without bug. :(

( 2018-11-25 09:34:43 -0600 )edit

I want to convert the PointCloud2 as a custom message including the the info such as distance and azimuth angle etc. Should I use the tf2 transform better than point by point calculating? Thanks in advance.

( 2018-11-25 09:59:28 -0600 )edit

Can you tell us what you're trying to build overall. There doesn't seem to be any point including redundant information such as distance and elevation in a custom point cloud message type. It would be easier to calculate those properties as and when needed.

( 2018-11-25 12:01:38 -0600 )edit

I want to build a custom message similar to the raw sensor message then publish them. It contains the azimuth angles and distance values from 16 lasers in 1206 bytes. Please see my question before.

( 2018-11-26 08:23:29 -0600 )edit

Hi Cicilia, you said you can extract x,y,z coordinates in python. Could you help me understand how I can do that? Maybe you can share your code if possible please.

( 2020-03-31 03:36:29 -0600 )edit

Sort by » oldest newest most voted

UPDATE: PointCloud2::XYZIR, the fifth field Ring contains the layer information. For VLP-16, the ring values are 0 to 15.

more

I have a VLP-16 and a PointCloud2 extracted from it from velodyne_points topic. Inside the data I checked every 5th number and it is not smaller than 16. There are even 14 numbers in a row in which none of them are smaller than 16. I was expecting every other 5th data to be smaller than 16 so that it represents a ring value. I am totally confused now. Do you have any idea?

( 2020-03-31 03:40:34 -0600 )edit