ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

fast rosbag to csv conversion

asked 2021-03-26 06:32:47 -0500

felixN gravatar image


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

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2021-03-26 07:48:55 -0500

piupiu_island gravatar image

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')
edit flag offensive delete link more

Question Tools



Asked: 2021-03-26 06:32:47 -0500

Seen: 2,849 times

Last updated: Mar 26 '21