def process_point_clouds(self, simulator_pc): """ Invoked when a point cloud is received from the simulator. """ game_time = int(simulator_pc.timestamp * 1000) timestamp = erdos.Timestamp(coordinates=[game_time]) watermark_msg = erdos.WatermarkMessage(timestamp) with erdos.profile(self.config.name + '.process_point_clouds', self, event_data={'timestamp': str(timestamp)}): # Ensure that the code executes serially with self._lock: assert len( simulator_pc.raw_data) > 0, 'Lidar did not send any points' # Include the transform relative to the vehicle. # simulator_pc.transform returns the world transform, but # we do not use it directly. msg = PointCloudMessage( timestamp, PointCloud.from_simulator_point_cloud( simulator_pc, self._lidar_setup)) if self._release_data: self._lidar_stream.send(msg) self._lidar_stream.send(watermark_msg) else: # Pickle the data, and release it upon release msg receipt. pickled_msg = pickle.dumps( msg, protocol=pickle.HIGHEST_PROTOCOL) with self._pickle_lock: self._pickled_messages[msg.timestamp] = pickled_msg self._notify_reading_stream.send(watermark_msg)
def on_point_cloud(self, data): self._counter += 1 if self._counter % self._modulo_to_send != 0: return timestamp = erdos.Timestamp(coordinates=[self._msg_cnt]) points = [] for data in pc2.read_points(data, field_names=('x', 'y', 'z'), skip_nans=True): points.append([data[0], data[1], data[2]]) points = np.array(points) point_cloud = pylot.perception.point_cloud.PointCloud( points, self._lidar_setup) msg = PointCloudMessage(timestamp, point_cloud) self._point_cloud_stream.send(msg) watermark_msg = erdos.WatermarkMessage(timestamp) self._point_cloud_stream.send(watermark_msg) self._logger.debug('@{}: sent message'.format(timestamp)) self._msg_cnt += 1
def process_point_clouds(self, carla_pc): """ Invoked when a pointcloud is received from the simulator. Args: carla_pc: a carla.SensorData object. """ # Ensure that the code executes serially with self._lock: game_time = int(carla_pc.timestamp * 1000) timestamp = erdos.Timestamp(coordinates=[game_time]) watermark_msg = erdos.WatermarkMessage(timestamp) # Include the transform relative to the vehicle. # Carla carla_pc.transform returns the world transform, but # we do not use it directly. msg = PointCloudMessage( PointCloud.from_carla_point_cloud( carla_pc, self._lidar_setup.get_transform()), timestamp) self._lidar_stream.send(msg) # Note: The operator is set not to automatically propagate # watermark messages received on input streams. Thus, we can # issue watermarks only after the Carla callback is invoked. self._lidar_stream.send(watermark_msg)