From 9283d49844885ff2b575b58dd51d4c3ea106b552 Mon Sep 17 00:00:00 2001 From: Mauro Passerino Date: Wed, 13 Oct 2021 08:43:34 +0100 Subject: [PATCH 1/3] Add client/service QoS getters Signed-off-by: Mauro Passerino --- rmw_connextdds/src/rmw_api_impl_ndds.cpp | 20 +++++ .../include/rmw_connextdds/rmw_api_impl.hpp | 13 ++++ .../include/rmw_connextdds/rmw_impl.hpp | 6 ++ rmw_connextdds_common/src/common/rmw_impl.cpp | 78 +++++++++++++++++++ .../src/common/rmw_service.cpp | 40 ++++++++++ .../src/rmw_api_impl_rtime.cpp | 20 +++++ 6 files changed, 177 insertions(+) diff --git a/rmw_connextdds/src/rmw_api_impl_ndds.cpp b/rmw_connextdds/src/rmw_api_impl_ndds.cpp index 3a8ec4ef..5cd8c8aa 100644 --- a/rmw_connextdds/src/rmw_api_impl_ndds.cpp +++ b/rmw_connextdds/src/rmw_api_impl_ndds.cpp @@ -566,6 +566,16 @@ rmw_create_client( } +rmw_ret_t +rmw_client_get_actual_qos( + const rmw_client_t * client, + rmw_qos_profile_t * qos) +{ + return rmw_api_connextdds_client_get_actual_qos( + client, qos); +} + + rmw_ret_t rmw_destroy_client( rmw_node_t * node, @@ -587,6 +597,16 @@ rmw_create_service( } +rmw_ret_t +rmw_service_get_actual_qos( + const rmw_service_t * service, + rmw_qos_profile_t * qos) +{ + return rmw_api_connextdds_service_get_actual_qos( + service, qos); +} + + rmw_ret_t rmw_destroy_service( rmw_node_t * node, diff --git a/rmw_connextdds_common/include/rmw_connextdds/rmw_api_impl.hpp b/rmw_connextdds_common/include/rmw_connextdds/rmw_api_impl.hpp index 565e2941..fe02c329 100644 --- a/rmw_connextdds_common/include/rmw_connextdds/rmw_api_impl.hpp +++ b/rmw_connextdds_common/include/rmw_connextdds/rmw_api_impl.hpp @@ -380,6 +380,12 @@ rmw_api_connextdds_create_client( const char * service_name, const rmw_qos_profile_t * qos_policies); +RMW_CONNEXTDDS_PUBLIC +rmw_ret_t +rmw_api_connextdds_client_get_actual_qos( + const rmw_client_t * client, + rmw_qos_profile_t * qos); + RMW_CONNEXTDDS_PUBLIC rmw_ret_t rmw_api_connextdds_destroy_client( @@ -394,6 +400,13 @@ rmw_api_connextdds_create_service( const char * service_name, const rmw_qos_profile_t * qos_policies); + +RMW_CONNEXTDDS_PUBLIC +rmw_ret_t +rmw_api_connextdds_service_get_actual_qos( + const rmw_service_t * service, + rmw_qos_profile_t * qos); + RMW_CONNEXTDDS_PUBLIC rmw_ret_t rmw_api_connextdds_destroy_service( diff --git a/rmw_connextdds_common/include/rmw_connextdds/rmw_impl.hpp b/rmw_connextdds_common/include/rmw_connextdds/rmw_impl.hpp index 8895d868..55780887 100644 --- a/rmw_connextdds_common/include/rmw_connextdds/rmw_impl.hpp +++ b/rmw_connextdds_common/include/rmw_connextdds/rmw_impl.hpp @@ -582,6 +582,9 @@ class RMW_Connext_Client rmw_ret_t enable(); + + rmw_ret_t + qos(rmw_qos_profile_t * const qos); }; class RMW_Connext_Service @@ -629,6 +632,9 @@ class RMW_Connext_Service rmw_ret_t enable(); + + rmw_ret_t + qos(rmw_qos_profile_t * const qos); }; /****************************************************************************** diff --git a/rmw_connextdds_common/src/common/rmw_impl.cpp b/rmw_connextdds_common/src/common/rmw_impl.cpp index 295b440a..15ac6055 100644 --- a/rmw_connextdds_common/src/common/rmw_impl.cpp +++ b/rmw_connextdds_common/src/common/rmw_impl.cpp @@ -2622,6 +2622,45 @@ RMW_Connext_Client::send_request( return rc; } +rmw_ret_t +RMW_Connext_Client::qos(rmw_qos_profile_t * const qos) +{ + rmw_qos_profile_t pub_qos = rmw_qos_profile_default; + rmw_qos_profile_t sub_qos = rmw_qos_profile_default; + + rmw_ret_t rc = this->reply_sub->qos(&sub_qos); + if (rc != RMW_RET_OK) { + RMW_SET_ERROR_MSG("coudn't get client's subscription qos"); + return rc; + } + rc = this->request_pub->qos(&pub_qos); + if (rc != RMW_RET_OK) { + RMW_SET_ERROR_MSG("coudn't get client's publisher qos"); + return rc; + } + + // Check if the QoS of the client's pub/sub match + // LifespanQosPolicy is a writer-only policy, so don't take into + // acount in this comparison + if (pub_qos.history == sub_qos.history && + pub_qos.depth == sub_qos.depth && + pub_qos.reliability == sub_qos.reliability && + pub_qos.durability == sub_qos.durability && + pub_qos.liveliness == sub_qos.liveliness && + pub_qos.deadline.sec == sub_qos.deadline.sec && + pub_qos.deadline.nsec == sub_qos.deadline.nsec && + pub_qos.liveliness_lease_duration.sec == sub_qos.liveliness_lease_duration.sec && + pub_qos.liveliness_lease_duration.nsec == sub_qos.liveliness_lease_duration.nsec) + { + // The client has a single QoS, set it as the client's publisher QoS since + // it includes the lifespan policy. + return this->request_pub->qos(qos); + } else { + RMW_SET_ERROR_MSG("client's publisher QoS does not match client's subscription QoS"); + return RMW_RET_ERROR; + } +} + rmw_ret_t RMW_Connext_Client::finalize() { @@ -2873,6 +2912,45 @@ RMW_Connext_Service::send_response( return this->reply_pub->write(&rr_msg, false /* serialized */); } +rmw_ret_t +RMW_Connext_Service::qos(rmw_qos_profile_t * const qos) +{ + rmw_qos_profile_t pub_qos = rmw_qos_profile_default; + rmw_qos_profile_t sub_qos = rmw_qos_profile_default; + + rmw_ret_t rc = this->request_sub->qos(&sub_qos); + if (rc != RMW_RET_OK) { + RMW_SET_ERROR_MSG("coudn't get service's subscription qos"); + return rc; + } + rc = this->reply_pub->qos(&pub_qos); + if (rc != RMW_RET_OK) { + RMW_SET_ERROR_MSG("coudn't get service's publisher qos"); + return rc; + } + + // Check if the QoS of the service's pub/sub match + // LifespanQosPolicy is a writer-only policy, so don't take into + // acount in this comparison + if (pub_qos.history == sub_qos.history && + pub_qos.depth == sub_qos.depth && + pub_qos.reliability == sub_qos.reliability && + pub_qos.durability == sub_qos.durability && + pub_qos.liveliness == sub_qos.liveliness && + pub_qos.deadline.sec == sub_qos.deadline.sec && + pub_qos.deadline.nsec == sub_qos.deadline.nsec && + pub_qos.liveliness_lease_duration.sec == sub_qos.liveliness_lease_duration.sec && + pub_qos.liveliness_lease_duration.nsec == sub_qos.liveliness_lease_duration.nsec) + { + // The service has a single QoS, set it as the service's publisher QoS since + // it includes the lifespan policy. + return this->reply_pub->qos(qos); + } else { + RMW_SET_ERROR_MSG("service's publisher QoS does not match service's subscription QoS"); + return RMW_RET_ERROR; + } +} + rmw_ret_t RMW_Connext_Service::finalize() { diff --git a/rmw_connextdds_common/src/common/rmw_service.cpp b/rmw_connextdds_common/src/common/rmw_service.cpp index a52d2425..dcbd8f8c 100644 --- a/rmw_connextdds_common/src/common/rmw_service.cpp +++ b/rmw_connextdds_common/src/common/rmw_service.cpp @@ -374,6 +374,46 @@ rmw_api_connextdds_create_service( } +rmw_ret_t +rmw_api_connextdds_service_get_actual_qos( + const rmw_service_t * service, + rmw_qos_profile_t * qos) +{ + RMW_CHECK_ARGUMENT_FOR_NULL(service, RMW_RET_INVALID_ARGUMENT); + RMW_CHECK_TYPE_IDENTIFIERS_MATCH( + service, + service->implementation_identifier, + RMW_CONNEXTDDS_ID, + return RMW_RET_INCORRECT_RMW_IMPLEMENTATION); + + RMW_CHECK_ARGUMENT_FOR_NULL(qos, RMW_RET_INVALID_ARGUMENT); + + RMW_Connext_Service * const svc_impl = + reinterpret_cast(service->data); + + return svc_impl->qos(qos); +} + +rmw_ret_t +rmw_api_connextdds_client_get_actual_qos( + const rmw_client_t * client, + rmw_qos_profile_t * qos) +{ + RMW_CHECK_ARGUMENT_FOR_NULL(client, RMW_RET_INVALID_ARGUMENT); + RMW_CHECK_TYPE_IDENTIFIERS_MATCH( + client, + client->implementation_identifier, + RMW_CONNEXTDDS_ID, + return RMW_RET_INCORRECT_RMW_IMPLEMENTATION); + + RMW_CHECK_ARGUMENT_FOR_NULL(qos, RMW_RET_INVALID_ARGUMENT); + + RMW_Connext_Client * const client_impl = + reinterpret_cast(client->data); + + return client_impl->qos(qos); +} + rmw_ret_t rmw_api_connextdds_destroy_service( rmw_node_t * node, diff --git a/rmw_connextddsmicro/src/rmw_api_impl_rtime.cpp b/rmw_connextddsmicro/src/rmw_api_impl_rtime.cpp index cac394cf..28a926b0 100644 --- a/rmw_connextddsmicro/src/rmw_api_impl_rtime.cpp +++ b/rmw_connextddsmicro/src/rmw_api_impl_rtime.cpp @@ -566,6 +566,16 @@ rmw_create_client( } +rmw_ret_t +rmw_client_get_actual_qos( + const rmw_client_t * client, + rmw_qos_profile_t * qos) +{ + return rmw_api_connextdds_client_get_actual_qos( + client, qos); +} + + rmw_ret_t rmw_destroy_client( rmw_node_t * node, @@ -587,6 +597,16 @@ rmw_create_service( } +rmw_ret_t +rmw_service_get_actual_qos( + const rmw_service_t * service, + rmw_qos_profile_t * qos) +{ + return rmw_api_connextdds_service_get_actual_qos( + service, qos); +} + + rmw_ret_t rmw_destroy_service( rmw_node_t * node, From 412081a5d506f051520e5d5cb4c64a3a9e264eee Mon Sep 17 00:00:00 2001 From: Mauro Passerino Date: Thu, 14 Oct 2021 17:58:47 +0100 Subject: [PATCH 2/3] Add some comments Signed-off-by: Mauro Passerino --- rmw_connextdds_common/src/common/rmw_impl.cpp | 70 +++++++++++-------- 1 file changed, 40 insertions(+), 30 deletions(-) diff --git a/rmw_connextdds_common/src/common/rmw_impl.cpp b/rmw_connextdds_common/src/common/rmw_impl.cpp index 15ac6055..237ce245 100644 --- a/rmw_connextdds_common/src/common/rmw_impl.cpp +++ b/rmw_connextdds_common/src/common/rmw_impl.cpp @@ -2625,8 +2625,8 @@ RMW_Connext_Client::send_request( rmw_ret_t RMW_Connext_Client::qos(rmw_qos_profile_t * const qos) { - rmw_qos_profile_t pub_qos = rmw_qos_profile_default; - rmw_qos_profile_t sub_qos = rmw_qos_profile_default; + rmw_qos_profile_t pub_qos; + rmw_qos_profile_t sub_qos; rmw_ret_t rc = this->reply_sub->qos(&sub_qos); if (rc != RMW_RET_OK) { @@ -2642,23 +2642,28 @@ RMW_Connext_Client::qos(rmw_qos_profile_t * const qos) // Check if the QoS of the client's pub/sub match // LifespanQosPolicy is a writer-only policy, so don't take into // acount in this comparison - if (pub_qos.history == sub_qos.history && - pub_qos.depth == sub_qos.depth && - pub_qos.reliability == sub_qos.reliability && - pub_qos.durability == sub_qos.durability && - pub_qos.liveliness == sub_qos.liveliness && - pub_qos.deadline.sec == sub_qos.deadline.sec && - pub_qos.deadline.nsec == sub_qos.deadline.nsec && - pub_qos.liveliness_lease_duration.sec == sub_qos.liveliness_lease_duration.sec && - pub_qos.liveliness_lease_duration.nsec == sub_qos.liveliness_lease_duration.nsec) + if (pub_qos.history != sub_qos.history || + pub_qos.depth != sub_qos.depth || + pub_qos.reliability != sub_qos.reliability || + pub_qos.durability != sub_qos.durability || + pub_qos.liveliness != sub_qos.liveliness || + pub_qos.deadline.sec != sub_qos.deadline.sec || + pub_qos.deadline.nsec != sub_qos.deadline.nsec || + pub_qos.liveliness_lease_duration.sec != sub_qos.liveliness_lease_duration.sec || + pub_qos.liveliness_lease_duration.nsec != sub_qos.liveliness_lease_duration.nsec) { - // The client has a single QoS, set it as the client's publisher QoS since - // it includes the lifespan policy. - return this->request_pub->qos(qos); - } else { + // This situation can happen if we set system default settings for qos. + // As no qos is defined by the user, the dds han chose to assign one qos policy for the + // subscription and a different for the publisher. Currently seems to only happen + // to reliability policy, which is set to best effort for subscription + // and reliable for publishers. RMW_SET_ERROR_MSG("client's publisher QoS does not match client's subscription QoS"); return RMW_RET_ERROR; } + + // We use the publisher QoS, since it includes the lifespan policy + *qos = pub_qos; + return RMW_RET_OK; } rmw_ret_t @@ -2929,26 +2934,31 @@ RMW_Connext_Service::qos(rmw_qos_profile_t * const qos) return rc; } - // Check if the QoS of the service's pub/sub match + // Check if the QoS of the server's pub/sub match // LifespanQosPolicy is a writer-only policy, so don't take into // acount in this comparison - if (pub_qos.history == sub_qos.history && - pub_qos.depth == sub_qos.depth && - pub_qos.reliability == sub_qos.reliability && - pub_qos.durability == sub_qos.durability && - pub_qos.liveliness == sub_qos.liveliness && - pub_qos.deadline.sec == sub_qos.deadline.sec && - pub_qos.deadline.nsec == sub_qos.deadline.nsec && - pub_qos.liveliness_lease_duration.sec == sub_qos.liveliness_lease_duration.sec && - pub_qos.liveliness_lease_duration.nsec == sub_qos.liveliness_lease_duration.nsec) + if (pub_qos.history != sub_qos.history || + pub_qos.depth != sub_qos.depth || + pub_qos.reliability != sub_qos.reliability || + pub_qos.durability != sub_qos.durability || + pub_qos.liveliness != sub_qos.liveliness || + pub_qos.deadline.sec != sub_qos.deadline.sec || + pub_qos.deadline.nsec != sub_qos.deadline.nsec || + pub_qos.liveliness_lease_duration.sec != sub_qos.liveliness_lease_duration.sec || + pub_qos.liveliness_lease_duration.nsec != sub_qos.liveliness_lease_duration.nsec) { - // The service has a single QoS, set it as the service's publisher QoS since - // it includes the lifespan policy. - return this->reply_pub->qos(qos); - } else { - RMW_SET_ERROR_MSG("service's publisher QoS does not match service's subscription QoS"); + // This situation can happen if we set system default settings for qos. + // As no qos is defined by the user, the dds han chose to assign one qos policy for the + // subscription and a different for the publisher. Currently seems to only happen + // to reliability policy, which is set to best effort for subscription + // and reliable for publishers. + RMW_SET_ERROR_MSG("server's publisher QoS does not match client's subscription QoS"); return RMW_RET_ERROR; } + + // We use the publisher QoS, since it includes the lifespan policy + *qos = pub_qos; + return RMW_RET_OK; } rmw_ret_t From b28998bdd88e3740d99fb4dd6baca3e7441f0f73 Mon Sep 17 00:00:00 2001 From: Mauro Passerino Date: Mon, 1 Nov 2021 14:06:29 +0000 Subject: [PATCH 3/3] Add serv/cli request/response qos getters Signed-off-by: Mauro Passerino --- rmw_connextdds/src/rmw_api_impl_ndds.cpp | 28 +++++- .../include/rmw_connextdds/rmw_api_impl.hpp | 15 +++- .../include/rmw_connextdds/rmw_impl.hpp | 10 ++- rmw_connextdds_common/src/common/rmw_impl.cpp | 88 +++++-------------- .../src/common/rmw_service.cpp | 64 +++++++++++--- .../src/rmw_api_impl_rtime.cpp | 27 +++++- 6 files changed, 144 insertions(+), 88 deletions(-) diff --git a/rmw_connextdds/src/rmw_api_impl_ndds.cpp b/rmw_connextdds/src/rmw_api_impl_ndds.cpp index 5cd8c8aa..78dcc468 100644 --- a/rmw_connextdds/src/rmw_api_impl_ndds.cpp +++ b/rmw_connextdds/src/rmw_api_impl_ndds.cpp @@ -567,11 +567,21 @@ rmw_create_client( rmw_ret_t -rmw_client_get_actual_qos( +rmw_client_request_publisher_get_actual_qos( const rmw_client_t * client, rmw_qos_profile_t * qos) { - return rmw_api_connextdds_client_get_actual_qos( + return rmw_api_connextdds_client_request_publisher_get_actual_qos( + client, qos); +} + + +rmw_ret_t +rmw_client_response_subscription_get_actual_qos( + const rmw_client_t * client, + rmw_qos_profile_t * qos) +{ + return rmw_api_connextdds_client_response_subscription_get_actual_qos( client, qos); } @@ -598,11 +608,21 @@ rmw_create_service( rmw_ret_t -rmw_service_get_actual_qos( +rmw_service_response_publisher_get_actual_qos( + const rmw_service_t * service, + rmw_qos_profile_t * qos) +{ + return rmw_api_connextdds_service_response_publisher_get_actual_qos( + service, qos); +} + + +rmw_ret_t +rmw_service_request_subscription_get_actual_qos( const rmw_service_t * service, rmw_qos_profile_t * qos) { - return rmw_api_connextdds_service_get_actual_qos( + return rmw_api_connextdds_service_request_subscription_get_actual_qos( service, qos); } diff --git a/rmw_connextdds_common/include/rmw_connextdds/rmw_api_impl.hpp b/rmw_connextdds_common/include/rmw_connextdds/rmw_api_impl.hpp index fe02c329..4afaaab6 100644 --- a/rmw_connextdds_common/include/rmw_connextdds/rmw_api_impl.hpp +++ b/rmw_connextdds_common/include/rmw_connextdds/rmw_api_impl.hpp @@ -382,7 +382,13 @@ rmw_api_connextdds_create_client( RMW_CONNEXTDDS_PUBLIC rmw_ret_t -rmw_api_connextdds_client_get_actual_qos( +rmw_api_connextdds_client_request_publisher_get_actual_qos( + const rmw_client_t * client, + rmw_qos_profile_t * qos); + +RMW_CONNEXTDDS_PUBLIC +rmw_ret_t +rmw_api_connextdds_client_response_subscription_get_actual_qos( const rmw_client_t * client, rmw_qos_profile_t * qos); @@ -400,10 +406,15 @@ rmw_api_connextdds_create_service( const char * service_name, const rmw_qos_profile_t * qos_policies); +RMW_CONNEXTDDS_PUBLIC +rmw_ret_t +rmw_api_connextdds_service_response_publisher_get_actual_qos( + const rmw_service_t * service, + rmw_qos_profile_t * qos); RMW_CONNEXTDDS_PUBLIC rmw_ret_t -rmw_api_connextdds_service_get_actual_qos( +rmw_api_connextdds_service_request_subscription_get_actual_qos( const rmw_service_t * service, rmw_qos_profile_t * qos); diff --git a/rmw_connextdds_common/include/rmw_connextdds/rmw_impl.hpp b/rmw_connextdds_common/include/rmw_connextdds/rmw_impl.hpp index 55780887..bd79a4a1 100644 --- a/rmw_connextdds_common/include/rmw_connextdds/rmw_impl.hpp +++ b/rmw_connextdds_common/include/rmw_connextdds/rmw_impl.hpp @@ -584,7 +584,10 @@ class RMW_Connext_Client enable(); rmw_ret_t - qos(rmw_qos_profile_t * const qos); + request_publisher_qos(rmw_qos_profile_t * const qos); + + rmw_ret_t + response_subscription_qos(rmw_qos_profile_t * const qos); }; class RMW_Connext_Service @@ -634,7 +637,10 @@ class RMW_Connext_Service enable(); rmw_ret_t - qos(rmw_qos_profile_t * const qos); + response_publisher_qos(rmw_qos_profile_t * const qos); + + rmw_ret_t + request_subscription_qos(rmw_qos_profile_t * const qos); }; /****************************************************************************** diff --git a/rmw_connextdds_common/src/common/rmw_impl.cpp b/rmw_connextdds_common/src/common/rmw_impl.cpp index 237ce245..a74a9010 100644 --- a/rmw_connextdds_common/src/common/rmw_impl.cpp +++ b/rmw_connextdds_common/src/common/rmw_impl.cpp @@ -2623,46 +2623,24 @@ RMW_Connext_Client::send_request( } rmw_ret_t -RMW_Connext_Client::qos(rmw_qos_profile_t * const qos) +RMW_Connext_Client::request_publisher_qos(rmw_qos_profile_t * const qos) { - rmw_qos_profile_t pub_qos; - rmw_qos_profile_t sub_qos; - - rmw_ret_t rc = this->reply_sub->qos(&sub_qos); + rmw_ret_t rc = this->request_pub->qos(qos); if (rc != RMW_RET_OK) { - RMW_SET_ERROR_MSG("coudn't get client's subscription qos"); + RMW_SET_ERROR_MSG("coudn't get client's request publisher qos"); return rc; } - rc = this->request_pub->qos(&pub_qos); + return RMW_RET_OK; +} + +rmw_ret_t +RMW_Connext_Client::response_subscription_qos(rmw_qos_profile_t * const qos) +{ + rmw_ret_t rc = this->reply_sub->qos(qos); if (rc != RMW_RET_OK) { - RMW_SET_ERROR_MSG("coudn't get client's publisher qos"); + RMW_SET_ERROR_MSG("coudn't get client's response subscription qos"); return rc; } - - // Check if the QoS of the client's pub/sub match - // LifespanQosPolicy is a writer-only policy, so don't take into - // acount in this comparison - if (pub_qos.history != sub_qos.history || - pub_qos.depth != sub_qos.depth || - pub_qos.reliability != sub_qos.reliability || - pub_qos.durability != sub_qos.durability || - pub_qos.liveliness != sub_qos.liveliness || - pub_qos.deadline.sec != sub_qos.deadline.sec || - pub_qos.deadline.nsec != sub_qos.deadline.nsec || - pub_qos.liveliness_lease_duration.sec != sub_qos.liveliness_lease_duration.sec || - pub_qos.liveliness_lease_duration.nsec != sub_qos.liveliness_lease_duration.nsec) - { - // This situation can happen if we set system default settings for qos. - // As no qos is defined by the user, the dds han chose to assign one qos policy for the - // subscription and a different for the publisher. Currently seems to only happen - // to reliability policy, which is set to best effort for subscription - // and reliable for publishers. - RMW_SET_ERROR_MSG("client's publisher QoS does not match client's subscription QoS"); - return RMW_RET_ERROR; - } - - // We use the publisher QoS, since it includes the lifespan policy - *qos = pub_qos; return RMW_RET_OK; } @@ -2918,46 +2896,24 @@ RMW_Connext_Service::send_response( } rmw_ret_t -RMW_Connext_Service::qos(rmw_qos_profile_t * const qos) +RMW_Connext_Service::response_publisher_qos(rmw_qos_profile_t * const qos) { - rmw_qos_profile_t pub_qos = rmw_qos_profile_default; - rmw_qos_profile_t sub_qos = rmw_qos_profile_default; - - rmw_ret_t rc = this->request_sub->qos(&sub_qos); + rmw_ret_t rc = this->reply_pub->qos(qos); if (rc != RMW_RET_OK) { - RMW_SET_ERROR_MSG("coudn't get service's subscription qos"); + RMW_SET_ERROR_MSG("coudn't get service's response publisher qos"); return rc; } - rc = this->reply_pub->qos(&pub_qos); + return RMW_RET_OK; +} + +rmw_ret_t +RMW_Connext_Service::request_subscription_qos(rmw_qos_profile_t * const qos) +{ + rmw_ret_t rc = this->request_sub->qos(qos); if (rc != RMW_RET_OK) { - RMW_SET_ERROR_MSG("coudn't get service's publisher qos"); + RMW_SET_ERROR_MSG("coudn't get service's request subscription qos"); return rc; } - - // Check if the QoS of the server's pub/sub match - // LifespanQosPolicy is a writer-only policy, so don't take into - // acount in this comparison - if (pub_qos.history != sub_qos.history || - pub_qos.depth != sub_qos.depth || - pub_qos.reliability != sub_qos.reliability || - pub_qos.durability != sub_qos.durability || - pub_qos.liveliness != sub_qos.liveliness || - pub_qos.deadline.sec != sub_qos.deadline.sec || - pub_qos.deadline.nsec != sub_qos.deadline.nsec || - pub_qos.liveliness_lease_duration.sec != sub_qos.liveliness_lease_duration.sec || - pub_qos.liveliness_lease_duration.nsec != sub_qos.liveliness_lease_duration.nsec) - { - // This situation can happen if we set system default settings for qos. - // As no qos is defined by the user, the dds han chose to assign one qos policy for the - // subscription and a different for the publisher. Currently seems to only happen - // to reliability policy, which is set to best effort for subscription - // and reliable for publishers. - RMW_SET_ERROR_MSG("server's publisher QoS does not match client's subscription QoS"); - return RMW_RET_ERROR; - } - - // We use the publisher QoS, since it includes the lifespan policy - *qos = pub_qos; return RMW_RET_OK; } diff --git a/rmw_connextdds_common/src/common/rmw_service.cpp b/rmw_connextdds_common/src/common/rmw_service.cpp index dcbd8f8c..c04e725c 100644 --- a/rmw_connextdds_common/src/common/rmw_service.cpp +++ b/rmw_connextdds_common/src/common/rmw_service.cpp @@ -267,6 +267,48 @@ rmw_api_connextdds_destroy_client( } +rmw_ret_t +rmw_api_connextdds_client_request_publisher_get_actual_qos( + const rmw_client_t * client, + rmw_qos_profile_t * qos) +{ + RMW_CHECK_ARGUMENT_FOR_NULL(client, RMW_RET_INVALID_ARGUMENT); + RMW_CHECK_TYPE_IDENTIFIERS_MATCH( + client, + client->implementation_identifier, + RMW_CONNEXTDDS_ID, + return RMW_RET_INCORRECT_RMW_IMPLEMENTATION); + + RMW_CHECK_ARGUMENT_FOR_NULL(qos, RMW_RET_INVALID_ARGUMENT); + + RMW_Connext_Client * const client_impl = + reinterpret_cast(client->data); + + return client_impl->request_publisher_qos(qos); +} + + +rmw_ret_t +rmw_api_connextdds_client_response_subscription_get_actual_qos( + const rmw_client_t * client, + rmw_qos_profile_t * qos) +{ + RMW_CHECK_ARGUMENT_FOR_NULL(client, RMW_RET_INVALID_ARGUMENT); + RMW_CHECK_TYPE_IDENTIFIERS_MATCH( + client, + client->implementation_identifier, + RMW_CONNEXTDDS_ID, + return RMW_RET_INCORRECT_RMW_IMPLEMENTATION); + + RMW_CHECK_ARGUMENT_FOR_NULL(qos, RMW_RET_INVALID_ARGUMENT); + + RMW_Connext_Client * const client_impl = + reinterpret_cast(client->data); + + return client_impl->response_subscription_qos(qos); +} + + rmw_service_t * rmw_api_connextdds_create_service( const rmw_node_t * node, @@ -375,7 +417,7 @@ rmw_api_connextdds_create_service( rmw_ret_t -rmw_api_connextdds_service_get_actual_qos( +rmw_api_connextdds_service_response_publisher_get_actual_qos( const rmw_service_t * service, rmw_qos_profile_t * qos) { @@ -391,29 +433,31 @@ rmw_api_connextdds_service_get_actual_qos( RMW_Connext_Service * const svc_impl = reinterpret_cast(service->data); - return svc_impl->qos(qos); + return svc_impl->response_publisher_qos(qos); } + rmw_ret_t -rmw_api_connextdds_client_get_actual_qos( - const rmw_client_t * client, +rmw_api_connextdds_service_request_subscription_get_actual_qos( + const rmw_service_t * service, rmw_qos_profile_t * qos) { - RMW_CHECK_ARGUMENT_FOR_NULL(client, RMW_RET_INVALID_ARGUMENT); + RMW_CHECK_ARGUMENT_FOR_NULL(service, RMW_RET_INVALID_ARGUMENT); RMW_CHECK_TYPE_IDENTIFIERS_MATCH( - client, - client->implementation_identifier, + service, + service->implementation_identifier, RMW_CONNEXTDDS_ID, return RMW_RET_INCORRECT_RMW_IMPLEMENTATION); RMW_CHECK_ARGUMENT_FOR_NULL(qos, RMW_RET_INVALID_ARGUMENT); - RMW_Connext_Client * const client_impl = - reinterpret_cast(client->data); + RMW_Connext_Service * const svc_impl = + reinterpret_cast(service->data); - return client_impl->qos(qos); + return svc_impl->request_subscription_qos(qos); } + rmw_ret_t rmw_api_connextdds_destroy_service( rmw_node_t * node, diff --git a/rmw_connextddsmicro/src/rmw_api_impl_rtime.cpp b/rmw_connextddsmicro/src/rmw_api_impl_rtime.cpp index 28a926b0..fd11a406 100644 --- a/rmw_connextddsmicro/src/rmw_api_impl_rtime.cpp +++ b/rmw_connextddsmicro/src/rmw_api_impl_rtime.cpp @@ -567,15 +567,24 @@ rmw_create_client( rmw_ret_t -rmw_client_get_actual_qos( +rmw_client_request_publisher_get_actual_qos( const rmw_client_t * client, rmw_qos_profile_t * qos) { - return rmw_api_connextdds_client_get_actual_qos( + return rmw_api_connextdds_client_request_publisher_get_actual_qos( client, qos); } +rmw_ret_t +rmw_client_response_subscription_get_actual_qos( + const rmw_client_t * client, + rmw_qos_profile_t * qos) +{ + return rmw_api_connextdds_client_response_subscription_get_actual_qos( + client, qos); +} + rmw_ret_t rmw_destroy_client( rmw_node_t * node, @@ -598,11 +607,21 @@ rmw_create_service( rmw_ret_t -rmw_service_get_actual_qos( +rmw_service_response_publisher_get_actual_qos( + const rmw_service_t * service, + rmw_qos_profile_t * qos) +{ + return rmw_api_connextdds_service_response_publisher_get_actual_qos( + service, qos); +} + + +rmw_ret_t +rmw_service_request_subscription_get_actual_qos( const rmw_service_t * service, rmw_qos_profile_t * qos) { - return rmw_api_connextdds_service_get_actual_qos( + return rmw_api_connextdds_service_request_subscription_get_actual_qos( service, qos); }