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.
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...
https://answers.ros.org/question/2027...
look at that question. that helped me. @jayess
So, do you not need an explanation any more?
@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.