From 74d9e8edb02eaf13771ee4d12a558d68279cbf44 Mon Sep 17 00:00:00 2001 From: Tony Najjar Date: Wed, 15 May 2024 14:05:33 +0200 Subject: [PATCH] Add missing sub and pub options (#308) Co-authored-by: Angsa Deployment Team --- image_transport/src/republish.cpp | 32 ++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/image_transport/src/republish.cpp b/image_transport/src/republish.cpp index 499b7cf6..412e3e55 100644 --- a/image_transport/src/republish.cpp +++ b/image_transport/src/republish.cpp @@ -96,18 +96,21 @@ void Republisher::initialize() "The 'out_transport' parameter is set to: " << out_transport); } + auto qos_override_options = rclcpp::QosOverridingOptions( + { + rclcpp::QosPolicyKind::Depth, + rclcpp::QosPolicyKind::Durability, + rclcpp::QosPolicyKind::History, + rclcpp::QosPolicyKind::Reliability, + }); + rclcpp::SubscriptionOptions sub_options; + rclcpp::PublisherOptions pub_options; + pub_options.qos_overriding_options = qos_override_options; + sub_options.qos_overriding_options = qos_override_options; + if (out_transport.empty()) { // Use all available transports for output - rclcpp::PublisherOptions pub_options; - auto qos_override_options = rclcpp::QosOverridingOptions( - { - rclcpp::QosPolicyKind::Depth, - rclcpp::QosPolicyKind::Durability, - rclcpp::QosPolicyKind::History, - rclcpp::QosPolicyKind::Reliability, - }); - - pub_options.qos_overriding_options = qos_override_options; + this->pub = image_transport::create_publisher( this, out_topic, rmw_qos_profile_default, pub_options); @@ -117,9 +120,6 @@ void Republisher::initialize() const sensor_msgs::msg::Image::ConstSharedPtr &) const; PublishMemFn pub_mem_fn = &image_transport::Publisher::publish; - rclcpp::SubscriptionOptions sub_options; - sub_options.qos_overriding_options = qos_override_options; - this->sub = image_transport::create_subscription( this, in_topic, std::bind(pub_mem_fn, &pub, std::placeholders::_1), in_transport, rmw_qos_profile_default, sub_options); @@ -133,14 +133,16 @@ void Republisher::initialize() std::string lookup_name = Plugin::getLookupName(out_transport); instance = loader->createUniqueInstance(lookup_name); - instance->advertise(this, out_topic); + instance->advertise(this, out_topic, rmw_qos_profile_default, pub_options); // Use PublisherPlugin::publish as the subscriber callback typedef void (Plugin::* PublishMemFn)(const sensor_msgs::msg::Image::ConstSharedPtr &) const; PublishMemFn pub_mem_fn = &Plugin::publishPtr; this->sub = image_transport::create_subscription( this, in_topic, - std::bind(pub_mem_fn, instance.get(), std::placeholders::_1), in_transport); + std::bind( + pub_mem_fn, + instance.get(), std::placeholders::_1), in_transport, rmw_qos_profile_default, sub_options); } }