diff --git a/tools/rosbag/src/rosbag/bag.py b/tools/rosbag/src/rosbag/bag.py index dbe26a4aa3..3db8b998c5 100644 --- a/tools/rosbag/src/rosbag/bag.py +++ b/tools/rosbag/src/rosbag/bag.py @@ -2355,7 +2355,7 @@ def read_topic_index_record(self): return (topic, topic_index) - def seek_and_read_message_data_record(self, position, raw): + def seek_and_read_message_data_record(self, position, raw, return_connection_header=False): f = self.bag._file # Seek to the message position @@ -2399,7 +2399,10 @@ def seek_and_read_message_data_record(self, position, raw): msg = msg_type() msg.deserialize(data) - return BagMessage(topic, msg, t) + if return_connection_header: + return BagMessageWithConnectionHeader(topic, msg, t, header) + else: + return BagMessage(topic, msg, t) class _BagReader200(_BagReader): """