4.3. How to convert between Ros Bag and Apollo Record?
How to convert Ros Bag into Apollo Record, and how to convert Apollo Record back into Ros Bag?
Maintainer:daohu527@gmail.com, yhuai@uci.edu
Version:1.0.0
Date:06/05/2024
Description:This document describes necessary tools and steps to convert data between Ros Bag and Apollo Record.
4.3.1. Answer
Ros Bag and Apollo Record are two different data storage formats. Because these two formats have differences in file structure and message definition, data conversion is required.
The process of conversion can be summarized into the following three key steps:
Read ROS Bag Data: First, we need to open the ROS Bag file using the corresponding tool or library, and read the stored ROS messages. In this step, we will get the type of ROS messages, and prepare for the subsequent conversion.
- Convert Message FormatAfter reading the ROS messages, we need to convert these messages from ROS
format to the format supported by the Apollo. This usually involves parsing the content of ROS messages, and reorganizing this data according to the message definition of Apollo.
- Save as Apollo RecordAfter completing the conversion of the message format, we will save the new Apollo
messages as an Apollo Record file. By completing this step, messages collected from the original ROS system can now be read and used by Apollo.
To simplify the process described above, we provide the bag_convert tool.
With this tool, users only need to specify the path of the ROS Bag file and the
path of the output Apollo Record file, and the data format conversion can be easily completed.
4.3.1.1. Installation
pip3 install bag_convert
4.3.1.2. Ros Bag to Apollo Record
bag_convert -m=b2r -b=data/input.bag -r=data/output.record
4.3.1.3. Apollo Record to Ros Bag
bag_convert -m=r2b -r=data/input.record -b=data/output.bag