# PointCloud2 parse to xyz array in ROS2

I'm trying to find a solution of converting PointCloud2 message data into xyz array for further analysis. Though, in my case I'm interested only in 2d application.

The information is either scarce or confusing.

Each point data in the PointCloud2 is stored as a binary blob. For example: First 1-4 numbers represent x as a 32 bit float, 5-8 represents y, 9-12 represents z, 13-16 represents the intensity.

So, my question is, is there any ROS2 library to make the conversion? Alternatively, any example of implementing it in C++.

For both cases, please provide a full code snippet or a link to an example

Look in the sensor_msgs_py package. It contains support functions for working with some of the more complex sensor messages, including point clouds. For your specific case, you could use the read_points() or read_points_numpy() or even the read_points_list() function to get the data out as a numpy array, which you can then analyse in the way you want.