-
Notifications
You must be signed in to change notification settings - Fork 287
Description
Description
This proposal introduces a new --split-naming option to improve the usability of split bagfiles by allowing timestamps to be included directly in the filenames.
Note
Supplementary comment:
- This proposal changes course from adding a new CLI option to instead adopt timestamp-indexed naming (start-timestamp plus index) as the default behavior for split bagfiles. The goal is to improve human-readability and make filenames naturally sortable by time. To preserve backward compatibility during transition, an explicit flag to force the legacy serial naming (for example
--split-naming=serial) may be provided, but the baseline behavior will be timestamp-indexed naming.
Currently, rosbag2 names split bagfiles using sequential numbering only (record_0.mcap, record_1.mcap, etc.). While this is functional, it makes it harder to quickly understand the time range each file covers when browsing files in a directory.
With the proposed --split-naming option, users could select between:
serial(default): Current behavior with sequential numbering.timestamp-index: Each split bagfile name includes the start timestamp plus an index (e.g.,record_2025-02-21-16-21-00_0.mcap).
This change would provide clearer, human-readable filenames, giving users immediate temporal context and helping those migrating from ROS1 workflows feel more at home. It is especially valuable in continuous operation scenarios, where stopping and restarting ros2 bag record frequently is not practical for systems with many topics or complex discovery.
Related Issues
This proposal is related to #1917 (Timestamp split bagfiles instead of serial numbering), which in turn is part of #1915 (Always-on recording). While all of these proposals aim to make bagfile naming more informative, they serve slightly different needs:
- Purpose: Timestamp split bagfiles instead of serial numbering #1917 is designed for always-on recording, where session boundaries do not apply. This proposal focuses on general split recording scenarios where timestamp context is important.
- Format: Timestamp split bagfiles instead of serial numbering #1917 suggests timestamp-only names (
recording_20250221T162100Z.mcap). This proposal keeps both timestamp and index (recording_2025-02-21-16-21-00_0.mcap), ensuring both clarity and ordering. - Compatibility: These approaches can coexist under a unified
--split-naminginterface, giving users flexibility to choose the scheme that best fits their workflow.
Completion Criteria
- Add
--split-namingoption to theros2 bag recordcommand. - Implement
serialmode (default, maintains current behavior). - Implement
timestamp-indexmode with filesystem-safe timestamp format. - Ensure compatibility with all splitting mechanisms (
--max-bag-duration,--max-bag-size, manual splitting via~/split_bagfile). - Preserve backward compatibility by defaulting to
serial. - Add appropriate unit and integration tests.
- Update documentation and CLI help text.
Implementation Notes / Suggestions
- Timestamps should be filesystem-safe and sortable (suggested:
YYYY-MM-DD-HH-mm-ss). - Implementation would involve extending the
SequentialWriterto handle naming modes. - Use
std::strftimeor similar for formatting. - Recommend UTC timestamps for consistency across environments.
- Timestamp should reflect the start time of each bagfile.
- Index should always be included to ensure uniqueness, even if multiple splits occur in the same second.
Testing Notes / Suggestions
-
Unit tests: Verify filename generation for both modes.
-
Integration tests: Confirm behavior with size, duration, and manual splits.
-
Edge cases:
- Rapid splits (sub-second).
- Cross-platform filesystem compatibility.
- Uniqueness guarantees under load.
-
Backward compatibility: Verify unchanged behavior when
--split-namingis not specified. -
Playback compatibility: Ensure generated bagfiles can be played back regardless of naming mode.