bagpy/bagreader.py
def laser_data(self, **kwargs):
        '''
        Class method `laser_data` extracts laser data from the given file, assuming laser data is of type `sensor_msgs/LaserScan`.

        Parameters
        -------------
        kwargs
            variable keyword arguments

        Returns
        ---------
        `list`
            A list of strings. Each string will correspond to file path of CSV file that contains extracted data of laser scan type

        Example
        ----------
        >>> b = bagreader('/home/ivory/CyverseData/ProjectSparkle/sparkle_n_1_update_rate_100.0_max_update_rate_100.0_time_step_0.01_logtime_30.0_2020-03-01-23-52-11.bag') 
        >>> laserdatafile = b.laser_data()
        >>> print(laserdatafile)

        '''
        tstart =None
        tend = None
        
        type_to_look ="sensor_msgs/LaserScan"
        table_rows = self.topic_table[self.topic_table['Types']==type_to_look]
        topics_to_read = table_rows['Topics'].values
        message_counts = table_rows['Message Count'].values
        
        column_names = ["Time",
                                "header.seq", 
                                "header.frame_id", 
                                "angle_min" , 
                                "angle_max", 
                                "angle_increment", 
                                "time_increment", 
                                "scan_time", 
                                "range_min", 
                                "range_max"]

        for p in range(0, 182):
            column_names.append("ranges_" + str(p))
        for p in range(0, 182):
            column_names.append("intensities_" + str(p))

        all_msg = []
        csvlist = []
        for i in range(len(table_rows)):
            tempfile = self.datafolder + "/" + topics_to_read[i].replace("/", "-") + ".csv"
            file_to_write = ntpath.dirname(tempfile) + '/' + ntpath.basename(tempfile)[1:]
            #msg_list = [LaserScan() for count in range(message_counts[i])]
            k = 0

            if sys.hexversion >= 0x3000000:
                opencall = open(file_to_write, "w", newline='')
            else:
                opencall = open(file_to_write, 'wb')

            with opencall as f:
                writer = csv.writer(f, delimiter=',')
                writer.writerow(column_names) # write the header
                for topic, msg, t in self.reader.read_messages(topics=topics_to_read[i], start_time=tstart, end_time=tend): 
                    #msg_list[k] = msg
                    
                    new_row = [t.secs + t.nsecs*1e-9, 
                                            msg.header.seq, 
                                            msg.header.frame_id, 
                                            msg.angle_min,
                                            msg.angle_max, 
                                            msg.angle_increment, 
                                            msg.time_increment, 
                                            msg.scan_time,  
                                            msg.range_min, 
                                            msg.range_max]

                    ranges = [None]*182
                    intensities = [None]*182

                    for ir, ran in enumerate(msg.ranges):
                        ranges[ir] = ran

                    for ir, ran in enumerate(msg.intensities):
                        intensities[ir] = ran

                    new_row  = new_row + ranges
                    new_row = new_row + intensities
                    writer.writerow(new_row)
                
                k = k + 1

            csvlist.append(file_to_write)
        return csvlist

        Class method `laser_data` extracts laser data from the given file, assuming laser data is of type `sensor_msgs/LaserScan`.

        Parameters
        -------------
        kwargs
            variable keyword arguments

        Returns
        ---------
        `list`
            A list of strings. Each string will correspond to file path of CSV file that contains extracted data of laser scan type

        Example
        ----------
        >>> b = bagreader('/home/ivory/CyverseData/ProjectSparkle/sparkle_n_1_update_rate_100.0_max_update_rate_100.0_time_step_0.01_logtime_30.0_2020-03-01-23-52-11.bag') 
        >>> laserdatafile = b.laser_data()
        >>> print(laserdatafile)

        
Class method `laser_data` extracts laser data from the given file, assuming laser data is of type `sensor_msgs/LaserScan`.
Parameters

kwargs
variable keyword arguments

Returns

`list`
A list of strings. Each string will correspond to file path of CSV file that contains extracted data of laser scan type

Example


