Ask Your Question
4

How can I use bag file data in Matlab?

asked 2011-09-27 08:21:02 -0500

fresh_ros_user gravatar image fresh_ros_user
41 3 4 7

I have datas in bag file such as velocity and acceleration from the sensors. I want to read data with respect to time domain to make calculations in Matlab. How can I gain the data and use in Matlab? Thanks for your answers.

edit retag flag offensive close delete

1 Answer

Sort by ยป oldest newest most voted
14

answered 2011-09-27 08:31:16 -0500

DimitriProsser gravatar image DimitriProsser flag of United States
8333 45 82 153

If you play back the bag, you can use:

rostopic echo -p /topic_name

to display the data in a MatLab-friendly format. You can output this to a text file with:

rostopic echo -p /topic_name > data.txt

Or, you can even convert a topic directly to CSV with:

rostopic echo -b file.bag -p /topic

NOTE: This will only work with simple message types. LaserScans, PointClouds, arrays, etc won't work very well because the entire message is rendered to text.

The other option would be to use the rosbag API, located here to load the data into a C++ program and manipulate it that way.

edit flag offensive delete publish link more

Comments

Or use the python API along with scipy.io.savemat to write out a .mat file. Dan Lazewatsky ( 2011-09-27 09:38:37 -0500 )edit

Your answer

Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
1 follower

subscribe to rss feed

Stats

Asked: 2011-09-27 08:21:02 -0500

Seen: 1,615 times

Last updated: Feb 04 '12