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

Composable Player and Recorder nodes #902

Closed
4 tasks done
hidmic opened this issue Nov 2, 2021 · 14 comments · Fixed by #1419
Closed
4 tasks done

Composable Player and Recorder nodes #902

hidmic opened this issue Nov 2, 2021 · 14 comments · Fixed by #1419
Labels
enhancement New feature or request

Comments

@hidmic
Copy link
Contributor

hidmic commented Nov 2, 2021

Description

To enable intra-process bag replaying and recording, sometimes necessary when dealing with high-frequency and/or high-bandwidth data streams, both rosbag2_transport::Player and rosbag2_transport::Recorder nodes have to be exposed as rclcpp components.

Completion Criteria

  • Allow rosbag2_transport::Player node configuration via parameters.
  • Register rosbag2_transport::Player node as a component.
  • Allow rosbag2_transport::Recorder node configuration via parameters.
  • Register rosbag2_transport::Recorder node as a component.

Testing Notes / Suggestions

Updating test_record.cpp and test_play.cpp to use intra-process comms and inter-process comms for their nodes should do.

@doisyg
Copy link

doisyg commented Nov 13, 2022

Also interested in having composable and IPC player capability. What is the current status for Humble ? Any plans ?

@berndpfrommer
Copy link
Contributor

Is introducing PR #892 an option? I don't think it would interfere with implementing a better solution later down the road and it would keep my stopgap solution alive.

@roncapat
Copy link
Contributor

roncapat commented Jul 12, 2023

Is someone already tackling this? @Karsten1987? Otherwise, I may try to open a PR as soon as I find some spare time.

Player::Player(const std::string & node_name, const rclcpp::NodeOptions & node_options)
: rclcpp::Node(node_name, node_options)
{
// TODO(karsten1987): Use this constructor later with parameter parsing.
// The reader, storage_options as well as play_options can be loaded via parameter.
// That way, the player can be used as a simple component in a component manager.
throw rclcpp::exceptions::UnimplementedError();
}

@emersonknapp
Copy link
Collaborator

emersonknapp commented Jul 12, 2023

@roncapat - @Karsten1987 has moved on to other projects and hasn't been working on rosbag2 for a while, none of the active maintainers currently have this on their plate, so contribution is very welcome. Perhaps you'd like to attend the rosbag2 working group Friday morning to discuss the design? https://calendar.google.com/calendar/u/0/embed?src=agf3kajirket8khktupm9go748@group.calendar.google.com (note default UTC time zone, it's 9am Pacific). If that's not feasible for you we can discuss over GitHub - feel free to open draft PRs early in development and ping @MichaelOrlov and myself to talk about overall structure.

@roncapat
Copy link
Contributor

@emersonknapp thank you very much for feedback! I'll try (and let you know) if I can manage to align friday meeting in my agenda, otherwise I will surely draft something here on github and discuss with you here - happy to contribute if I can :)

@roncapat
Copy link
Contributor

roncapat commented Jul 13, 2023

So, let's start with the first issue: RecordOptions, PlayOptions and StorageOptions feature many uint64_t and even some size_t attributes.
However, rclcpp parameter API only supports signed integers, being int64_t the widest. We would loose the ability to set the upper half of the uint64_t value range.
About size_t, it is both unsigned and platform dependent (even if I think on 90% of current ROS 2 setups with 64 bit x86 or ARM, it should correspond again to an uint64_t).

Do you have an opinion on this, or experience from other packages? Can we afford to loose half of the positive interval for those values?

My personal answer is: of course yes (see below) but looks a bit ugly to be forced by parameter system not to parse an unsigned integer. So I'd implement some ugly-yet-needed type casts there...

Example to prove we are not loosing anything concrete here:
StorageOptions.max_bagfile_size --> still around 8 Petabytes...
StorageOptions.max_bagfile_duration --> countless years...
StorageOptions.max_cache_size --> quintillions of messages...

PlayOptions.read_ahead_queue_size --> quintillions of messages...

RecordOptions.compression_queue_size --> quintillions of messages...
RecordOptions.compression_threads --> are all there enough CPU cores in the whole world?

@emersonknapp
Copy link
Collaborator

Personal opinion on that opinion - it ain't ugly if it's needed. We can just validate that the parameters are positive, and cast them to the necessary types. No big deal. Anybody who wants that extra range is doing something very special and can work around it by not using Parameters for configuration.

@roncapat
Copy link
Contributor

Thanks! BTW, the linked PR builds fine, but I will probably have time to test it properly not earlier than August.

If you have time to review even part of the proposed code in the meantime, I will be very happy to incorporate feedbacks :)

@nachovizzo
Copy link

Any update on this one folks 👼 ? I'm happy to jump and help if that's neccesary

@roncapat
Copy link
Contributor

roncapat commented Nov 2, 2023

Any update on this one folks 👼 ? I'm happy to jump and help if that's neccesary

Working hard right now on this prerequisite #1476! Feel free to follow or suggest improvements of course. #1476 started as a small tweak to better support configurability of QoS from parameter files, and became quite a huge patch due to all the inter-dependencies here-and-there in the codebase.

