Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add client/service QoS getters #67

Merged
merged 3 commits into from
Nov 19, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions rmw_connextdds/src/rmw_api_impl_ndds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
13 changes: 13 additions & 0 deletions rmw_connextdds_common/include/rmw_connextdds/rmw_api_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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(
Expand Down
6 changes: 6 additions & 0 deletions rmw_connextdds_common/include/rmw_connextdds/rmw_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -629,6 +632,9 @@ class RMW_Connext_Service

rmw_ret_t
enable();

rmw_ret_t
qos(rmw_qos_profile_t * const qos);
};

/******************************************************************************
Expand Down
78 changes: 78 additions & 0 deletions rmw_connextdds_common/src/common/rmw_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
ivanpauno marked this conversation as resolved.
Show resolved Hide resolved
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()
{
Expand Down Expand Up @@ -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)
ivanpauno marked this conversation as resolved.
Show resolved Hide resolved
{
// 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()
{
Expand Down
40 changes: 40 additions & 0 deletions rmw_connextdds_common/src/common/rmw_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<RMW_Connext_Service *>(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<RMW_Connext_Client *>(client->data);

return client_impl->qos(qos);
}

rmw_ret_t
rmw_api_connextdds_destroy_service(
rmw_node_t * node,
Expand Down
20 changes: 20 additions & 0 deletions rmw_connextddsmicro/src/rmw_api_impl_rtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down