AIT-Assistive-Autonomous-Systems / ros2bag_tools

Tool extensions for ros2bag cli
122 stars 34 forks source link

Cutting bags containing messages with transient_local durability #20

Closed FranzAlbers closed 1 year ago

FranzAlbers commented 1 year ago

Thanks for developing these awesome rosbag2 extensions!

When cutting a rosbag2, all messages outside of a certain time span are dropped. This is also the case for messages with transient_local durability: E.g., the tf tree published on /tf_static is lost in the new bag, when we cut a time span that does not contain the very beginning of the original bag.

In my opinion, messages with transient_local durability should be always carried over when cutting a portion of a bag. Is there currently a way to do so?

Kettenhoax commented 1 year ago

Thanks for the feedback!

There's currently no way to handle transient_local durability, but I understand the need and am happy to review a PR that extends cut for this case.

I think the solution can't carry over the affected messages with their original timestamp. For messages recorded at the start, the original bag timestamp would leave a gap between it and the next message of a topic affected by the cut. This makes ros2 bag play seem unresponsive in the beginning. To avoid this, the (bag) timestamp of the carried-over message would need to be set to the new bag start time. Same thing at the end.

Since this behaviour can be just as surprising as the message being removed, an opt-in argument is IMO the best way to add this functionality. I.e. an additional cut arg --snap-topics TOPIC [TOPIC..], that keeps all messages of given topics but snaps their timestamps to the start and end of the bag.