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

        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 geometry_msgs/Wrench 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') 
        >>> wrenchdatafile = b.wrench_data()
        >>> print(wrenchdatafile)

        '''
        tstart = None
        tend = None
        
        type_to_look ="geometry_msgs/Wrench"
        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",
                                "force.x", 
                                "force.y", 
                                "force.z" , 
                                "torque.x", 
                                "torque.y", 
                                "torque.z"]

        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) # write the header
                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.force.x, 
                                            msg.force.y,
                                            msg.force.z,
                                            msg.torque.x,
                                            msg.torque.y,
                                            msg.torque.z]

                    writer.writerow(new_row)
                
                k = k + 1

            csvlist.append(file_to_write)
        return csvlist

        Class method `wrench_data` extracts velocity data from the given file, assuming laser data is of type `geometry_msgs/Wrench`.

        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 geometry_msgs/Wrench 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') 
        >>> wrenchdatafile = b.wrench_data()
        >>> print(wrenchdatafile)

        
Class method `wrench_data` extracts velocity data from the given file, assuming laser data is of type `geometry_msgs/Wrench`.
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 geometry_msgs/Wrench type

Example


Class method ` wrench_data ` extracts velocity data from the given file assuming laser data is of type ` geometry_msgs / Wrench ` . 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 geometry_msgs / Wrench type Example
def wrench_data(self, **kwargs):
        tstart = None
        tend = None
        type_to_look ="geometry_msgs/Wrench"
        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",
                                "force.x", 
                                "force.y", 
                                "force.z" , 
                                "torque.x", 
                                "torque.y", 
                                "torque.z"]
        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.force.x, 
                                            msg.force.y,
                                            msg.force.z,
                                            msg.torque.x,
                                            msg.torque.y,
                                            msg.torque.z]
                    writer.writerow(new_row)
                k = k + 1
            csvlist.append(file_to_write)
        return csvlist
def wrench_data ( self , ** kwargs ) : tstart = None tend = None type_to_look = "geometry_msgs/Wrench" 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" , "force.x" , "force.y" , "force.z" , "torque.x" , "torque.y" , "torque.z" ] 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 . force . x , msg . force . y , msg . force . z , msg . torque . x , msg . torque . y , msg . torque . z ] writer . writerow ( new_row ) k = k + 1 csvlist . append ( file_to_write ) return csvlist
Class method `wrench_data` extracts velocity data from the given file, assuming laser data is of type `geometry_msgs/Wrench`.
Class method ` wrench_data ` extracts velocity data from the given file assuming laser data is of type ` geometry_msgs / Wrench ` .
'''
        Class method `wrench_data` extracts velocity data from the given file, assuming laser data is of type `geometry_msgs/Wrench`.

        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 geometry_msgs/Wrench 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') 
        >>> wrenchdatafile = b.wrench_data()
        >>> print(wrenchdatafile)

        ''' # write the header
self