nclt2ros/transformer/velodyne_data.py
def xyzil_array_to_pointcloud2(self, utime, hits):
        """reads the x, y, z, intensity, laser_id list and convert it into a pointcloud2 message

        :param utime: timestamp in microseconds from the binary file
        :param  hits: list, containing the x, y, z intensity, laser_id

        :return: timestamp: ros time object,
                   pc2_msg: pointcloud2 message
        """

        timestamp = rospy.Time.from_sec(utime / 1e6)
        points = np.array(hits)

        pc2_msg = PointCloud2()
        pc2_msg.header.stamp = timestamp
        pc2_msg.header.frame_id = self.velodyne_frame

        num_values = points.shape[0]
        assert(num_values > 0)

        NUM_FIELDS = 5
        assert(np.mod(num_values, NUM_FIELDS) == 0)

        num_points = num_values / NUM_FIELDS

        assert(len(points.shape) == 1)
        pc2_msg.height = 1

        FLOAT_SIZE_BYTES = 4
        pc2_msg.width = num_values * FLOAT_SIZE_BYTES

        pc2_msg.fields = [
            PointField('x', 0, PointField.FLOAT32, 1),
            PointField('y', 4, PointField.FLOAT32, 1),
            PointField('z', 8, PointField.FLOAT32, 1),
            PointField('i', 12, PointField.FLOAT32, 1),
            PointField('l', 16, PointField.FLOAT32, 1)
        ]

        pc2_msg.is_bigendian = False
        pc2_msg.point_step = NUM_FIELDS * FLOAT_SIZE_BYTES

        pc2_msg.row_step = pc2_msg.point_step * num_points
        pc2_msg.is_dense = False

        pc2_msg.width = num_points
        pc2_msg.data = np.asarray(points, np.float32).tostring()

        return timestamp, pc2_msg
reads the x, y, z, intensity, laser_id list and convert it into a pointcloud2 message

        :param utime: timestamp in microseconds from the binary file
        :param  hits: list, containing the x, y, z intensity, laser_id

        :return: timestamp: ros time object,
                   pc2_msg: pointcloud2 message
        
reads the x, y, z, intensity, laser_id list and convert it into a pointcloud2 message
reads the x y z intensity laser_id list and convert it into a pointcloud2 message
def xyzil_array_to_pointcloud2(self, utime, hits):
        timestamp = rospy.Time.from_sec(utime / 1e6)
        points = np.array(hits)
        pc2_msg = PointCloud2()
        pc2_msg.header.stamp = timestamp
        pc2_msg.header.frame_id = self.velodyne_frame
        num_values = points.shape[0]
        assert(num_values > 0)
        NUM_FIELDS = 5
        assert(np.mod(num_values, NUM_FIELDS) == 0)
        num_points = num_values / NUM_FIELDS
        assert(len(points.shape) == 1)
        pc2_msg.height = 1
        FLOAT_SIZE_BYTES = 4
        pc2_msg.width = num_values * FLOAT_SIZE_BYTES
        pc2_msg.fields = [
            PointField('x', 0, PointField.FLOAT32, 1),
            PointField('y', 4, PointField.FLOAT32, 1),
            PointField('z', 8, PointField.FLOAT32, 1),
            PointField('i', 12, PointField.FLOAT32, 1),
            PointField('l', 16, PointField.FLOAT32, 1)
        ]
        pc2_msg.is_bigendian = False
        pc2_msg.point_step = NUM_FIELDS * FLOAT_SIZE_BYTES
        pc2_msg.row_step = pc2_msg.point_step * num_points
        pc2_msg.is_dense = False
        pc2_msg.width = num_points
        pc2_msg.data = np.asarray(points, np.float32).tostring()
        return timestamp, pc2_msg
def xyzil_array_to_pointcloud2 ( self , utime , hits ) : timestamp = rospy . Time . from_sec ( utime / 1e6 ) points = np . array ( hits ) pc2_msg = PointCloud2 ( ) pc2_msg . header . stamp = timestamp pc2_msg . header . frame_id = self . velodyne_frame num_values = points . shape [ 0 ] assert ( num_values > 0 ) NUM_FIELDS = 5 assert ( np . mod ( num_values , NUM_FIELDS ) == 0 ) num_points = num_values / NUM_FIELDS assert ( len ( points . shape ) == 1 ) pc2_msg . height = 1 FLOAT_SIZE_BYTES = 4 pc2_msg . width = num_values * FLOAT_SIZE_BYTES pc2_msg . fields = [ PointField ( 'x' , 0 , PointField . FLOAT32 , 1 ) , PointField ( 'y' , 4 , PointField . FLOAT32 , 1 ) , PointField ( 'z' , 8 , PointField . FLOAT32 , 1 ) , PointField ( 'i' , 12 , PointField . FLOAT32 , 1 ) , PointField ( 'l' , 16 , PointField . FLOAT32 , 1 ) ] pc2_msg . is_bigendian = False pc2_msg . point_step = NUM_FIELDS * FLOAT_SIZE_BYTES pc2_msg . row_step = pc2_msg . point_step * num_points pc2_msg . is_dense = False pc2_msg . width = num_points pc2_msg . data = np . asarray ( points , np . float32 ) . tostring ( ) return timestamp , pc2_msg
reads the x, y, z, intensity, laser_id list and convert it into a pointcloud2 message
reads the x y z intensity laser_id list and convert it into a pointcloud2 message
"""reads the x, y, z, intensity, laser_id list and convert it into a pointcloud2 message

        :param utime: timestamp in microseconds from the binary file
        :param  hits: list, containing the x, y, z intensity, laser_id

        :return: timestamp: ros time object,
                   pc2_msg: pointcloud2 message
        """
ros time object,
pc2_msg: pointcloud2 message
ros time object pc2_msg : pointcloud2 message
self
utime
timestamp in microseconds from the binary file
timestamp in microseconds from the binary file
hits
list, containing the x, y, z intensity, laser_id
list containing the x y z intensity laser_id