Skip to content

Commit

Permalink
Add missing sub and pub options (#308)
Browse files Browse the repository at this point in the history
Co-authored-by: Angsa Deployment Team <[email protected]>
  • Loading branch information
tonynajjar and Angsa Deployment Team authored May 15, 2024
1 parent 136807e commit 74d9e8e
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions image_transport/src/republish.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
}
}

Expand Down

0 comments on commit 74d9e8e

Please sign in to comment.