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
Filter topic by type #1577
Conversation
Signed-off-by: Alejandro Hernández Cordero <ahcorde@gmail.com>
Signed-off-by: Alejandro Hernández Cordero <ahcorde@gmail.com>
Signed-off-by: Alejandro Hernández Cordero <ahcorde@gmail.com>
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.
@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.
- At least one options out of --all, --all-topics, --all-services, --services, --topics, --topic-types or --regex must be used.
- 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)
rosbag2/rosbag2_transport/src/rosbag2_transport/config_options_from_node_params.cpp
Lines 205 to 215 in a2283ab
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.
- Will need to add the new parameter
topic_types
to the
is_discovery_disabled: true topics: ["topic", "other_topic"] services: ["service", "other_service"] - Will need to add a check for a new parameter
topic_types
in the
rosbag2/rosbag2_transport/test/rosbag2_transport/test_composable_recorder.cpp
Lines 213 to 215 in a2283ab
std::vector<std::string> topics {"/topic", "/other_topic"}; EXPECT_EQ(record_options.topics, topics); std::vector<std::string> services {"/service/_service_event", "/other_service/_service_event"};
rosbag2_transport/test/rosbag2_transport/test_record_topic_types.cpp
Outdated
Show resolved
Hide resolved
rosbag2_transport/test/rosbag2_transport/test_record_topic_types.cpp
Outdated
Show resolved
Hide resolved
rosbag2_transport/test/rosbag2_transport/test_record_topic_types.cpp
Outdated
Show resolved
Hide resolved
rosbag2_transport/test/rosbag2_transport/test_record_topic_types.cpp
Outdated
Show resolved
Hide resolved
rosbag2_transport/test/rosbag2_transport/test_record_topic_types.cpp
Outdated
Show resolved
Hide resolved
Signed-off-by: Alejandro Hernández Cordero <ahcorde@gmail.com>
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.
just one clarification about this behavior in rosbag2_transport
.
Signed-off-by: Alejandro Hernández Cordero <ahcorde@gmail.com>
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.
lgtm with green CI
@MichaelOrlov all good from your side ? |
@ahcorde I am sorry, I didn't have time to get back to it. Please give me one more day or so. |
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.
@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.
rosbag2_transport/test/rosbag2_transport/test_record_topic_types.cpp
Outdated
Show resolved
Hide resolved
rosbag2_transport/test/rosbag2_transport/test_record_topic_types.cpp
Outdated
Show resolved
Hide resolved
Signed-off-by: Alejandro Hernández Cordero <ahcorde@gmail.com>
@ahcorde The
|
@ahcorde However, I can't reproduce this failure on my local setup. |
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.
@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.
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 |
It will be great to be able to filter topic by type.
Example usage: