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

Trying to understand PointCloud2 msg

asked 2017-10-16 13:33:59 -0600

krishna43 gravatar image


Can someone please post a clear explanation of how to understand pointcloud2 message? I want to get x,y,z point from the message and I found a solution to do that, but I am not able to understand why there are so many numbers in data field?

Can someone please explain?


edit retag flag offensive close merge delete


What is the solution that you found? I think that people may have a hard time explaining it if they don't know what it is...

jayess gravatar image jayess  ( 2017-10-16 13:59:13 -0600 )edit

look at that question. that helped me. @jayess

krishna43 gravatar image krishna43  ( 2017-10-18 15:45:36 -0600 )edit

So, do you not need an explanation any more?

jayess gravatar image jayess  ( 2017-10-18 15:53:26 -0600 )edit

@jayess I need an explanation of PointCloud2 data format. I got the result i want by blindly copying the code snippet, but i don't know what it means.

krishna43 gravatar image krishna43  ( 2017-10-18 15:55:26 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2017-11-04 11:41:00 -0600

Ed Venator gravatar image

The data field of a PointCloud2 message contains the list of points encoded as a byte stream, where each point is a struct. The format of the points in an individual PointCloud2 message is defined by the fields, which is a list of sensor_msgs/PointField objects. In order to turn the data back into individual points, it has to be deserialized. The PointCloud library has defined methods that do this automatically (in Python, you'd use pc2.read_points.) Under the hood, these methods use memory reinterpretation to transform the byte stream to a list of points (e.g. Python's struct.unpack() or reinterpret casting in C++).

The advantage of the byte stream representation is that it's a compact way to transport the data that is extremely flexible, allowing any arbitrary struct to be used for the points. The disadvantage is that the message unreadable without deserialization.

edit flag offensive delete link more

Question Tools



Asked: 2017-10-16 13:33:59 -0600

Seen: 13,345 times

Last updated: Nov 04 '17