Robotics StackExchange | Archived questions

Understand PointCloud2 msg (data array)

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:

header: 
  seq: 0
  stamp: 
    secs: 1527193450
    nsecs:  13024000
  frame_id: "velodyne"
height: 1
width: 1
fields: 
  - 
    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!

Asked by z1huo on 2018-08-18 12:48:13 UTC

Comments

Answers

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.

Asked by PeteBlackerThe3rd on 2018-08-18 14:37:17 UTC

Comments

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

Asked by Danfoa on 2019-01-17 03:38:20 UTC

Comments

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 : http://docs.ros.org/en/jade/api/ros_numpy/html/point__cloud2_8py_source.html

Asked by Vignesh_93 on 2021-03-05 07:12:01 UTC

Comments

Here is the structure of Point cloud data

# This message holds a collection of N-dimensional points, which may
# contain additional information such as normals, intensity, etc. The
# point data is stored as a binary blob, its layout described by the
# contents of the "fields" array.

# The point cloud data may be organized 2d (image-like) or 1d
# (unordered). Point clouds organized as 2d images may be produced by
# camera depth sensors such as stereo or time-of-flight.

# Time of sensor data acquisition, and the coordinate frame ID (for 3d points). 
Header header

# 2D structure of the point cloud. If the cloud is unordered, height is
# 1 and width is the length of the point cloud. 
uint32 height 
uint32 width
# Describes the channels and their layout in the binary data blob.
PointField[] fields

bool    is_bigendian # Is this data bigendian?
uint32  point_step   #Length of a point in bytes 
uint32 row_step     # Length of a row in bytes
uint8[] data         # Actual point data, size is (row_step*height)

bool is_dense        # True if there are no invalid points

Asked by HossamAlzomor on 2022-08-22 16:05:46 UTC

Comments