@roncapat
Copy link
Contributor

roncapat commented Dec 1, 2023

@nachovizzo lots of updates on the associated PR #1419. Would you like testing / provide some feedback?

MichaelOrlov added a commit that referenced this issue Dec 11, 2023
* Squasgh to ease rebase

Signed-off-by: Patrick Roncagliolo <ronca.pat@gmail.com>

* Remove TODO for keyboard handlers

Signed-off-by: roncapat <ronca.pat@gmail.com>
Signed-off-by: Patrick Roncagliolo <ronca.pat@gmail.com>

* Change structure

Signed-off-by: roncapat <ronca.pat@gmail.com>
Signed-off-by: Patrick Roncagliolo <ronca.pat@gmail.com>

* Fix

Signed-off-by: roncapat <ronca.pat@gmail.com>
Signed-off-by: Patrick Roncagliolo <ronca.pat@gmail.com>

* Fix

Signed-off-by: roncapat <ronca.pat@gmail.com>
Signed-off-by: Patrick Roncagliolo <ronca.pat@gmail.com>

* QoS parsing

Signed-off-by: roncapat <ronca.pat@gmail.com>
Signed-off-by: Patrick Roncagliolo <ronca.pat@gmail.com>

* Fix

Signed-off-by: roncapat <ronca.pat@gmail.com>
Signed-off-by: Patrick Roncagliolo <ronca.pat@gmail.com>

* Uncrustify

Signed-off-by: roncapat <ronca.pat@gmail.com>
Signed-off-by: Patrick Roncagliolo <ronca.pat@gmail.com>

* Draft comparison of passed vs parsed params

Signed-off-by: roncapat <ronca.pat@gmail.com>
Signed-off-by: Patrick Roncagliolo <ronca.pat@gmail.com>

* Fix shared_from_this() issue, param file & paths

Signed-off-by: roncapat <ronca.pat@gmail.com>
Signed-off-by: Patrick Roncagliolo <ronca.pat@gmail.com>

* Fixes after rebase

Signed-off-by: Patrick Roncagliolo <ronca.pat@gmail.com>

* Fixes to handle durations

Signed-off-by: Patrick Roncagliolo <ronca.pat@gmail.com>

* Better test output

Signed-off-by: Patrick Roncagliolo <ronca.pat@gmail.com>

* Drafting record param test

Signed-off-by: Patrick Roncagliolo <ronca.pat@gmail.com>

* Fixing recorder issues

Signed-off-by: Patrick Roncagliolo <ronca.pat@gmail.com>

* Fixes

Signed-off-by: Patrick Roncagliolo <ronca.pat@gmail.com>

* Draft component load test

Signed-off-by: Patrick Roncagliolo <ronca.pat@gmail.com>

* Composition tests working

Signed-off-by: Patrick Roncagliolo <ronca.pat@gmail.com>

* Uncrustify

Signed-off-by: Patrick Roncagliolo <ronca.pat@gmail.com>

* Cpplint

Signed-off-by: Patrick Roncagliolo <ronca.pat@gmail.com>

* Cpplint

Signed-off-by: Patrick Roncagliolo <ronca.pat@gmail.com>

* Fix play_offset bug

Signed-off-by: Patrick Roncagliolo <ronca.pat@gmail.com>

* Fix storage defaults bug

Signed-off-by: Patrick Roncagliolo <ronca.pat@gmail.com>

* Get rid of temporal conversion crutches using map<string, Rosbag2QoS>

Signed-off-by: Michael Orlov <michael.orlov@apex.ai>

* Use const ref to node in the options getter functions

- Also made a style clean up in getter functions

Signed-off-by: Michael Orlov <michael.orlov@apex.ai>

* Cleanups in get_storage(/play/record)_options functions

Signed-off-by: Michael Orlov <michael.orlov@apex.ai>

* Move RosBag2RecordTestFixture insight test_record_params.cpp

Signed-off-by: Michael Orlov <michael.orlov@apex.ai>

* Rename overrides.yaml to the qos_profile_overrides.yaml file

Signed-off-by: Michael Orlov <michael.orlov@apex.ai>

* Rename params_player.yaml to the player_node_params.yaml

Signed-off-by: Michael Orlov <michael.orlov@apex.ai>

* Rename params_recorder.yaml to the recorder_node_params.yaml

Signed-off-by: Michael Orlov <michael.orlov@apex.ai>

* Replace Rosbag2Duration by rclcpp::Duration

Signed-off-by: Michael Orlov <michael.orlov@apex.ai>

* Cleanup in functions which are getting values from node parameters

- Address issues in duration and integer parameters conversion
- Introduce `declare_integer_node_params(..)` and
`get_duration_from_node_param(..)` helper functions

Signed-off-by: Michael Orlov <michael.orlov@apex.ai>

* Bugfix. Adjust min-max ranges for get_duration_from_node_param(..)

- Also add expected range to the exception message

Signed-off-by: Michael Orlov <michael.orlov@apex.ai>

