ROS Resources: Documentation | Support | Discussion Forum | Service Status | Q&A
Ask Your Question

Is there a way to save all rosbag data into a .csv or text file ?

asked 2013-02-12 05:18:37 -0500

Hi all!

I would like to extract the data from the rosbag and convert it into text or .csv file to use the data into Matlab and Excel. Is this possible ?

edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted

answered 2013-05-29 11:35:26 -0500

NickSpeal gravatar image

updated 2014-04-29 01:34:25 -0500

fivef gravatar image

Please see this answer for a simple script to save all topics in the bag file as a seperate csv.

Please let me know if you found this useful or if you have any suggestions for how to improve it.

edit flag offensive delete link more

answered 2013-02-12 07:22:23 -0500

Mani gravatar image

This is taken from this answer for a similar question:

For simple message formats, you can convert directly to CSV from the command line:

rostopic echo -b file.bag -p /topic

This won't work well if your bag file contains arrays/images/pointclouds/etc... as it renders the entire message to text.

edit flag offensive delete link more


This is so awsome

kaiyu gravatar imagekaiyu ( 2017-02-10 16:50:44 -0500 )edit

What are the meaning of the -b and -p flags ?

tonyParker gravatar imagetonyParker ( 2018-06-04 05:49:13 -0500 )edit

answered 2013-02-12 05:42:11 -0500

Here's a quick way:

rosbag play mybag.bag
rostopic echo /foo > output.txt

This will output all message in the topic /foo to a yaml-formatted text file. You can then parse the file. It might be useful to output to multiple files for different fields. Let's say the message type on /foo is Pose:

rosbag play mybag.bag
rostopic echo /foo/position/x > output_x.txt
rostopic echo /foo/position/y > output_y.txt
rostopic echo /foo/position/z > output_z.txt

You can also look into bagys, which are an extension of the concept above.

edit flag offensive delete link more


Hi there! Is the other way around possible. i.e., convert from a .txt to a .bag? Thanks in advance!

TSC gravatar imageTSC ( 2014-08-26 13:45:29 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2013-02-12 05:18:37 -0500

Seen: 22,794 times

Last updated: Apr 29 '14