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

Revision history [back]

After looking into the source code I found out that this read_points is a generator function that yields the next value of a cloud each time it is called. It works also as an iterator and calling it in a loop will deliver all pointcloud points: for p in enumerate(point_cloud2.read_points(pc2, field_names = ("x", "y", "z"), skip_nans=True)): cloud_points.append(p)

After looking into the source code I found out that this read_points is a generator function that yields the next value of a cloud each time it is called. It works also as an iterator and calling it in a loop will deliver all pointcloud points: cloud_points = [] for p in enumerate(point_cloud2.read_points(pc2, field_names = ("x", "y", "z"), skip_nans=True)): cloud_points.append(p) cloud_points.append(p)
cloud_points will then be a list of 3D points forming the cloud.

After looking into the source code I found out that this read_points is a generator function that yields the next value of a cloud each time it is called. It works also as an iterator and calling it in a loop will deliver all pointcloud points: points:

cloud_points = []
for  p in enumerate(point_cloud2.read_points(pc2, field_names = ("x", "y", "z"), skip_nans=True)):
    cloud_points.append(p) 
cloud_points.append(p)

cloud_points will then be a list of 3D points forming the cloud.

After looking into the source code I found out that this read_points is a generator function that yields the next value of a cloud each time it is called. It works also as an iterator and calling it in a loop will deliver all pointcloud points:

cloud_points = []
for  p in enumerate(point_cloud2.read_points(pc2, field_names = ("x", "y", "z"), skip_nans=True)):
    cloud_points.append(p)

Here pc2 is my pointcloud of type sensor_msgs/PointCloud2

and cloud_points will then be a list of 3D points forming the cloud.

After looking into the source code I found out that this read_points is a generator function that yields the next value of a cloud each time it is called. It works also as an iterator and calling it in a loop will deliver all pointcloud points:

cloud_points = []
for  p in enumerate(point_cloud2.read_points(pc2, point_cloud2.read_points(pc2, field_names = ("x", "y", "z"), skip_nans=True)):
skip_nans=True):
    cloud_points.append(p)

Here pc2 is my pointcloud of type sensor_msgs/PointCloud2

and cloud_points will then be a list of 3D points forming the cloud.