How to get start_time and end_time without using "rosbag info""
I want to get these two times as soon as possible. When use "rosbag info" on very large bag files(over 100GB), the process is not quick enough. I tried to read "Source Code for Module rosbag.bag" on http://docs.ros.org/melodic/api/rosba..., and I found these codes:
def get_start_time(self):
"""
Returns the start time of the bag.
@return: a timestamp of the start of the bag
@rtype: float, timestamp in seconds, includes fractions of a second
"""
if self._chunks:
start_stamp = self._chunks[0].start_time.to_sec()
else:
if not self._connection_indexes:
raise ROSBagException('Bag contains no message')
start_stamps = [index[0].time.to_sec() for index in self._connection_indexes.values() if index]
start_stamp = min(start_stamps) if start_stamps else 0
return start_stamp
def get_end_time(self):
"""
Returns the end time of the bag.
@return: a timestamp of the end of the bag
@rtype: float, timestamp in seconds, includes fractions of a second
"""
if self._chunks:
end_stamp = self._chunks[-1].end_time.to_sec()
else:
if not self._connection_indexes:
raise ROSBagException('Bag contains no message')
end_stamps = [index[-1].time.to_sec() for index in self._connection_indexes.values() if index]
end_stamp = max(end_stamps) if end_stamps else 0
return end_stamp
but I don't understand what are self._chunks[0] and self._chunks[-1]
can anyone explain them for me?
Those are the first and last chunk of a bagfile.