Ask Your Question

Understand PointCloud2 msg (data array)

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

z1huo gravatar image

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

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

2 Answers

Sort by » oldest newest most voted

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

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 2019-01-17 02:38:20 -0600

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

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

1 follower


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

Seen: 2,005 times

Last updated: Jan 17 '19