# Creating a ROS bag file from csv file data

Hi

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 close merge delete

Sort by » oldest newest most voted

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: http://wiki.ros.org/rosbag/Cookbook

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.

more

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

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?

more