Ask Your Question

Understand PointCloud2 msg (data array)

asked 2018-08-18 12:48:13 -0500

z1huo gravatar image

updated 2018-08-18 14:27:40 -0500

gvdhoorn gravatar image

Hi everyone,

I used rostopic echo and received a bunch of PointCloud2 Msg, but I have a hard time understand it especially for the "data" array.

Here is one example:

  seq: 0
    secs: 1527193450
    nsecs:  13024000
  frame_id: "velodyne"
height: 1
width: 1
    name: "x"
    offset: 0
    datatype: 7
    count: 1
    name: "y"
    offset: 4
    datatype: 7
    count: 1
    name: "z"
    offset: 8
    datatype: 7
    count: 1
    name: "intensity"
    offset: 16
    datatype: 7
    count: 1
is_bigendian: False
point_step: 32
row_step: 32
data: [218, 49, 151, 64, 105, 199, 245, 64, 50, 184, 192, 63, 0, 0, 128, 63, 1, 0, 64, 64, 252, 127, 0, 0, 182, 0, 0, 0, 0, 0, 0, 0]
is_dense: True

I have read through the documents for PointCloud2 but did not find helpful information for understand the "data". I want to extract point coordinate as (x,y,z) from it. Looking forward to some help!

edit retag flag offensive close merge delete

3 Answers

Sort by » oldest newest most voted

answered 2018-08-18 14:37:17 -0500

If you just need to work with the point data then you can create a subscriber function which will receive a pcl::PointCloud object directly as described in this tutorial. This way you don't need to worry about the underlying representation at all. The documentation on the PCL website should then tell you everything you need to know to work with the received point cloud object.

If you're interested, most of the information you showed from the message is actually meta information that describes the format of the point cloud in the message. There are many possible point types for point clouds, including custom ones so the message format has to be flexible. The Data array is then the byte buffer values of the raw point cloud data, it is possible to reconstruct the cloud from this data but there are much easier ways of doing it.

Hope this helps.

edit flag offensive delete link more

answered 2021-03-05 06:12:01 -0500

Vignesh_93 gravatar image

updated 2021-03-05 06:12:53 -0500

Hopng its not too late !! If its python we have a whole bunch of libraries written for the conversion. for this specific case we can use ros_numpy.point_cloud2.pointcloud2_to_xyz_array(your_array) and this returns x,y,z as a 3D numpy array

More information please find here :

edit flag offensive delete link more

answered 2019-01-17 02:38:20 -0500

updated 2019-01-17 02:38:51 -0500

Here you can find useful information about the message structure and how to iterate through the cloud points.

edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools



Asked: 2018-08-18 12:48:13 -0500

Seen: 6,434 times

Last updated: Mar 05