Robotics StackExchange | Archived questions

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.

Thanks for your answers and best wishes.

Asked by Cicilia on 2018-11-25 06:43:14 UTC

Comments

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.

Asked by Cicilia on 2018-11-25 06:53:10 UTC

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

Asked by PeteBlackerThe3rd on 2018-11-25 07:14:55 UTC

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. :(

Asked by Cicilia on 2018-11-25 10:34:43 UTC

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.

Asked by Cicilia on 2018-11-25 10:59:28 UTC

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.

Asked by PeteBlackerThe3rd on 2018-11-25 13:01:38 UTC

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.

Asked by Cicilia on 2018-11-26 09:23:29 UTC

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.

Asked by beluga on 2020-03-31 03:36:29 UTC

Answers

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

Asked by Cicilia on 2018-11-27 08:53:33 UTC

Comments

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?

Asked by beluga on 2020-03-31 03:40:34 UTC