fast rosbag to csv conversion
Hi,
I have rather big bag files (1 hour of recording, about 1.2GB). Those bag files contain nearly all the topics, except the image topics.
I regularly want to do some analysis of the recorded data using excel, so I need to extract the relevant data as .csv
The solution I found (that works) is :
rostopic echo -b my_bag_file.bag -p /my_topic>my_csv_file.csv
The issue is that it is very slow, specially when I need to retrieve several topics.
Do you know any fast(er) way to extract several topics (one after each other or several at once or all at once)? As a result, I would like either one global csv file or one per topic, but in both cases with some form of timestamp (real timestamp or clock time, both are fine). If it can make things faster, I can often reduce the time interval. But I'm also fine with getting the full record of the rosbag.
Do you have any solutions?
Thanks a lot in advance
Asked by felixN on 2021-03-26 06:32:47 UTC
Answers
you can use bagpy in python, give which topic you want, the topic data will be automatically extracted into a csv file.
For example, if you want to extract '/odom' topic, after running below code, you will find a csv file named "odom.csv" in the script folder. Hope it helps.
from bagpy import bagreader
b = bagreader('./sample_mission.bag')
bmesg = b.message_by_topic('/odom')
Asked by piupiu_island on 2021-03-26 07:48:55 UTC
Comments