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

Filter topic by type #1577

Merged
merged 6 commits into from Mar 14, 2024
Merged

Filter topic by type #1577

merged 6 commits into from Mar 14, 2024

Conversation

ahcorde
Copy link
Contributor

@ahcorde ahcorde commented Feb 28, 2024

It will be great to be able to filter topic by type.

Example usage:

ros2 bag record --topic_types sensor_msgs/msg/Image sensor_msgs/msg/CameraInfo

Signed-off-by: Alejandro Hernández Cordero <ahcorde@gmail.com>
Signed-off-by: Alejandro Hernández Cordero <ahcorde@gmail.com>
@ahcorde ahcorde self-assigned this Feb 28, 2024
@ahcorde ahcorde requested a review from a team as a code owner February 28, 2024 15:43
@ahcorde ahcorde requested review from emersonknapp and hidmic and removed request for a team February 28, 2024 15:43
Signed-off-by: Alejandro Hernández Cordero <ahcorde@gmail.com>
Copy link
Contributor

@MichaelOrlov MichaelOrlov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ahcorde Thanks for this PR.

Among other small findings and neatpicks I have a concern about the current logic of how the new parameter --topic-types is handled.
I would expect that two fundamental and conceptual conditions shall be true.

  1. At least one options out of --all, --all-topics, --all-services, --services, --topics, --topic-types or --regex must be used.
  2. Only one option out of --all, --all-topics, --topics, --topic-types or --regex can be used.

The --all means All topics and services regardless of the other inclusive filters among exclusive filters.
i.e. --topic-types shall not override --all. However, currently according to the logic in the topic_filters.cpp and newly created test --topic-types overrides --all parameter.
The same for --all-topics. It means all topics and not services regardless of the other inclusive filters among exclusive filters.

If agree with the proposed logic please change the logic in the topic_filters.cpp and the unit test, if not let's discuss.
Also, need to add new unit tests to the test_topic_filter.cpp to cover these two conceptual conditions. Currently, the changed logic is not covered by the unit tests.

Also, I found that missed part related to the parsing RecordOptions from nodes parameters. We recently added a new feature aka composable recorder/player.
Please add updates for the new field RecordOptions::topics_types to the get_record_options_from_node_params(rclcpp::Node & node)