* Initial comparisons

Signed-off-by: Patrick Roncagliolo <ronca.pat@gmail.com>

* Move component manager in fixture

Signed-off-by: Patrick Roncagliolo <ronca.pat@gmail.com>

* Uncrustify

Signed-off-by: Patrick Roncagliolo <ronca.pat@gmail.com>

* Remove residual AMENT_DEPS after merge

Signed-off-by: Patrick Roncagliolo <ronca.pat@gmail.com>

* Complete test_play_params

Signed-off-by: Patrick Roncagliolo <ronca.pat@gmail.com>

* Finish param tests

Signed-off-by: Patrick Roncagliolo <ronca.pat@gmail.com>

* Uncrustify

Signed-off-by: Patrick Roncagliolo <ronca.pat@gmail.com>

* Cleanups in player/recorder parameters and load components tests

Signed-off-by: Michael Orlov <michael.orlov@apex.ai>

* Renames in player/recorder parameters and load components tests

Signed-off-by: Michael Orlov <michael.orlov@apex.ai>

* Namespaced parameters

Signed-off-by: Patrick Roncagliolo <ronca.pat@gmail.com>

* Fix load_composable_components test

Signed-off-by: Patrick Roncagliolo <ronca.pat@gmail.com>

* Automatically start playback in "composable" Player constructor

- Added doxygen comments for Player's constructors

Signed-off-by: Michael Orlov <michael.orlov@apex.ai>

* Add integration test for composable player

- Integration test will check that player can automatically play file
after composition

Signed-off-by: Michael Orlov <michael.orlov@apex.ai>

* Add missing dependencies to the mock_player.hpp

Signed-off-by: Michael Orlov <michael.orlov@apex.ai>

* Automatically start recording in "composable" Recorder constructor

- Added doxygen comments for Recorder's constructors

Signed-off-by: Michael Orlov <michael.orlov@apex.ai>

* Adopt existent tests for auto starting recording after composition

- Add default "cdr" value for rmw_serialization_format node parameter

Signed-off-by: Michael Orlov <michael.orlov@apex.ai>

* Add integration test for composable recorder

- Test verify that recorder can automatically start recording after
composition and record messages

Signed-off-by: Michael Orlov <michael.orlov@apex.ai>

* Add missed parameters prefixes after rebase

Signed-off-by: Michael Orlov <michael.orlov@apex.ai>

* Fix for failing test with wrong check for playback_until_timestamp

Signed-off-by: Michael Orlov <michael.orlov@apex.ai>

* Fix for failing tests with wrong parameters deduction

- Adjust max bagfile size and duration due to the bug in the
 rc_yaml_param_parcer/parser.c
 Need to use srtoll() instead of the strol() in parser

Signed-off-by: Michael Orlov <michael.orlov@apex.ai>

* Close recorder before trying to delete temp files on test destruction

Signed-off-by: Michael Orlov <michael.orlov@apex.ai>

* Update rosbag2_transport/test/rosbag2_transport/composition_manager_test_fixture.hpp

Signed-off-by: Patrick Roncagliolo <ronca.pat@gmail.com>

* Update rosbag2_transport/test/rosbag2_transport/test_composable_recorder.cpp

Signed-off-by: Patrick Roncagliolo <ronca.pat@gmail.com>

* Update rosbag2_transport/CMakeLists.txt

Signed-off-by: Patrick Roncagliolo <ronca.pat@gmail.com>

* Update rosbag2_transport/CMakeLists.txt

Signed-off-by: Patrick Roncagliolo <ronca.pat@gmail.com>

* Address warnings from Windows CI job in composable player and recorder

Signed-off-by: Michael Orlov <michael.orlov@apex.ai>

* Update rosbag2_transport/src/rosbag2_transport/config_options_from_node_params.cpp

Co-authored-by: Michael Orlov <morlovmr@gmail.com>
Signed-off-by: Patrick Roncagliolo <ronca.pat@gmail.com>

* Update rosbag2_transport/test/rosbag2_transport/test_composable_player.cpp

Co-authored-by: Michael Orlov <morlovmr@gmail.com>
Signed-off-by: Patrick Roncagliolo <ronca.pat@gmail.com>

---------

Signed-off-by: Patrick Roncagliolo <ronca.pat@gmail.com>
Signed-off-by: roncapat <ronca.pat@gmail.com>
Signed-off-by: Michael Orlov <michael.orlov@apex.ai>
Co-authored-by: Michael Orlov <michael.orlov@apex.ai>
Co-authored-by: Michael Orlov <morlovmr@gmail.com>
@nachovizzo
Copy link

@nachovizzo lots of updates on the associated PR #1419. Would you like testing / provide some feedback?

Sorry, I missed this notification. Silly me. Feedback: Extremely happy to see this got merged :D

Great job man!!!

@roncapat
Copy link
Contributor

No worries, still valid :) If you ever happen to leverage this feature and discover issues, tag me and let me know!

@nachovizzo
Copy link

Sure thing ;)

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

Successfully merging a pull request may close this issue.

6 participants