How to read a bag file in ROS2?
Hello guys,
I have seen searching about it and found some discussions (1, 2, 3), but I couldn't make things work (I explain why below).
My problem
I have some bag files (db3 files) that I saved using rosbag2 record from here. Now, I would like to get information from the file and save it in a different format (.txt, .mat, it does not matter). For example, get messages from a specific topic and plot all data.
It seems that there is no python API ready yet, as there was for ROS1.
Possible solutions/Problems I found
I thought about some solutions, but faced a few limitations:
- Replay data, create a node that subscribes to all these topics, and then process this data in "real-time", saving it in a different format in the end.
- The problem of doing this would be that it takes the time of the recorded data. If the experiment duration is 15minutes, it will take that long to get all data. And it does not make much sense for me.
- Create my own python API that opens the db3 file (sqlite3) and then process it.
- I actually developed this quite a bit. I can open the file, see all topics, and get all messages on those topics. However, when it is time to interpret this data, it gets confusing as to how the cdr file is constructed. I explained that a little bit more here.
- Use the code that is being under development at the rosba2 github.
- It seems that some packages (in cpp and in py) are starting to deserialize data. But I am really noob at this. I can build the rosbag2_cpp package, but I don't know how to test it. I don't know where to start from there actually.
Any help is really appreciated.
Using
- Ubuntu 20.04
- ROS2 foxy
- rosbag2