ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

bag file is empty after rosbag reindexing and fixing file

asked 2018-09-03 02:51:14 -0500

Lucas02 gravatar image

updated 2018-09-04 02:58:36 -0500

Hello everyone!

I'm trying to convert file into .bag file so I can play it inside rqt_bag program. The thing is, I tried to follow this steps which is to:

  1. rosbag reindex the file, and then
  2. rosbag fix file into .bag file

I do get the message that Bag migration is successful. after running rosbag fix, but when trying rosbag play it says that there are 0 messages to play.

Someone else also asked this question, but there are no answers, so I'm trying again, maybe you can help me.

EDIT: To anybody else reading this question, to recap:

  1. run rosbag record with --chunksize=<some_number> option. <some_number> should be a number which is appropriate for how much data in KB you are sending and/or receiving.
  2. run rosbag reindex <your_bag_active_file>, e.g. rosbag reindex
  3. run rosbag fix <your_bag_active_file> <new_bag_file_name>, e.g. rosbag fix mybagfile.bag
edit retag flag offensive close merge delete


What is the size of the bag before you fix it?

Reamees gravatar image Reamees  ( 2018-09-03 03:48:22 -0500 )edit file is 528,4 kB and .bag file after reindex and fix is 4,1 kB.

Lucas02 gravatar image Lucas02  ( 2018-09-03 04:09:44 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2018-09-03 05:43:07 -0500

Reamees gravatar image

There probably is no actual data in the bag file. I was able to reproduce the problem by terminating the bag in a "not polite way" before the bag had reached the "chunksize". (768kB according to the wiki).

From the wiki:


Advanced. Record to chunks of SIZE KB (Default: 768). This is a buffer within the bag file object. Lowering this value will result in more writes to disk.

So I guess anything still in the buffer when the process dies unexpectedly is lost. If you need to work with such small amounts of data and the application is prone to cause recording to crash then you could lower the chunksize.

edit flag offensive delete link more


Ah okay, will try this if it works.

Lucas02 gravatar image Lucas02  ( 2018-09-03 07:27:04 -0500 )edit

Try it and if it helps you sometimes recover some data then great. In the end it would be best to minimize the need to fix your bags afterward, shutting down the recording of the bag gently, e.g pressing ctrl+c.

Reamees gravatar image Reamees  ( 2018-09-03 08:15:27 -0500 )edit

I can confirm that this works beautifully. Thank you!

Lucas02 gravatar image Lucas02  ( 2018-09-04 02:40:47 -0500 )edit

Good! Thanks for accepting the answer! It would also be good to keep in mind that reducing the chunksize has some implications. If you start getting more data at some point it might be too much overhead and might cause problems.

Reamees gravatar image Reamees  ( 2018-09-04 04:31:35 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2018-09-03 02:51:14 -0500

Seen: 4,264 times

Last updated: Sep 04 '18