Interpreting the pointcloud2 data values

asked 2020-04-18 06:21:50 -0500

elemecrobots gravatar image

updated 2020-04-18 06:22:51 -0500

Hi. I am subscribing to a point cloud topic having the following data:

height : 480

width: 640

point_step: 16

row_step: 10240

fields: name: "x" offset: 0 datatype: 7, "y" offset: 4 datatype: 7, "z" offset: 8 datatype: 7

Above data means that every x,y,z value is represented as 16 bytes of data. As in fields, we have only x,y,z, so, this means, out of 16 bytes per point, we are only using 12 bytes per point, remaining 4 are set to zero.

Once i output 16 bytes which correspond to 1 point, I am getting following output

[0, 0, 192, 127, 0, 0, 192, 127, 0, 0, 192, 127, 0, 0, 0, 0]

As you can see, last 4 bytes are set to zero which is logical because we only have x,y,z and they represent first 12 bytes. Question is how I can interpret the values of first 12 bytes? what does 12 bytes [0, 0, 192, 127, 0, 0, 192, 127, 0, 0, 192, 127] mean? Another confusing point is for majority of the points, I am getting the same output per point. Shouldn't the X, Y value in the bytes change as i output some other point? What I am expecting is that each 4 bytes should represent the distance value for each x,y,z if i am not wrong..Any clues?

Thanks in advance

edit retag flag offensive close merge delete


I would try to fisualize the pointcloud in rviz. If you want this point cloud to be used with other ros nodes it should meet the standards of the messege type anyway, thus rviz should show what you publish and thus give you a clue whats wrong or right.

Dragonslayer gravatar image Dragonslayer  ( 2020-04-18 10:07:44 -0500 )edit

I am able to visualize the pointcloud in RVIZ correctly. What i feel is, i need to deserliaze this data. Upon further digging, I came to know about ros_numpy.numpify() function which converts the data into a numpy array. Once, i convert it, the data makes more sense. I am curious to know what is happening inside ros_numpy.numpify() message which converts the data

elemecrobots gravatar image elemecrobots  ( 2020-04-18 17:44:56 -0500 )edit