ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
4

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:

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!

edit retag flag offensive close merge delete

4 Answers

Sort by » oldest newest most voted
3

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
0

answered 2022-08-22 16:05:46 -0500

HossamAlzomor gravatar image

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
edit flag offensive delete link more
0

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

edit flag offensive delete link more
0

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

Question Tools

2 followers

Stats

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

Seen: 13,942 times

Last updated: Mar 05 '21