Rosanswers logo

I am trying to save data into bag file to run gmapping later. I don't want to do it through command line using rosbag, rather i want to write a python script to save the data into bag file.

I tried saving just Laserscan messages into bag file by following this tutorial and it worked like charm. :)

But in order to simulate gmapping i have to save data from multiple topics i.e /tf and /scan ,so i tried using message filters to scan data from both tf and scan, but it always throwing me errors.

I think most people saved the data into bag file before, to simulate gmapping. Can someone tell me how they did it?


Originally posted by krishna43 on ROS Answers with karma: 63 on 2016-07-15

Post score: 0


1 Answer 1


Rosanswers logo

It would help if you'd post the error and and give short code snippet. However, I think you are trying to reinvent the wheel and I am pretty sure that the vast majority of people used the commandline tool to save data for gemapping. rosbag does exactly what you want to do when you start it from the command line and is well tested even thought it might have its flaws. If you want to start recording bag files from a python script, have a look at the subprocess package in python. This allows you to run rosbag record from the python script instead of the command line and you do not have to reimplementing its functionality.

Originally posted by Chrissi with karma: 1642 on 2016-07-15

This answer was ACCEPTED on the original site

Post score: 1

Original comments

Comment by krishna43 on 2016-07-15:
Thank you. I found how i can include rosbag record commands in launch file.

Comment by Chrissi on 2016-07-15:
If that also works for you, even better ;)


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.