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

How to extract data from *.bag?

asked 2011-02-16 18:38:45 -0500

Changhyun Jun gravatar image

updated 2014-01-28 17:09:10 -0500

ngrennan gravatar image

How to extract data from *.bag?

I recorded my odomerty and laser data using rosbag. I want to extract (specific) data stream(text format) from recorded bagfiles. (time, step, odometry[x,y,...], laser data, ...) Becuase my unfinshied project are programed by matlab.

Question. 1) How to extract data from *.bag? (using matlab, C/C++ or ROS API...)

edit retag flag offensive close merge delete

Comments

when you see an answer you like, mark it as an accepted answer
mmwise gravatar image mmwise  ( 2011-02-17 09:32:40 -0500 )edit

Ok, is it possible to extract the contents of the bag file time, step, odometry[x,y..] and write our own customize code in cpp or java to move the robot through particular location of the map. Does we need to create the package with our customize code? How to combine all in built packages of ros and our own package?

RB gravatar image RB  ( 2013-10-27 19:40:10 -0500 )edit

The script worked well for me, but I didn't test for a bunch of different bags. I'd imagine it wouldn't work if the bag contains data of a type that is not just a simple number

mariakatosvich gravatar image mariakatosvich  ( 2016-09-09 01:49:54 -0500 )edit

@changhyun, did you find the relevant solution? I am also trying to retrieve the odom data in terms of each step , data and all. The below "highlighted" answer is not giving me the required output. Did you find the solution? Kindly help

Ayush Sharma gravatar image Ayush Sharma  ( 2017-03-12 08:18:09 -0500 )edit

13 Answers

Sort by ยป oldest newest most voted
0

answered 2012-04-04 01:58:13 -0500

tayyab gravatar image

Make sure you have set the path variable and add these two lines to the top of your main python script to avoid any dependency errors.

import roslib; roslib.load_manifest('your_package_name')

then write your rest of the script. Please keep in mind that this does not need to be in every python script but just in the main entry point.

edit flag offensive delete link more
0

answered 2011-12-10 02:01:28 -0500

suzuki tarou gravatar image

updated 2011-12-10 02:02:14 -0500

I followed guide at http://www.ros.org/doc/api/rosbag/html/c++/ when i run the code it tells me "ImportError: No module named rosbag"

Traceback (most recent call last): File "/home/user/ros_workspace/beginner_tutorials/nodes/read_bag.py", line 4, in <module> import rosbag ImportError: No module named rosbag

please tell me how to fix this!

edit flag offensive delete link more

Comments

2
Don't hijack the thread. Open up a new question instead.
130s gravatar image 130s  ( 2011-12-10 04:43:31 -0500 )edit
-1

answered 2014-11-11 15:51:57 -0500

just type the following in the directory of bag file:

rostopic echo -b bagname.bag -p /topicname > filename.csv

the data will save into filename.csv then you can use it in matlab

edit flag offensive delete link more

Comments

This is already covered in the answer by @kwc

ahendrix gravatar image ahendrix  ( 2014-11-11 16:13:38 -0500 )edit

Question Tools

7 followers

Stats

Asked: 2011-02-16 18:38:45 -0500

Seen: 94,326 times

Last updated: Oct 11 '20