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

Creating a ROS bag file from csv file data

asked 2014-01-17 22:00:21 -0500

Sentinal_Bias gravatar image


I have a data set, which contains several time stamped csv files.

One of the files contains time stamped gps data and the other contains LIDAR data. I want to convert these csv files into a Rosbag file.

What would be the simplest way of making a bagfile?

I have opened a bagfile and all I see is hex I guess this is because of some compression? Also I have looked at the format of bagfiles and it looks complicated. Are there any tools or libraries to write bag-files which are simple to use?

I guess the alternatives would be for me to parse the files, try and play them back using the timestamps, publish rostopics and use the rosbag record. However with this method the original timestamps will not be maintained and I am not sure if I can publish all the topics at the appropriate frequencies.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2014-01-20 03:46:29 -0500

demmeln gravatar image

I believe the simplest and most robust way would be to write a little standalone tool that parses your cvs file, creates appropriate ros message objects, and uses the rosbag API to directly write a bagfile. You can use either C++ or python.

This way you are not dependent on a running ROS core and you don't have to worry about publishing rate, dropped messages etc, while getting the fastest conversion rate possible.


There are some small examples manipulating existing bad files. In your case you have the cvs files as input, and only for output use rosbag:

P.S.: Even if you use the publishing node variant, if you set the header.stamp value properly according to your cvs file, you should end up with correct timestamps in the bag file. Note that while in the bag file the stamp of when each message was recorded is not part of the message itself. If the recorded message has a header, this is in general a different timestamp (namely the one you set when publishing the message). So when you read the message back from the bag file later, you likely want to use the timestamp in the header, not the one of when the message was recorded.

edit flag offensive delete link more


Good links!

PeterMilani gravatar image PeterMilani  ( 2014-01-20 11:36:29 -0500 )edit

answered 2014-01-19 12:26:16 -0500

as you suggest, I think if you wrote a node that reads your csv file, and then publishes the information across a topic to ros-bag that would be the simplest way to do this. It may be slow, but I guess you could play with the publishing rate, or the way you structure your messages.

As for ensuring your time stamps are correct, ros::time has two elements ros::time::nsecs and ros::time::secs, plus a number of other functions that you can use to place your csv time in the message.header.stamp value. It seems you may have tried this as well, did the timestamps not come through correctly?

edit flag offensive delete link more

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: 2014-01-17 22:00:21 -0500

Seen: 4,843 times

Last updated: Jan 20 '14