Skip to content

Commit

Permalink
fix: reorder the advanced pub/sub options to match the ROS2 QoS
Browse files Browse the repository at this point in the history
  • Loading branch information
YuanYuYuan committed Jan 13, 2025
1 parent 448bb6c commit 9cc776b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 4 additions & 2 deletions rmw_zenoh_cpp/src/detail/rmw_publisher_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,13 @@ std::shared_ptr<PublisherData> PublisherData::make(
}

auto adv_pub_opts = zenoh::ext::SessionExt::AdvancedPublisherOptions::create_default();
adv_pub_opts.publisher_detection = true;
adv_pub_opts.sample_miss_detection = true;

// Create a Publication Cache if durability is transient_local.
if (adapted_qos_profile.durability == RMW_QOS_POLICY_DURABILITY_TRANSIENT_LOCAL) {
// Retransmission can only be done if history is enabled on subscriber side.
adv_pub_opts.publisher_detection = true;
// Allow this publisher to be detected through liveliness.
adv_pub_opts.sample_miss_detection = true;
adv_pub_opts.cache =
zenoh::ext::SessionExt::AdvancedPublisherOptions::CacheOptions::create_default();
adv_pub_opts.cache->max_samples = adapted_qos_profile.depth;
Expand Down
4 changes: 3 additions & 1 deletion rmw_zenoh_cpp/src/detail/rmw_subscription_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,14 +174,16 @@ bool SubscriptionData::init()
sess_ = context_impl->session();

auto adv_sub_opts = zenoh::ext::SessionExt::AdvancedSubscriberOptions::create_default();
adv_sub_opts.subscriber_detection = true;

// Instantiate the subscription with suitable options depending on the
// adapted_qos_profile.
// TODO(Yadunund): Rely on a separate function to return the sub
// as we start supporting more qos settings.
if (entity_->topic_info()->qos_.durability == RMW_QOS_POLICY_DURABILITY_TRANSIENT_LOCAL) {
// Allow this subscriber to be detected through liveliness.
adv_sub_opts.subscriber_detection = true;
adv_sub_opts.query_timeout_ms = std::numeric_limits<uint64_t>::max();
// History can only be retransmitted by Publishers that enable caching.
adv_sub_opts.history =
zenoh::ext::SessionExt::AdvancedSubscriberOptions::HistoryOptions::create_default();
adv_sub_opts.history->detect_late_publishers = true;
Expand Down

0 comments on commit 9cc776b

Please sign in to comment.