RecordOptions get_record_options_from_node_params(rclcpp::Node & node)
{
RecordOptions record_options{};
record_options.all_topics = node.declare_parameter<bool>("record.all_topics", false);
record_options.all_services = node.declare_parameter<bool>("record.all_services", false);
record_options.is_discovery_disabled =
node.declare_parameter<bool>("record.is_discovery_disabled", false);
record_options.topics = node.declare_parameter<std::vector<std::string>>(
"record.topics", std::vector<std::string>());

Also please update the corresponding tests.

ros2bag/ros2bag/verb/record.py Outdated Show resolved Hide resolved
ros2bag/ros2bag/verb/record.py Outdated Show resolved Hide resolved
ros2bag/ros2bag/verb/record.py Outdated Show resolved Hide resolved
rosbag2_transport/CMakeLists.txt Outdated Show resolved Hide resolved
rosbag2_transport/CMakeLists.txt Outdated Show resolved Hide resolved
Signed-off-by: Alejandro Hernández Cordero <ahcorde@gmail.com>
Copy link
Contributor

@fujitatomoya fujitatomoya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MichaelOrlov @ahcorde

just one clarification about this behavior in rosbag2_transport.

rosbag2_transport/src/rosbag2_transport/topic_filter.cpp Outdated Show resolved Hide resolved
rosbag2_transport/src/rosbag2_transport/topic_filter.cpp Outdated Show resolved Hide resolved
Signed-off-by: Alejandro Hernández Cordero <ahcorde@gmail.com>
Copy link
Contributor

@fujitatomoya fujitatomoya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm with green CI

@ahcorde
Copy link
Contributor Author

ahcorde commented Mar 11, 2024

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Windows Build Status

@ahcorde
Copy link
Contributor Author

ahcorde commented Mar 11, 2024

@MichaelOrlov all good from your side ?

@MichaelOrlov
Copy link
Contributor

@ahcorde I am sorry, I didn't have time to get back to it. Please give me one more day or so.

Copy link
Contributor

@MichaelOrlov MichaelOrlov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ahcorde Thanks for addressing comments from the previous review round.
It's almost all good. However, I found a couple of mismatches in the newly added test.

Signed-off-by: Alejandro Hernández Cordero <ahcorde@gmail.com>
@MichaelOrlov
Copy link
Contributor

@ahcorde The ros2bag tests fail with an error message:

==================================== ERRORS ====================================
2024-03-13T10:19:00.8916311Z ____________________________ ERROR collecting test _____________________________
2024-03-13T10:19:00.8917767Z /usr/local/lib/python3.10/dist-packages/pluggy/_hooks.py:501: in __call__
2024-03-13T10:19:00.8920690Z     return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
2024-03-13T10:19:00.8922556Z /usr/local/lib/python3.10/dist-packages/pluggy/_manager.py:119: in _hookexec
2024-03-13T10:19:00.8923632Z     return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
2024-03-13T10:19:00.8924871Z /usr/local/lib/python3.10/dist-packages/_pytest/python.py:225: in pytest_collect_file
2024-03-13T10:19:00.8926155Z     module: Module = ihook.pytest_pycollect_makemodule(
2024-03-13T10:19:00.8927395Z /usr/local/lib/python3.10/dist-packages/_pytest/config/compat.py:79: in fixed_hook
2024-03-13T10:19:00.8928511Z     return hook(**kw)
2024-03-13T10:19:00.8939779Z /usr/local/lib/python3.10/dist-packages/pluggy/_hooks.py:501: in __call__
2024-03-13T10:19:00.8940939Z     return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
2024-03-13T10:19:00.8942176Z /usr/local/lib/python3.10/dist-packages/pluggy/_manager.py:119: in _hookexec
2024-03-13T10:19:00.8943254Z     return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
2024-03-13T10:19:00.8944406Z ../../../../build/launch_testing/launch_testing/pytest/hooks.py:188: in pytest_pycollect_makemodule
2024-03-13T10:19:00.8945018Z     entrypoint = find_launch_test_entrypoint(path)
2024-03-13T10:19:00.8945613Z ../../../../build/launch_testing/launch_testing/pytest/hooks.py:178: in find_launch_test_entrypoint
2024-03-13T10:19:00.8946177Z     module = import_path(path, root=None)
2024-03-13T10:19:00.8946847Z E   TypeError: import_path() missing 1 required keyword-only argument: 'consider_namespace_packages'
2024-03-13T10:19:00.8947631Z --- generated xml file: /__w/rosbag2/rosbag2/ros_ws/build/ros2bag/pytest.xml ---
2024-03-13T10:19:00.8948177Z =========================== short test summary info ============================
2024-03-13T10:19:00.8949067Z ERROR test - TypeError: import_path() missing 1 required keyword-only argument: 'consider_namespace_packages'
2024-03-13T10:19:00.8949855Z !!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!
2024-03-13T10:19:00.8950330Z =============================== 1 error in 0.16s ===============================
2024-03-13T10:19:00.9269817Z Failed   <<< ros2bag [1.56s, exited with code 2]

@MichaelOrlov
Copy link
Contributor

@ahcorde However, I can't reproduce this failure on my local setup.
Will try to restart the CI job.

Copy link
Contributor

@MichaelOrlov MichaelOrlov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ahcorde Approving this PR.
However, I have a concern to the way how written unit tests and logic in the topic_filter.cpp.
In general need to avoid using the transport layer and pub/sub if it could be avoided, especially for testing some specific classes like filters which could be easily tested and verified with regular unit tests. The logic in the topic_filter.cpp needs to be simplified and cleaned up.
I am going to address these issues in the follow-up PR.

@ahcorde
Copy link
Contributor Author

ahcorde commented Mar 14, 2024

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Windows Build Status

@ahcorde ahcorde merged commit b5e9926 into rolling Mar 14, 2024
13 of 14 checks passed
@delete-merged-branch delete-merged-branch bot deleted the ahcorde/rolling/filter_by_topic_type branch March 14, 2024 12:51
@ros-discourse
Copy link

This pull request has been mentioned on ROS Discourse. There might be relevant details there:

https://discourse.ros.org/t/ros-2-tsc-meeting-minutes-for-2024-03-21/36814/1

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

Successfully merging this pull request may close these issues.

None yet

4 participants