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

Creating a ROS bag file from csv file data

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

Sentinal_Bias gravatar image

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

2 Answers

Sort by ยป oldest newest most voted
2

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

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.

API: http://wiki.ros.org/rosbag/Code%20API

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.

edit flag offensive delete link more

Comments

Good links!

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

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

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

Question Tools

2 followers

Stats

Asked: 2014-01-17 22:00:21 -0600

Seen: 5,414 times

Last updated: Jan 20 '14