data_tamer icon indicating copy to clipboard operation
data_tamer copied to clipboard

MCAP logging error: Message: invalid magic bytes in Footer: 0xD0FF0B0000000000

Open scastro-bdai opened this issue 9 months ago • 4 comments

Hi @facontidavide!

I've been trying to get started with this tool and I'm probably doing something wrong with the MCAPSink.

So first of all, I was running into the chunking issue explained in https://github.com/PickNikRobotics/data_tamer/issues/20 -- since I was only trying to log a single scalar double value over time, I wasn't seeing anything coming up on file until I logged a ton of data.

Next up, when I finally get a file that's partially full, I try to load it into PlotJuggler and get this error:

 Message: invalid magic bytes in Footer: 0xD0FF0B0000000000

Is there some special way to make sure the file/buffer are closed properly? Or something missing? Here is my code:

(in the constructor)

  mcap_sink_ = std::make_shared<DataTamer::MCAPSink>("ruckig_traj_executor_log.mcap");
  log_channel_ = DataTamer::LogChannel::create("trajectory");
  log_channel_->addDataSink(mcap_sink_);

  log_channel_->registerValue("joint_1", &joint_value_);

in some subscriber callback

  joint_value_ += 1.0;
  if (!log_channel_->takeSnapshot()) {
    RCLCPP_INFO_STREAM(get_node()->get_logger(), "LOGGING FAILED!");
  } else {
    RCLCPP_INFO_STREAM(get_node()->get_logger(), "LOGGING SUCCEEDED!");
  }

Confirming the "LOGGING SUCCEEDED" printout is happening.

Any ideas? Thanks!

scastro-bdai avatar Feb 27 '25 20:02 scastro-bdai

I could be wrong, but I have also had similar issues and it seems like issues like that are due to the mcap writer not properly destructing and getting to finish writing the file.

jlack1987 avatar Feb 27 '25 20:02 jlack1987

yes, that is the problem... i need to find a way to make this less fragile to crashes

facontidavide avatar Feb 27 '25 20:02 facontidavide

Yep -- ok, confirming that for whatever reason, this code is not properly destroying the object containing the MCAPSink. I blame the use of pluginlib in this whole mess :)

If I manually reset() the shared pointer to the sink during execution, the file reads correctly in PlotJuggler.

Not sure if you'd like to leave this open or closed, but I defer to you -- thanks, guys!

scastro-bdai avatar Feb 27 '25 21:02 scastro-bdai

I will at the very least confirm that properly destructing "mcap stuff" can be finicky. I haven't really dug into it, but I think it may be the provided mcap writer or something bc i've written an mcap writer that uses a json schema and it suffers from similar issues in that you just have to be super careful to make sure it destructs properly

jlack1987 avatar Jun 09 '25 12:06 jlack1987