how to read generator data as numpy array

asked 2017-10-31 11:30:38 -0600

Moneyball gravatar image
 def laser_callback(self, laserMsg):
     cloud = self.laser_projector.projectLaser(laserMsg)
     gen = pc2.read_points(cloud, skip_nans=True, field_names=('x', 'y', 'z'))
     self.xyz_generator = gen
     print(gen)

I'm trying to convert the laser data into pointcloud2 data, and then display them using matplotlib.pyplot. I tried traversing individual points in the generator but it takes a long time. Instead I'd like to convert them into a numpy array and then plot it. How do I go about doing that?

edit retag flag offensive close merge delete