-
Notifications
You must be signed in to change notification settings - Fork 282
[draft] merge the remapping argument into Player's NodeOption. #2089
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?
Conversation
| { | ||
| } |
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.
this change is unrelated but i met the following error to be fixed with it.
135: Test command: /usr/bin/python3 "-u" "/root/ros2_ws/colcon_ws/install/ament_cmake_test/share/ament_cmake_test/cmake/run_test.py" "/root/ros2_ws/colcon_ws/build/rosbag2_transport/test_results/rosbag2_transport/uncrustify.xunit.xml" "--package-name" "rosbag2_transport" "--output-file" "/root/ros2_ws/colcon_ws/build/rosbag2_transport/ament_uncrustify/uncrustify.txt" "--command" "/root/ros2_ws/colcon_ws/install/ament_uncrustify/bin/ament_uncrustify" "--xunit-file" "/root/ros2_ws/colcon_ws/build/rosbag2_transport/test_results/rosbag2_transport/uncrustify.xunit.xml"
135: Working Directory: /root/ros2_ws/colcon_ws/src/ros2/rosbag2/rosbag2_transport
135: Test timeout computed to be: 60
135: -- run_test.py: invoking following command in '/root/ros2_ws/colcon_ws/src/ros2/rosbag2/rosbag2_transport':
135: - /root/ros2_ws/colcon_ws/install/ament_uncrustify/bin/ament_uncrustify --xunit-file /root/ros2_ws/colcon_ws/build/rosbag2_transport/test_results/rosbag2_transport/uncrustify.xunit.xml
135: Code style divergence in file 'src/rosbag2_transport/player.cpp':
135:
135: --- src/rosbag2_transport/player.cpp
135: +++ src/rosbag2_transport/player.cpp.uncrustify
135: @@ -2180 +2180 @@
135: - )
135: +)
135: @@ -2225 +2225 @@
135: - )
135: +)
135: @@ -2264 +2264 @@
135: - ),
135: +),
135: @@ -2267 +2267,2 @@
135: -{}
135: +{
135: +}
135:
135: 1 files with code style divergence|
Pulls: #2089 |
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.
Pull Request Overview
This PR merges NodeOptions arguments with topic remapping options in the Player constructor instead of overwriting them. The change ensures that existing arguments from NodeOptions are preserved while appending the topic remapping options, addressing issue #2088.
- Modifies three Player constructor overloads to merge arguments instead of replacing them
- Changes the argument handling from direct assignment to a lambda-based merge operation
- Preserves existing NodeOptions arguments while appending topic remapping options
| [&, node_options]() { | ||
| auto args = node_options.arguments(); | ||
| args.insert(args.end(), | ||
| play_options.topic_remapping_options.begin(), | ||
| play_options.topic_remapping_options.end()); | ||
| return args; | ||
| }() | ||
| ) | ||
| ) | ||
| { |
Copilot
AI
Jul 15, 2025
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.
The identical lambda logic is duplicated across three constructors. Consider extracting this into a private helper function to improve maintainability and reduce code duplication.
| [&, node_options]() { | |
| auto args = node_options.arguments(); | |
| args.insert(args.end(), | |
| play_options.topic_remapping_options.begin(), | |
| play_options.topic_remapping_options.end()); | |
| return args; | |
| }() | |
| ) | |
| ) | |
| { | |
| merge_node_arguments(node_options, play_options) | |
| ) | |
| ) | |
| { | |
| // Helper function for merging node arguments | |
| auto merge_node_arguments( | |
| const rclcpp::NodeOptions & node_options, | |
| const rosbag2_transport::PlayOptions & play_options) -> std::vector<std::string> { | |
| auto args = node_options.arguments(); | |
| args.insert(args.end(), | |
| play_options.topic_remapping_options.begin(), | |
| play_options.topic_remapping_options.end()); | |
| return args; | |
| } |
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.
hmm i do not think this is necessary. waiting for what other people think about this.
Signed-off-by: Tomoya Fujita <[email protected]>
6055fa5 to
2971f2f
Compare
|
Hi @fujitatomoya and thank you for the patch. I will try to test it tomorrow. Apart from possible code deduplication, this seems ok in principle for me. I have only one doubt: take as reference the following lines in a test case of this repo: rosbag2/rosbag2_transport/test/rosbag2_transport/test_play_topic_remap.cpp Lines 41 to 42 in 9741bfc
Never actually checked (but I may try to experiment with rclcpp tomorrow or dig inside the codebase) - as we chain argument lists, what if there is duplicate "--ros-args" token? Is it ok to have it let's say twice in the argument list? |
|
Another thing that I noticed right now is that the standard constructor will hit these lines: rosbag2/rosbag2_transport/src/rosbag2_transport/config_options_from_node_params.cpp Lines 187 to 195 in 9741bfc
So basically only node arguments are accepted/kept. Shall we reason in the same way, by dropping the ones from |
|
@fujitatomoya @roncapat, Am I understanding correctly that this PR is still WIP? |
|
@MichaelOrlov IMHO yes. By the way, may I ask your opinion on my previous comments? |
|
Hi @roncapat As regards more than one As regards
I would disagree with this statement. Because otherwise, how to remap topics from CLI? rosbag2/ros2bag/ros2bag/verb/play.py Lines 99 to 102 in 8607af5
and rosbag2/ros2bag/ros2bag/verb/play.py Lines 250 to 253 in 8607af5
|
|
Thank you for the clarifications and feedback.
|
Description
Fixes #2088
Is this user-facing behavior change?
Yes, with this PR, Player constructor honors the NodeOption argument to append play_option.arguments.
in other word,
play_option.argumentsdoes not overwrite the argument for the NodeOption.Did you use Generative AI?
Yes, Copilot Claude Sonnet 4.
Additional Information