Class method ` laser_data ` extracts laser data from the given file assuming laser data is of type ` sensor_msgs / LaserScan ` . Parameters kwargs variable keyword arguments Returns ` list ` A list of strings . Each string will correspond to file path of CSV file that contains extracted data of laser scan type Example
def laser_data(self, **kwargs):
        tstart =None
        tend = None
        type_to_look ="sensor_msgs/LaserScan"
        table_rows = self.topic_table[self.topic_table['Types']==type_to_look]
        topics_to_read = table_rows['Topics'].values
        message_counts = table_rows['Message Count'].values
        column_names = ["Time",
                                "header.seq", 
                                "header.frame_id", 
                                "angle_min" , 
                                "angle_max", 
                                "angle_increment", 
                                "time_increment", 
                                "scan_time", 
                                "range_min", 
                                "range_max"]
        for p in range(0, 182):
            column_names.append("ranges_" + str(p))
        for p in range(0, 182):
            column_names.append("intensities_" + str(p))
        all_msg = []
        csvlist = []
        for i in range(len(table_rows)):
            tempfile = self.datafolder + "/" + topics_to_read[i].replace("/", "-") + ".csv"
            file_to_write = ntpath.dirname(tempfile) + '/' + ntpath.basename(tempfile)[1:]
            k = 0
            if sys.hexversion >= 0x3000000:
                opencall = open(file_to_write, "w", newline='')
            else:
                opencall = open(file_to_write, 'wb')
            with opencall as f:
                writer = csv.writer(f, delimiter=',')
                writer.writerow(column_names) 
                for topic, msg, t in self.reader.read_messages(topics=topics_to_read[i], start_time=tstart, end_time=tend): 
                    new_row = [t.secs + t.nsecs*1e-9, 
                                            msg.header.seq, 
                                            msg.header.frame_id, 
                                            msg.angle_min,
                                            msg.angle_max, 
                                            msg.angle_increment, 
                                            msg.time_increment, 
                                            msg.scan_time,  
                                            msg.range_min, 
                                            msg.range_max]
                    ranges = [None]*182
                    intensities = [None]*182
                    for ir, ran in enumerate(msg.ranges):
                        ranges[ir] = ran
                    for ir, ran in enumerate(msg.intensities):
                        intensities[ir] = ran
                    new_row  = new_row + ranges
                    new_row = new_row + intensities
                    writer.writerow(new_row)
                k = k + 1
            csvlist.append(file_to_write)
        return csvlist
def laser_data ( self , ** kwargs ) : tstart = None tend = None type_to_look = "sensor_msgs/LaserScan" table_rows = self . topic_table [ self . topic_table [ 'Types' ] == type_to_look ] topics_to_read = table_rows [ 'Topics' ] . values message_counts = table_rows [ 'Message Count' ] . values column_names = [ "Time" , "header.seq" , "header.frame_id" , "angle_min" , "angle_max" , "angle_increment" , "time_increment" , "scan_time" , "range_min" , "range_max" ] for p in range ( 0 , 182 ) : column_names . append ( "ranges_" + str ( p ) ) for p in range ( 0 , 182 ) : column_names . append ( "intensities_" + str ( p ) ) all_msg = [ ] csvlist = [ ] for i in range ( len ( table_rows ) ) : tempfile = self . datafolder + "/" + topics_to_read [ i ] . replace ( "/" , "-" ) + ".csv" file_to_write = ntpath . dirname ( tempfile ) + '/' + ntpath . basename ( tempfile ) [ 1 : ] k = 0 if sys . hexversion >= 0x3000000 : opencall = open ( file_to_write , "w" , newline = '' ) else : opencall = open ( file_to_write , 'wb' ) with opencall as f : writer = csv . writer ( f , delimiter = ',' ) writer . writerow ( column_names ) for topic , msg , t in self . reader . read_messages ( topics = topics_to_read [ i ] , start_time = tstart , end_time = tend ) : new_row = [ t . secs + t . nsecs * 1e-9 , msg . header . seq , msg . header . frame_id , msg . angle_min , msg . angle_max , msg . angle_increment , msg . time_increment , msg . scan_time , msg . range_min , msg . range_max ] ranges = [ None ] * 182 intensities = [ None ] * 182 for ir , ran in enumerate ( msg . ranges ) : ranges [ ir ] = ran for ir , ran in enumerate ( msg . intensities ) : intensities [ ir ] = ran new_row = new_row + ranges new_row = new_row + intensities writer . writerow ( new_row ) k = k + 1 csvlist . append ( file_to_write ) return csvlist
Class method `laser_data` extracts laser data from the given file, assuming laser data is of type `sensor_msgs/LaserScan`.
Class method ` laser_data ` extracts laser data from the given file assuming laser data is of type ` sensor_msgs / LaserScan ` .
'''
        Class method `laser_data` extracts laser data from the given file, assuming laser data is of type `sensor_msgs/LaserScan`.

        Parameters
        -------------
        kwargs
            variable keyword arguments

        Returns
        ---------
        `list`
            A list of strings. Each string will correspond to file path of CSV file that contains extracted data of laser scan type

        Example
        ----------
        >>> b = bagreader('/home/ivory/CyverseData/ProjectSparkle/sparkle_n_1_update_rate_100.0_max_update_rate_100.0_time_step_0.01_logtime_30.0_2020-03-01-23-52-11.bag') 
        >>> laserdatafile = b.laser_data()
        >>> print(laserdatafile)

        ''' #msg_list = [LaserScan() for count in range(message_counts[i])] # write the header #msg_list[k] = msg
self