Skip to content
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

Record a limited number of messages on each topic #1574

Open
AadityaRavindran opened this issue Feb 27, 2024 · 4 comments
Open

Record a limited number of messages on each topic #1574

AadityaRavindran opened this issue Feb 27, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@AadityaRavindran
Copy link

AadityaRavindran commented Feb 27, 2024

Description

rosbag record has an argument which records a limited number of messages of any topic(s). Eg: rosbag record -l 1000 /chatter

Related Issues

Completion Criteria

  • Add an option ros2 bag record --limit <NUM> <topics>

Implementation Notes / Suggestions

https://github.com/ros/ros_comm/blob/noetic-devel/tools/rosbag/src/record.cpp#L62

Testing Notes / Suggestions

  • Recording should stop after receiving NUM messages on each topic
@AadityaRavindran AadityaRavindran added the enhancement New feature or request label Feb 27, 2024
@MichaelOrlov
Copy link
Contributor

@AadityaRavindran But how to count the number of messages to record if multiple topics need to be recorded with different frequencies?

@AadityaRavindran
Copy link
Author

AadityaRavindran commented Feb 28, 2024

@AadityaRavindran But how to count the number of messages to record if multiple topics need to be recorded with different frequencies?

@MichaelOrlov Regardless of the different frequencies, it should record the same number of messages. If that means one of the topics will finish recording/playing back before other topics are recorded/played back, then that should be totally fine. Recording should stop after all specified topics have the specified number of messages each.
Should have the same behavior as the ros1 version --limit argument http://wiki.ros.org/rosbag/Commandline#rosbag_record

@fujitatomoya
Copy link
Contributor

@AadityaRavindran besides ROS 1 rosbag supports it, what use case do you have? i think this is reasonable option to have, but what could be the actual use case?

@AadityaRavindran
Copy link
Author

@AadityaRavindran besides ROS 1 rosbag supports it, what use case do you have? i think this is reasonable option to have, but what could be the actual use case?

@fujitatomoya I have integration tests where I need to record 1 message each of a few topics (Eg: the static map). These messages are used as inputs to gtest a class. I wrote my own bag recorder using rosbag2_cpp, but it would be extremely useful if I could generalize this to other gtests. I could write a generic bag recorder which takes in just 1 message of a list of topics, but if it was baked into rosbag2 cli, it would be helpful.

In general, if you have topic interfaces to a class, it's extremely useful to be able to write a unit/integration test (ros2 lifecycle nodes makes this easy to write and fast to run)

  1. which reads in the collected bag file using rosbag2_cpp api
  2. publish the data needed by the test through lifecycle nodes
  3. test your use cases

If there were multiple messages needed at different times or order, you would store 1 message each of the various topics in different bags, and play them back whenever needed by the test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants