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

Revision history [back]

click to hide/show revision 1
initial version

As of ROS2 humble there is also read_points_numpy (see here) which would give you directly a 2D NumPy array. For example:

        cloud = point_cloud2.read_points_numpy(
             msg, field_names=['x', 'y', 'z', "intensity"], skip_nans=True)

Note that there also exists a read_points_list (see here) at least for galactic, foxy, and humble which would have simplified the code of the other answers.

As of ROS2 humble there is also read_points_numpy (see here) which would give you directly a 2D NumPy array. For example:

 cloud = point_cloud2.read_points_numpy(
             msg, field_names=['x', 'y', 'z', "intensity"], skip_nans=True)

Note that there also exists a read_points_list (see here) at least for galactic, foxy, and humble which would have simplified the code of the other answers.

As of ROS2 humble there is also read_points_numpy (see here) which would give you directly a 2D NumPy array. For example:

cloud = point_cloud2.read_points_numpy(
     msg, field_names=['x', 'y', 'z', "intensity"], skip_nans=True)

Note that there also exists a read_points_list (see here) at least for galactic, foxy, and humble which would have simplified the code of the other answers.