From 5f495d79306041320bc428ade711747ba002d9b7 Mon Sep 17 00:00:00 2001 From: Ivan Santiago Paunovic Date: Mon, 9 Nov 2020 13:49:08 -0300 Subject: [PATCH 1/8] Add demo of how to use qos overrides Signed-off-by: Ivan Santiago Paunovic --- quality_of_service_demo/README.md | 18 ++++ quality_of_service_demo/rclcpp/CMakeLists.txt | 23 +++- .../params_file/example_qos_overrides.yaml | 17 +++ .../example_qos_overrides_with_wildcard.yaml | 10 ++ .../rclcpp/src/qos_overrides_listener.cpp | 89 +++++++++++++++ .../rclcpp/src/qos_overrides_talker.cpp | 102 ++++++++++++++++++ 6 files changed, 258 insertions(+), 1 deletion(-) create mode 100644 quality_of_service_demo/rclcpp/params_file/example_qos_overrides.yaml create mode 100644 quality_of_service_demo/rclcpp/params_file/example_qos_overrides_with_wildcard.yaml create mode 100644 quality_of_service_demo/rclcpp/src/qos_overrides_listener.cpp create mode 100644 quality_of_service_demo/rclcpp/src/qos_overrides_talker.cpp diff --git a/quality_of_service_demo/README.md b/quality_of_service_demo/README.md index f9afa77a0..572c37af2 100644 --- a/quality_of_service_demo/README.md +++ b/quality_of_service_demo/README.md @@ -178,3 +178,21 @@ Example output: ``` For information about how to tune QoS settings for large messages see [DDS tuning](https://index.ros.org/doc/ros2/Troubleshooting/DDS-tuning/). + +## Qos overrides + +You can use qos overrides parameters for making qos profiles configurable. +Create a parameters yaml file, similar to the examples in the `params_file` folder. + +and run: + +``` +# you can use `$(ros2 pkg prefix quality_of_service_demo_cpp)/share/quality_of_service_demo_cpp/params_file/example_qos_overrides.yaml` instead of `/path/to/yaml/file` to use the example installed yaml file. +ros2 run quality_of_service_demo_cpp qos_overrides_talker --ros-args --params-file /path/to/yaml/file +``` + +in another terminal: + +``` +ros2 run quality_of_service_demo_cpp qos_overrides_listener --ros-args --params-file /path/to/yaml/file +``` diff --git a/quality_of_service_demo/rclcpp/CMakeLists.txt b/quality_of_service_demo/rclcpp/CMakeLists.txt index 9ba41742b..e4f4ff5fa 100644 --- a/quality_of_service_demo/rclcpp/CMakeLists.txt +++ b/quality_of_service_demo/rclcpp/CMakeLists.txt @@ -60,13 +60,34 @@ rclcpp_components_register_node(message_lost PLUGIN "quality_of_service_demo::MessageLostTalker" EXECUTABLE message_lost_talker) +add_library(qos_overrides SHARED + src/qos_overrides_listener.cpp + src/qos_overrides_talker.cpp +) +ament_target_dependencies(qos_overrides + "rclcpp" + "rclcpp_components" + "rcutils" + "sensor_msgs" +) +target_compile_definitions(qos_overrides + PRIVATE "QUALITY_OF_SERVICE_DEMO_BUILDING_DLL") +rclcpp_components_register_node(qos_overrides + PLUGIN "quality_of_service_demo::QosOverridesListener" + EXECUTABLE qos_overrides_listener) +rclcpp_components_register_node(qos_overrides + PLUGIN "quality_of_service_demo::QosOverridesTalker" + EXECUTABLE qos_overrides_talker) + install(TARGETS - message_lost + message_lost qos_overrides ARCHIVE DESTINATION lib LIBRARY DESTINATION lib RUNTIME DESTINATION bin ) +install(DIRECTORY params_file DESTINATION ${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME}) + if(BUILD_TESTING) find_package(ament_lint_auto REQUIRED) ament_lint_auto_find_test_dependencies() diff --git a/quality_of_service_demo/rclcpp/params_file/example_qos_overrides.yaml b/quality_of_service_demo/rclcpp/params_file/example_qos_overrides.yaml new file mode 100644 index 000000000..a838b95c5 --- /dev/null +++ b/quality_of_service_demo/rclcpp/params_file/example_qos_overrides.yaml @@ -0,0 +1,17 @@ +qos_overrides_talker: # node name + ros__parameters: # All parameters are nested in this key + qos_overrides: # Parameter group for all qos overrides + /qos_overrides_chatter: # Parameter group for the topic + publisher: # Profile for publishers in the topic + # publisher_my_id: # Profile for publishers in the topic with id="my_id" + reliability: reliable + depth: 9 + # depth: 11 # Uncomment this line to make the validation callback fail +qos_overrides_listener: + ros__parameters: + qos_overrides: + /qos_overrides_chatter: + subscription: # Profile for subscriptions in the topic + # subscription_my_id: # Profile for subscriptions in the topic with id="my_id" + reliability: reliable + depth: 9 diff --git a/quality_of_service_demo/rclcpp/params_file/example_qos_overrides_with_wildcard.yaml b/quality_of_service_demo/rclcpp/params_file/example_qos_overrides_with_wildcard.yaml new file mode 100644 index 000000000..022fa1e5d --- /dev/null +++ b/quality_of_service_demo/rclcpp/params_file/example_qos_overrides_with_wildcard.yaml @@ -0,0 +1,10 @@ +/**: + ros__parameters: + qos_overrides: + /qos_overrides_chatter: + publisher: + reliability: reliable + depth: 9 + subscription: + reliability: reliable + depth: 9 diff --git a/quality_of_service_demo/rclcpp/src/qos_overrides_listener.cpp b/quality_of_service_demo/rclcpp/src/qos_overrides_listener.cpp new file mode 100644 index 000000000..e45ecf7bc --- /dev/null +++ b/quality_of_service_demo/rclcpp/src/qos_overrides_listener.cpp @@ -0,0 +1,89 @@ +// Copyright 2020 Open Source Robotics Foundation, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "rclcpp/qos_overriding_options.hpp" +#include "rclcpp/rclcpp.hpp" +#include "rclcpp_components/register_node_macro.hpp" + +#include "sensor_msgs/msg/image.hpp" + +#include "quality_of_service_demo/visibility_control.h" + +namespace quality_of_service_demo +{ +class QosOverridesListener : public rclcpp::Node +{ +public: + QUALITY_OF_SERVICE_DEMO_PUBLIC + explicit QosOverridesListener(const rclcpp::NodeOptions & options) + : Node("qos_overrides_listener", options) + { + // Callback that will be used when a message is received. + auto callback = + [this](const sensor_msgs::msg::Image::SharedPtr msg) -> void + { + rclcpp::Time now = this->get_clock()->now(); + auto diff = now - msg->header.stamp; + RCLCPP_INFO( + this->get_logger(), + "I heard an image. Message single trip latency: [%f]", + diff.seconds()); + }; + rclcpp::SubscriptionOptions sub_opts; + // Update the subscription options to allow reconfigurable qos settings. + sub_opts.qos_overriding_options.policy_kinds = { + // Here all policies that are desired to be reconfigurable are listed. + rclcpp::QosPolicyKind::Depth, + rclcpp::QosPolicyKind::Durability, + rclcpp::QosPolicyKind::History, + rclcpp::QosPolicyKind::Reliability, + }; + sub_opts.qos_overriding_options.validation_callback = [](const rclcpp::QoS & qos) { + /** This is a qos validation callback, that can optionally be provided. + * Here, arbitrary constraints in the final qos profile can be checked. + * The function will return true if the user provided qos profile is accepted. + * If the profile is not accepted, the user will get an InvalidQosOverridesException. + */ + // TODO(ivanpauno): Add getters to `rclcpp::QoS` to make this easier. + rclcpp::QosCallbackResult result; + result.successful = false; + if (qos.get_rmw_qos_profile().depth > 10u) { + result.reason = "expexted history depth less or equal than 10"; + return result; + } + result.successful = true; + return result; + }; + /** + * The "id" option is useful when you want to have subscriptions + * listening to the same topic with different QoS profiles within a node. + * You can try uncommenting and modifying + * `qos_overrides./qos_overrides_topic.subscription` + * to + * `qos_overrides./qos_overrides_topic.subscription_custom_identifier` + */ + // sub_opts.qos_overriding_options.id = "custom_identifier"; + + // create the subscription + sub_ = create_subscription( + "qos_overrides_chatter", 1, callback, sub_opts); + } + +private: + rclcpp::Subscription::SharedPtr sub_; +}; + +} // namespace quality_of_service_demo + +RCLCPP_COMPONENTS_REGISTER_NODE(quality_of_service_demo::QosOverridesListener) diff --git a/quality_of_service_demo/rclcpp/src/qos_overrides_talker.cpp b/quality_of_service_demo/rclcpp/src/qos_overrides_talker.cpp new file mode 100644 index 000000000..dd24d5f05 --- /dev/null +++ b/quality_of_service_demo/rclcpp/src/qos_overrides_talker.cpp @@ -0,0 +1,102 @@ +// Copyright 2020 Open Source Robotics Foundation, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include +#include +#include +#include +#include + +#include "rcutils/cmdline_parser.h" + +#include "rclcpp/rclcpp.hpp" +#include "rclcpp_components/register_node_macro.hpp" + +#include "sensor_msgs/msg/image.hpp" + +#include "quality_of_service_demo/visibility_control.h" + +using namespace std::chrono_literals; + +namespace quality_of_service_demo +{ + +class QosOverridesTalker : public rclcpp::Node +{ +public: + QUALITY_OF_SERVICE_DEMO_PUBLIC + explicit QosOverridesTalker(const rclcpp::NodeOptions & options) + : Node("qos_overrides_talker", options) + { + // Timer callback + auto publish_message = + [this]() -> void + { + for (size_t i = 0; i < 1u * 1024u * 1024u; ++i) { + msg_.data.push_back(0); + } + rclcpp::Time now = this->get_clock()->now(); + msg_.header.stamp = now; + RCLCPP_INFO( + this->get_logger(), + "Publishing an image, sent at [%f]", + now.seconds()); + + pub_->publish(msg_); + }; + + rclcpp::PublisherOptions pub_opts; + // Update the subscription options to allow reconfigurable qos settings. + pub_opts.qos_overriding_options.policy_kinds = { + // Here all policies that are desired to be reconfigurable are listed. + rclcpp::QosPolicyKind::Depth, + rclcpp::QosPolicyKind::Durability, + rclcpp::QosPolicyKind::History, + rclcpp::QosPolicyKind::Reliability, + }; + pub_opts.qos_overriding_options.validation_callback = [](const rclcpp::QoS & qos) { + /** This is a qos validation callback, that can optionally be provided. + * Here, arbitrary constraints in the final qos profile can be checked. + * The function will return true if the user provided qos profile is accepted. + * If the profile is not accepted, the user will get an InvalidQosOverridesException. + */ + // TODO(ivanpauno): Add getters to `rclcpp::QoS` to make this easier. + rclcpp::QosCallbackResult result; + result.successful = false; + if (qos.get_rmw_qos_profile().depth > 10u) { + result.reason = "expexted history depth less or equal than 10"; + return result; + } + result.successful = true; + return result; + }; + + + // Create a publisher + pub_ = this->create_publisher("qos_overrides_chatter", 1, pub_opts); + + // Use a timer to schedule periodic message publishing. + timer_ = this->create_wall_timer(3s, publish_message); + } + +private: + size_t message_size_; + sensor_msgs::msg::Image msg_; + rclcpp::Publisher::SharedPtr pub_; + rclcpp::TimerBase::SharedPtr timer_; +}; + +} // namespace quality_of_service_demo + +RCLCPP_COMPONENTS_REGISTER_NODE(quality_of_service_demo::QosOverridesTalker) From 560dacb051fbb2e485d4045899fb56018994b64f Mon Sep 17 00:00:00 2001 From: Ivan Santiago Paunovic Date: Mon, 9 Nov 2020 16:02:52 -0300 Subject: [PATCH 2/8] spelling Signed-off-by: Ivan Santiago Paunovic Co-authored-by: Jacob Perron --- quality_of_service_demo/rclcpp/src/qos_overrides_listener.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quality_of_service_demo/rclcpp/src/qos_overrides_listener.cpp b/quality_of_service_demo/rclcpp/src/qos_overrides_listener.cpp index e45ecf7bc..4d50945d6 100644 --- a/quality_of_service_demo/rclcpp/src/qos_overrides_listener.cpp +++ b/quality_of_service_demo/rclcpp/src/qos_overrides_listener.cpp @@ -59,7 +59,7 @@ class QosOverridesListener : public rclcpp::Node rclcpp::QosCallbackResult result; result.successful = false; if (qos.get_rmw_qos_profile().depth > 10u) { - result.reason = "expexted history depth less or equal than 10"; + result.reason = "expected history depth less or equal than 10"; return result; } result.successful = true; From 7a3a567bf0a64551eb154fd0ea0e78fb64ac695e Mon Sep 17 00:00:00 2001 From: Ivan Santiago Paunovic Date: Mon, 9 Nov 2020 16:03:07 -0300 Subject: [PATCH 3/8] spelling Signed-off-by: Ivan Santiago Paunovic Co-authored-by: Jacob Perron --- quality_of_service_demo/rclcpp/src/qos_overrides_talker.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quality_of_service_demo/rclcpp/src/qos_overrides_talker.cpp b/quality_of_service_demo/rclcpp/src/qos_overrides_talker.cpp index dd24d5f05..d508293c7 100644 --- a/quality_of_service_demo/rclcpp/src/qos_overrides_talker.cpp +++ b/quality_of_service_demo/rclcpp/src/qos_overrides_talker.cpp @@ -75,7 +75,7 @@ class QosOverridesTalker : public rclcpp::Node rclcpp::QosCallbackResult result; result.successful = false; if (qos.get_rmw_qos_profile().depth > 10u) { - result.reason = "expexted history depth less or equal than 10"; + result.reason = "expected history depth less or equal than 10"; return result; } result.successful = true; From 5c15f7de334ea3f5c4a1498961f8a7adf9b6667b Mon Sep 17 00:00:00 2001 From: Ivan Santiago Paunovic Date: Mon, 9 Nov 2020 16:04:00 -0300 Subject: [PATCH 4/8] Improve readme Signed-off-by: Ivan Santiago Paunovic Co-authored-by: Jacob Perron --- quality_of_service_demo/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quality_of_service_demo/README.md b/quality_of_service_demo/README.md index 572c37af2..98334c161 100644 --- a/quality_of_service_demo/README.md +++ b/quality_of_service_demo/README.md @@ -181,7 +181,7 @@ For information about how to tune QoS settings for large messages see [DDS tunin ## Qos overrides -You can use qos overrides parameters for making qos profiles configurable. +You can use QoS overrides parameters for making QoS profiles configurable when starting a node. Create a parameters yaml file, similar to the examples in the `params_file` folder. and run: From 19ed1e169b46d82cd501b355c632190d513b577e Mon Sep 17 00:00:00 2001 From: Ivan Santiago Paunovic Date: Mon, 9 Nov 2020 16:05:51 -0300 Subject: [PATCH 5/8] Improve readme Signed-off-by: Ivan Santiago Paunovic Co-authored-by: Jacob Perron --- quality_of_service_demo/README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/quality_of_service_demo/README.md b/quality_of_service_demo/README.md index 98334c161..3ce78b350 100644 --- a/quality_of_service_demo/README.md +++ b/quality_of_service_demo/README.md @@ -182,9 +182,7 @@ For information about how to tune QoS settings for large messages see [DDS tunin ## Qos overrides You can use QoS overrides parameters for making QoS profiles configurable when starting a node. -Create a parameters yaml file, similar to the examples in the `params_file` folder. - -and run: +Create a parameters yaml file, similar to the examples in the `params_file` folder, and run: ``` # you can use `$(ros2 pkg prefix quality_of_service_demo_cpp)/share/quality_of_service_demo_cpp/params_file/example_qos_overrides.yaml` instead of `/path/to/yaml/file` to use the example installed yaml file. From 525eef8be63f907a256fa4022d28b0bcd060a307 Mon Sep 17 00:00:00 2001 From: Ivan Santiago Paunovic Date: Wed, 18 Nov 2020 18:14:02 -0300 Subject: [PATCH 6/8] Update after last API changes Signed-off-by: Ivan Santiago Paunovic --- .../rclcpp/src/qos_overrides_listener.cpp | 63 ++++++++++--------- .../rclcpp/src/qos_overrides_talker.cpp | 56 ++++++++++------- 2 files changed, 67 insertions(+), 52 deletions(-) diff --git a/quality_of_service_demo/rclcpp/src/qos_overrides_listener.cpp b/quality_of_service_demo/rclcpp/src/qos_overrides_listener.cpp index 4d50945d6..02f61c300 100644 --- a/quality_of_service_demo/rclcpp/src/qos_overrides_listener.cpp +++ b/quality_of_service_demo/rclcpp/src/qos_overrides_listener.cpp @@ -42,39 +42,42 @@ class QosOverridesListener : public rclcpp::Node }; rclcpp::SubscriptionOptions sub_opts; // Update the subscription options to allow reconfigurable qos settings. - sub_opts.qos_overriding_options.policy_kinds = { - // Here all policies that are desired to be reconfigurable are listed. - rclcpp::QosPolicyKind::Depth, - rclcpp::QosPolicyKind::Durability, - rclcpp::QosPolicyKind::History, - rclcpp::QosPolicyKind::Reliability, - }; - sub_opts.qos_overriding_options.validation_callback = [](const rclcpp::QoS & qos) { - /** This is a qos validation callback, that can optionally be provided. - * Here, arbitrary constraints in the final qos profile can be checked. - * The function will return true if the user provided qos profile is accepted. - * If the profile is not accepted, the user will get an InvalidQosOverridesException. - */ - // TODO(ivanpauno): Add getters to `rclcpp::QoS` to make this easier. - rclcpp::QosCallbackResult result; - result.successful = false; - if (qos.get_rmw_qos_profile().depth > 10u) { - result.reason = "expected history depth less or equal than 10"; + sub_opts.qos_overriding_options = rclcpp::QosOverridingOptions { + { + // Here all policies that are desired to be reconfigurable are listed. + rclcpp::QosPolicyKind::Depth, + rclcpp::QosPolicyKind::Durability, + rclcpp::QosPolicyKind::History, + rclcpp::QosPolicyKind::Reliability, + }, + [](const rclcpp::QoS & qos) { + /** This is a qos validation callback, that can optionally be provided. + * Here, arbitrary constraints in the final qos profile can be checked. + * The function will return true if the user provided qos profile is accepted. + * If the profile is not accepted, the user will get an InvalidQosOverridesException. + */ + // TODO(ivanpauno): Add getters to `rclcpp::QoS` to make this easier. + rclcpp::QosCallbackResult result; + result.successful = false; + if (qos.get_rmw_qos_profile().depth > 10u) { + result.reason = "expected history depth less or equal than 10"; + return result; + } + result.successful = true; return result; } - result.successful = true; - return result; + /** + * The "id" option is useful when you want to have subscriptions + * listening to the same topic with different QoS profiles within a node. + * You can try uncommenting and modifying + * `qos_overrides./qos_overrides_topic.subscription` + * to + * `qos_overrides./qos_overrides_topic.subscription_custom_identifier` + * + * Uncomment the next line to try it. + */ + // , "custom_identifier" }; - /** - * The "id" option is useful when you want to have subscriptions - * listening to the same topic with different QoS profiles within a node. - * You can try uncommenting and modifying - * `qos_overrides./qos_overrides_topic.subscription` - * to - * `qos_overrides./qos_overrides_topic.subscription_custom_identifier` - */ - // sub_opts.qos_overriding_options.id = "custom_identifier"; - // create the subscription sub_ = create_subscription( "qos_overrides_chatter", 1, callback, sub_opts); diff --git a/quality_of_service_demo/rclcpp/src/qos_overrides_talker.cpp b/quality_of_service_demo/rclcpp/src/qos_overrides_talker.cpp index d508293c7..3ff70a143 100644 --- a/quality_of_service_demo/rclcpp/src/qos_overrides_talker.cpp +++ b/quality_of_service_demo/rclcpp/src/qos_overrides_talker.cpp @@ -55,34 +55,46 @@ class QosOverridesTalker : public rclcpp::Node pub_->publish(msg_); }; - + rclcpp::PublisherOptions pub_opts; // Update the subscription options to allow reconfigurable qos settings. - pub_opts.qos_overriding_options.policy_kinds = { - // Here all policies that are desired to be reconfigurable are listed. - rclcpp::QosPolicyKind::Depth, - rclcpp::QosPolicyKind::Durability, - rclcpp::QosPolicyKind::History, - rclcpp::QosPolicyKind::Reliability, - }; - pub_opts.qos_overriding_options.validation_callback = [](const rclcpp::QoS & qos) { - /** This is a qos validation callback, that can optionally be provided. - * Here, arbitrary constraints in the final qos profile can be checked. - * The function will return true if the user provided qos profile is accepted. - * If the profile is not accepted, the user will get an InvalidQosOverridesException. - */ - // TODO(ivanpauno): Add getters to `rclcpp::QoS` to make this easier. - rclcpp::QosCallbackResult result; - result.successful = false; - if (qos.get_rmw_qos_profile().depth > 10u) { - result.reason = "expected history depth less or equal than 10"; + pub_opts.qos_overriding_options = rclcpp::QosOverridingOptions { + { + // Here all policies that are desired to be reconfigurable are listed. + rclcpp::QosPolicyKind::Depth, + rclcpp::QosPolicyKind::Durability, + rclcpp::QosPolicyKind::History, + rclcpp::QosPolicyKind::Reliability + }, + [](const rclcpp::QoS & qos) { + /** This is a qos validation callback, that can optionally be provided. + * Here, arbitrary constraints in the final qos profile can be checked. + * The function will return true if the user provided qos profile is accepted. + * If the profile is not accepted, the user will get an InvalidQosOverridesException. + */ + // TODO(ivanpauno): Add getters to `rclcpp::QoS` to make this easier. + rclcpp::QosCallbackResult result; + result.successful = false; + if (qos.get_rmw_qos_profile().depth > 10u) { + result.reason = "expected history depth less or equal than 10"; + return result; + } + result.successful = true; return result; } - result.successful = true; - return result; + /** + * The "id" option is useful when you want to have subscriptions + * listening to the same topic with different QoS profiles within a node. + * You can try uncommenting and modifying + * `qos_overrides./qos_overrides_topic.subscription` + * to + * `qos_overrides./qos_overrides_topic.subscription_custom_identifier` + * + * Uncomment the next line to try it. + */ + // , "custom_identifier" }; - // Create a publisher pub_ = this->create_publisher("qos_overrides_chatter", 1, pub_opts); From 066f427b501ff0a422feed7bfaf16bd207d32b74 Mon Sep 17 00:00:00 2001 From: Chris Lalancette Date: Wed, 9 Dec 2020 13:51:37 +0000 Subject: [PATCH 7/8] Remove unused message_size_ member variable. Signed-off-by: Chris Lalancette --- quality_of_service_demo/rclcpp/src/qos_overrides_talker.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/quality_of_service_demo/rclcpp/src/qos_overrides_talker.cpp b/quality_of_service_demo/rclcpp/src/qos_overrides_talker.cpp index 3ff70a143..dab86e037 100644 --- a/quality_of_service_demo/rclcpp/src/qos_overrides_talker.cpp +++ b/quality_of_service_demo/rclcpp/src/qos_overrides_talker.cpp @@ -103,7 +103,6 @@ class QosOverridesTalker : public rclcpp::Node } private: - size_t message_size_; sensor_msgs::msg::Image msg_; rclcpp::Publisher::SharedPtr pub_; rclcpp::TimerBase::SharedPtr timer_; From 7e57e571c36d455189861dfa0a698ceb577f1c23 Mon Sep 17 00:00:00 2001 From: Ivan Santiago Paunovic Date: Thu, 10 Dec 2020 19:04:19 -0300 Subject: [PATCH 8/8] Use rclcpp::QoS getters Signed-off-by: Ivan Santiago Paunovic --- quality_of_service_demo/rclcpp/src/qos_overrides_listener.cpp | 3 +-- quality_of_service_demo/rclcpp/src/qos_overrides_talker.cpp | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/quality_of_service_demo/rclcpp/src/qos_overrides_listener.cpp b/quality_of_service_demo/rclcpp/src/qos_overrides_listener.cpp index 02f61c300..47a41f581 100644 --- a/quality_of_service_demo/rclcpp/src/qos_overrides_listener.cpp +++ b/quality_of_service_demo/rclcpp/src/qos_overrides_listener.cpp @@ -56,10 +56,9 @@ class QosOverridesListener : public rclcpp::Node * The function will return true if the user provided qos profile is accepted. * If the profile is not accepted, the user will get an InvalidQosOverridesException. */ - // TODO(ivanpauno): Add getters to `rclcpp::QoS` to make this easier. rclcpp::QosCallbackResult result; result.successful = false; - if (qos.get_rmw_qos_profile().depth > 10u) { + if (qos.depth() > 10u) { result.reason = "expected history depth less or equal than 10"; return result; } diff --git a/quality_of_service_demo/rclcpp/src/qos_overrides_talker.cpp b/quality_of_service_demo/rclcpp/src/qos_overrides_talker.cpp index dab86e037..9ff43cc0c 100644 --- a/quality_of_service_demo/rclcpp/src/qos_overrides_talker.cpp +++ b/quality_of_service_demo/rclcpp/src/qos_overrides_talker.cpp @@ -72,10 +72,9 @@ class QosOverridesTalker : public rclcpp::Node * The function will return true if the user provided qos profile is accepted. * If the profile is not accepted, the user will get an InvalidQosOverridesException. */ - // TODO(ivanpauno): Add getters to `rclcpp::QoS` to make this easier. rclcpp::QosCallbackResult result; result.successful = false; - if (qos.get_rmw_qos_profile().depth > 10u) { + if (qos.depth() > 10u) { result.reason = "expected history depth less or equal than 10"; return result; }