From 11ee470743464d12eba757b87de22ee7a9bc20b4 Mon Sep 17 00:00:00 2001 From: ivanpauno Date: Mon, 25 Mar 2019 13:01:41 -0300 Subject: [PATCH 1/2] Implement rmw_get_actual_qos Signed-off-by: ivanpauno --- rmw_fastrtps_cpp/src/rmw_publisher.cpp | 9 +++ .../src/rmw_publisher.cpp | 9 +++ .../rmw_fastrtps_shared_cpp/rmw_common.hpp | 6 ++ rmw_fastrtps_shared_cpp/src/rmw_publisher.cpp | 57 +++++++++++++++++++ 4 files changed, 81 insertions(+) diff --git a/rmw_fastrtps_cpp/src/rmw_publisher.cpp b/rmw_fastrtps_cpp/src/rmw_publisher.cpp index febb64c53..5c68307d8 100644 --- a/rmw_fastrtps_cpp/src/rmw_publisher.cpp +++ b/rmw_fastrtps_cpp/src/rmw_publisher.cpp @@ -210,6 +210,15 @@ rmw_publisher_count_matched_subscriptions( publisher, subscription_count); } +rmw_ret_t +rmw_publisher_get_actual_qos( + const rmw_publisher_t * publisher, + rmw_qos_profile_t * qos) +{ + return rmw_fastrtps_shared_cpp::__rmw_publisher_get_actual_qos( + publisher, qos); +} + rmw_ret_t rmw_destroy_publisher(rmw_node_t * node, rmw_publisher_t * publisher) { diff --git a/rmw_fastrtps_dynamic_cpp/src/rmw_publisher.cpp b/rmw_fastrtps_dynamic_cpp/src/rmw_publisher.cpp index 0ac3bdaa3..422a66066 100644 --- a/rmw_fastrtps_dynamic_cpp/src/rmw_publisher.cpp +++ b/rmw_fastrtps_dynamic_cpp/src/rmw_publisher.cpp @@ -205,6 +205,15 @@ rmw_publisher_count_matched_subscriptions( publisher, subscription_count); } +rmw_ret_t +rmw_publisher_get_actual_qos( + const rmw_publisher_t * publisher, + rmw_qos_profile_t * qos) +{ + return rmw_fastrtps_shared_cpp::__rmw_publisher_get_actual_qos( + publisher, qos); +} + rmw_ret_t rmw_destroy_publisher(rmw_node_t * node, rmw_publisher_t * publisher) { diff --git a/rmw_fastrtps_shared_cpp/include/rmw_fastrtps_shared_cpp/rmw_common.hpp b/rmw_fastrtps_shared_cpp/include/rmw_fastrtps_shared_cpp/rmw_common.hpp index 39678d3ec..5824c95c5 100644 --- a/rmw_fastrtps_shared_cpp/include/rmw_fastrtps_shared_cpp/rmw_common.hpp +++ b/rmw_fastrtps_shared_cpp/include/rmw_fastrtps_shared_cpp/rmw_common.hpp @@ -135,6 +135,12 @@ __rmw_publisher_count_matched_subscriptions( const rmw_publisher_t * publisher, size_t * subscription_count); +RMW_FASTRTPS_SHARED_CPP_PUBLIC +rmw_ret_t +__rmw_publisher_get_actual_qos( + const rmw_publisher_t * publisher, + rmw_qos_profile_t * qos); + RMW_FASTRTPS_SHARED_CPP_PUBLIC rmw_ret_t __rmw_send_request( diff --git a/rmw_fastrtps_shared_cpp/src/rmw_publisher.cpp b/rmw_fastrtps_shared_cpp/src/rmw_publisher.cpp index 493b9fea1..6885831dd 100644 --- a/rmw_fastrtps_shared_cpp/src/rmw_publisher.cpp +++ b/rmw_fastrtps_shared_cpp/src/rmw_publisher.cpp @@ -101,4 +101,61 @@ __rmw_publisher_count_matched_subscriptions( return RMW_RET_OK; } + +rmw_ret_t +__rmw_publisher_get_actual_qos( + const rmw_publisher_t * publisher, + rmw_qos_profile_t * qos) +{ + RMW_CHECK_ARGUMENT_FOR_NULL(publisher, RMW_RET_INVALID_ARGUMENT); + RMW_CHECK_ARGUMENT_FOR_NULL(qos, RMW_RET_INVALID_ARGUMENT); + + auto info = static_cast(publisher->data); + if (info == nullptr) { + return RMW_RET_ERROR; + } + eprosima::fastrtps::Publisher * fastrtps_pub = info->publisher_; + if (fastrtps_pub == nullptr) { + return RMW_RET_ERROR; + } + const eprosima::fastrtps::PublisherAttributes attributes = + fastrtps_pub->getAttributes(); + + switch (attributes.topic.historyQos.kind) { + case eprosima::fastrtps::KEEP_LAST_HISTORY_QOS: + qos->history = RMW_QOS_POLICY_HISTORY_KEEP_LAST; + break; + case eprosima::fastrtps::KEEP_ALL_HISTORY_QOS: + qos->history = RMW_QOS_POLICY_HISTORY_KEEP_ALL; + break; + default: + qos->history = RMW_QOS_POLICY_HISTORY_SYSTEM_DEFAULT; + break; + } + switch (attributes.qos.m_durability.kind) { + case eprosima::fastrtps::TRANSIENT_LOCAL_DURABILITY_QOS: + qos->durability = RMW_QOS_POLICY_DURABILITY_TRANSIENT_LOCAL; + break; + case eprosima::fastrtps::VOLATILE_DURABILITY_QOS: + qos->durability = RMW_QOS_POLICY_DURABILITY_VOLATILE; + break; + default: + qos->durability = RMW_QOS_POLICY_DURABILITY_SYSTEM_DEFAULT; + break; + } + switch (attributes.qos.m_reliability.kind) { + case eprosima::fastrtps::BEST_EFFORT_RELIABILITY_QOS: + qos->reliability = RMW_QOS_POLICY_RELIABILITY_BEST_EFFORT; + break; + case eprosima::fastrtps::RELIABLE_RELIABILITY_QOS: + qos->reliability = RMW_QOS_POLICY_RELIABILITY_RELIABLE; + break; + default: + qos->reliability = RMW_QOS_POLICY_RELIABILITY_SYSTEM_DEFAULT; + break; + } + qos->depth = static_cast(attributes.topic.historyQos.depth); + + return RMW_RET_OK; +} } // namespace rmw_fastrtps_shared_cpp From 0e9f496a217a2ec4b7019a7d710f4930c8cd6f4d Mon Sep 17 00:00:00 2001 From: ivanpauno Date: Tue, 26 Mar 2019 15:39:44 -0300 Subject: [PATCH 2/2] Corrected with PR comments Signed-off-by: ivanpauno --- rmw_fastrtps_shared_cpp/src/rmw_publisher.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/rmw_fastrtps_shared_cpp/src/rmw_publisher.cpp b/rmw_fastrtps_shared_cpp/src/rmw_publisher.cpp index 6885831dd..469e8faf3 100644 --- a/rmw_fastrtps_shared_cpp/src/rmw_publisher.cpp +++ b/rmw_fastrtps_shared_cpp/src/rmw_publisher.cpp @@ -118,7 +118,7 @@ __rmw_publisher_get_actual_qos( if (fastrtps_pub == nullptr) { return RMW_RET_ERROR; } - const eprosima::fastrtps::PublisherAttributes attributes = + const eprosima::fastrtps::PublisherAttributes & attributes = fastrtps_pub->getAttributes(); switch (attributes.topic.historyQos.kind) { @@ -129,7 +129,7 @@ __rmw_publisher_get_actual_qos( qos->history = RMW_QOS_POLICY_HISTORY_KEEP_ALL; break; default: - qos->history = RMW_QOS_POLICY_HISTORY_SYSTEM_DEFAULT; + qos->history = RMW_QOS_POLICY_HISTORY_UNKNOWN; break; } switch (attributes.qos.m_durability.kind) { @@ -140,7 +140,7 @@ __rmw_publisher_get_actual_qos( qos->durability = RMW_QOS_POLICY_DURABILITY_VOLATILE; break; default: - qos->durability = RMW_QOS_POLICY_DURABILITY_SYSTEM_DEFAULT; + qos->durability = RMW_QOS_POLICY_DURABILITY_UNKNOWN; break; } switch (attributes.qos.m_reliability.kind) { @@ -151,7 +151,7 @@ __rmw_publisher_get_actual_qos( qos->reliability = RMW_QOS_POLICY_RELIABILITY_RELIABLE; break; default: - qos->reliability = RMW_QOS_POLICY_RELIABILITY_SYSTEM_DEFAULT; + qos->reliability = RMW_QOS_POLICY_RELIABILITY_UNKNOWN; break; } qos->depth = static_cast(attributes.topic.historyQos.depth);