Skip to content

Feature: Add circular logging (by size/duration) to ros2 bag record #2217

@luke-alloy

Description

@luke-alloy

Description

This feature introduces parameters to ros2 bag record to control recording file size or duration limits, enabling both circular logging.

  • --max-record-size: Sets a maximum total size (in bytes) for all bag files. When this limit is exceeded, the oldest file(s) are deleted to maintain the limit. This enables continuous, size-bounded circular logging.
  • --max-record-duration: Sets a maximum total duration (in seconds) spanning all bag files. When this limit is exceeded, the oldest file(s) are deleted. This enables continuous, time-bounded circular logging.
  • [optional] --max-splits: Stops the recording session automatically after a specified number of split files have been created. This is a stopping condition, not a circular logging mechanism.

Related Issues

Completion Criteria

  • ros2 bag record accepts --max-record-size <SIZE_BYTES>. When total size is exceeded, the oldest files are deleted, and recording continues.
  • ros2 bag record accepts --max-record-duration <DURATION_SEC>. When total duration is exceeded, the oldest files are deleted, and recording continues.
  • All new options are documented.

Implementation Notes / Suggestions

  • Logic for monitoring total size, duration, and split file count should be implemented within the SequentialWriter class.
  • The SequentialWriter must include a mechanism to identify and delete the oldest split files when --max-record-size or --max-record-duration limits are breached.
  • To limit checking and simplify implementation, checking of size and duration only happens when splitting files.

Testing Notes / Suggestions

  • --max-record-size Test: Record with a small size limit and file splitting. Verify that total size remains bounded and old files are deleted.
  • --max-record-duration Test: Record with a short duration limit and file splitting. Verify that total duration remains bounded and old files are deleted.
  • --max-splits Test: Record with splitting and --max-splits 5. Verify recording stops after exactly 5 files.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions