-
Notifications
You must be signed in to change notification settings - Fork 292
Feature/rosbag2 circular logging size duration 2217 #2218
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: rolling
Are you sure you want to change the base?
Feature/rosbag2 circular logging size duration 2217 #2218
Conversation
Signed-off-by: Luke Sy <[email protected]>
- Add StorageOptions.max_splits (+ YAML/params, Python bindings) - CLI: --max-splits (before size/duration) - Writer: delete oldest files when exceeding size, duration, or split count Signed-off-by: Luke Sy <[email protected]>
Signed-off-by: Luke Sy <[email protected]>
309537d to
7b4c6bb
Compare
Signed-off-by: Luke Sy <[email protected]>
Signed-off-by: Luke Sy <[email protected]>
Signed-off-by: Luke Sy <[email protected]>
30f9f5c to
cf16699
Compare
Signed-off-by: Luke Sy <[email protected]>
|
I've committed changes that should address the unit test error. I'm also happy to include @fujitatomoya ’s suggestion to remove |
Simplify storage options by removing max_record_size and max_record_duration fields and CLI arguments. Circular logging now only supports limiting by split count (max_splits). Signed-off-by: Luke Sy <[email protected]>
Signed-off-by: Luke Sy <[email protected]>
MichaelOrlov
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@luke-alloy Thank you for your contribution. This is a long-time-wanted feature that will be very useful.
I've made a thorough review, and overall implementation looks good to me. However, I have a few suggestions:
- The naming is hard. I would propose to rename
--max-splitsparameter to--max_bag_filesto avoid confusion and multiple user questions, like:
- Will splits stop after reaching
max_splits?- Why is there one file when
max_splits = 1? I would expect to have at least two files after the split.
- I would like to see at least one integration test with real files writing and deletion.
To facilitate this, we do have a specialTemporaryDirectoryFixture. Please consider modifying your tests or adding another one. I recently added a similar test in one of my PR. Please, refer to the 81ef9fd#diff-c14a7d44179cf64868ce86b5e60c7f741f957ef368c04a0477ccfe7ccd89f1f2R138-R164 as an example from the #2224.
rosbag2_compression/test/rosbag2_compression/test_sequential_compression_writer.cpp
Outdated
Show resolved
Hide resolved
@MichaelOrlov Thanks for the detailed review! I will update the PR soon. I completely agree regarding the naming confusion—good catch. To maintain consistency with the other CLI flags, would |
|
@luke-alloy Yes. Need to use |
Replace max_splits with max_bag_files across all interfaces (CLI, C++,
Python, YAML, ROS params) for improved clarity. Addressed suggested code changes
Signed-off-by: Luke Sy <[email protected]>
…circular-logging-size-duration-2217 Signed-off-by: Luke Sy <[email protected]>
Remove redundant size check by directly comparing against max_bag_files in the while loop condition. Signed-off-by: Luke Sy <[email protected]>
|
Committed changes to address (most) review comments. |
Test circular deletion with real storage (sqlite3/mcap) to verify files are actually removed from disk when max_bag_files is exceeded. Signed-off-by: Luke Sy <[email protected]>
|
@MichaelOrlov Thanks for the review. I've pushed fixes addressing the comments. Ready for a re-review! |
|
@luke-alloy Thank you for the follow-up.
I think it is a sort of inconsistency and would be considered as a bug. Update: |
MichaelOrlov
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@luke-alloy Thank you one more time.
I've made one more round of review. Overall looks good to me, with one concern regarding adjustments of the message_count and topics_with_message_count in metadata when we are deleting old files, and a few nitpicks findings in the newly added unit test.
| auto msg = std::make_shared<rosbag2_storage::SerializedBagMessage>(); | ||
| msg->topic_name = topic_name; | ||
| msg->recv_timestamp = static_cast<rcutils_time_point_value_t>(i * 100); | ||
| msg->send_timestamp = msg->recv_timestamp; | ||
| uint32_t data = static_cast<uint32_t>(i); | ||
| msg->serialized_data = rosbag2_storage::make_serialized_message(&data, sizeof(data)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do have a make_test_msg(); helper function
| auto msg = std::make_shared<rosbag2_storage::SerializedBagMessage>(); | |
| msg->topic_name = topic_name; | |
| msg->recv_timestamp = static_cast<rcutils_time_point_value_t>(i * 100); | |
| msg->send_timestamp = msg->recv_timestamp; | |
| uint32_t data = static_cast<uint32_t>(i); | |
| msg->serialized_data = rosbag2_storage::make_serialized_message(&data, sizeof(data)); | |
| auto msg = make_test_msg(); | |
| msg->topic_name = topic_name; | |
| msg->recv_timestamp = static_cast<rcutils_time_point_value_t>(i * 100); | |
| msg->send_timestamp = msg->recv_timestamp;``` |
|
@luke-alloy Can you please also regenerate Python stub files (.pyi) according to the https://github.com/ros2/rosbag2/blob/rolling/rosbag2_py/README.md ? |
…k. Updated _storage stubs Signed-off-by: Luke Sy <[email protected]>
Thanks for the feedback! I agree this should be fixed. The challenge: Two options:
Plan: I'll go with Option B since circular logging is a runtime feature anyway—if the process restarts, the session ends. Smaller blast radius too. Can extend to A later if needed. Let me know if you'd prefer Option A. |
When max_bag_files prunes old bag files, message_count and topics_with_message_count were not decremented, showing full session totals instead of only retained files. Adds per-file per-topic tracking and adjusts counts on deletion. Updates test to verify multi-topic scenario. Signed-off-by: Luke Sy <[email protected]>
|
@luke-alloy Thank you for the follow-up. I agree with proposed option B. |
Description
Adds circular logging by split count, record size and duration to rosbag2 recording.
--max-splits--max-bag-filesFixes #2217
Is this user-facing behavior change?
Yes.
--max-splits N--max-bag-files: limit number of retained bagfile splits.ros2 bag record -a --max-bag-size 100MB --max-bag-files 5Did you use Generative AI?
Yes.
Additional Information
--log-levelif needed.metadata.yamlcurrently retains aggregatemessage_countandtopics_with_message_countacross the entire capture, even when older bagfiles are pruned by circular logging. File lists and durations reflect pruning, but those two fields still represent the full session totals.