ros-tooling / rosbag2_storage_mcap

rosbag2 storage implementation for MCAP file format
https://mcap.dev/
Apache License 2.0
32 stars 5 forks source link

Writing order seems to be wrong in new rosbag writer #71

Closed fnobis closed 1 year ago

fnobis commented 1 year ago

The writing of ros messages to file seems to have changed again since: https://github.com/ros-tooling/rosbag2_storage_mcap/issues/49

Since the newest update of the debian packages of ros humble, I notice an error in my script which is caused by the message order in a rosbag I create.

I write a rosbag with the API as shown here: https://mcap.dev/docs/python/ros2_example.html Then I read the same rosbag again and I need the messages to have the same order as I have written them.

E.g.

  1. camera t=0.0
  2. camera_markers t=0.1
  3. camera t=1.0
  4. camera_markers t=1.1

and not

camera_markers camera camera camera_markers

I set the timestamps as above for both the header and the bag time while writing the messages, and write the messages to teh bag in that order (checked in the debugger).

When I read the rosbag, however the rosbag API shows me the camera_markers message first. I expected that camera would be first, since it is written first via the code and has the lower timestamp in both the header and in the rosbag.

What defines the ordering in the bag file now? Is there anyway to set the mesage ordering with the new version?

jtbandes commented 1 year ago

Thanks for the report. Our first step will be trying to reproduce the issue. Are you still using the gist from https://github.com/ros-tooling/rosbag2_storage_mcap/issues/49#issuecomment-1231388233 or can you share a script that reproduces the problem without needing any separate input files (or if you can provide the input files)?

jhurliman commented 1 year ago

@fnobis just following up on this issue to see if you can provide more info on reproducing the problem.

fnobis commented 1 year ago

Yes, the general workflow is still the same as above. I create and write the messages "a" and "b" in an alternating order: "abab". I read with "while has_next" and an if statement to handle different topics, when i reqd the back it first jumps into the "b" if statement.

I might be able to provide more data on this mid december.

james-rms commented 1 year ago

in rolling you are able to set the read order using set_read_order() on SequentialReader instances and also when directly using the rosbag2_storage plugin API.