Skip to content

Commit

Permalink
Add serv/cli request/response qos getters
Browse files Browse the repository at this point in the history
Signed-off-by: Mauro Passerino <mpasserino@irobot.com>
  • Loading branch information
Mauro Passerino committed Nov 1, 2021
1 parent 1523820 commit c5ae5b3
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 77 deletions.
20 changes: 18 additions & 2 deletions rmw_fastrtps_cpp/src/rmw_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ rmw_destroy_client(rmw_node_t * node, rmw_client_t * 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)
{
Expand All @@ -507,6 +507,22 @@ rmw_client_get_actual_qos(
return RMW_RET_INCORRECT_RMW_IMPLEMENTATION);
RMW_CHECK_ARGUMENT_FOR_NULL(qos, RMW_RET_INVALID_ARGUMENT);

return rmw_fastrtps_shared_cpp::__rmw_client_get_actual_qos(client, qos);
return rmw_fastrtps_shared_cpp::__rmw_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)
{
RMW_CHECK_ARGUMENT_FOR_NULL(client, RMW_RET_INVALID_ARGUMENT);
RMW_CHECK_TYPE_IDENTIFIERS_MATCH(
client,
client->implementation_identifier,
eprosima_fastrtps_identifier,
return RMW_RET_INCORRECT_RMW_IMPLEMENTATION);
RMW_CHECK_ARGUMENT_FOR_NULL(qos, RMW_RET_INVALID_ARGUMENT);

return rmw_fastrtps_shared_cpp::__rmw_client_response_subscription_get_actual_qos(client, qos);
}
} // extern "C"
20 changes: 18 additions & 2 deletions rmw_fastrtps_cpp/src/rmw_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ rmw_destroy_service(rmw_node_t * node, rmw_service_t * 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)
{
Expand All @@ -506,6 +506,22 @@ rmw_service_get_actual_qos(
return RMW_RET_INCORRECT_RMW_IMPLEMENTATION);
RMW_CHECK_ARGUMENT_FOR_NULL(qos, RMW_RET_INVALID_ARGUMENT);

return rmw_fastrtps_shared_cpp::__rmw_service_get_actual_qos(service, qos);
return rmw_fastrtps_shared_cpp::__rmw_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)
{
RMW_CHECK_ARGUMENT_FOR_NULL(service, RMW_RET_INVALID_ARGUMENT);
RMW_CHECK_TYPE_IDENTIFIERS_MATCH(
service,
service->implementation_identifier,
eprosima_fastrtps_identifier,
return RMW_RET_INCORRECT_RMW_IMPLEMENTATION);
RMW_CHECK_ARGUMENT_FOR_NULL(qos, RMW_RET_INVALID_ARGUMENT);

return rmw_fastrtps_shared_cpp::__rmw_service_request_subscription_get_actual_qos(service, qos);
}
} // extern "C"
Original file line number Diff line number Diff line change
Expand Up @@ -319,13 +319,25 @@ __rmw_subscription_get_actual_qos(

RMW_FASTRTPS_SHARED_CPP_PUBLIC
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);

RMW_FASTRTPS_SHARED_CPP_PUBLIC
rmw_ret_t
__rmw_client_get_actual_qos(
__rmw_service_request_subscription_get_actual_qos(
const rmw_service_t * service,
rmw_qos_profile_t * qos);

RMW_FASTRTPS_SHARED_CPP_PUBLIC
rmw_ret_t
__rmw_client_request_publisher_get_actual_qos(
const rmw_client_t * client,
rmw_qos_profile_t * qos);

RMW_FASTRTPS_SHARED_CPP_PUBLIC
rmw_ret_t
__rmw_client_response_subscription_get_actual_qos(
const rmw_client_t * client,
rmw_qos_profile_t * qos);

Expand Down
48 changes: 14 additions & 34 deletions rmw_fastrtps_shared_cpp/src/rmw_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,44 +128,24 @@ __rmw_destroy_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)
{
auto info = static_cast<CustomClientInfo *>(client->data);

eprosima::fastdds::dds::DataReader * fastdds_dr = info->response_reader_;
eprosima::fastdds::dds::DataWriter * fastdds_dw = info->request_writer_;

rmw_qos_profile_t dr_qos = rmw_qos_profile_default;
rmw_qos_profile_t dw_qos = rmw_qos_profile_default;

dds_qos_to_rmw_qos(fastdds_dr->get_qos(), &dr_qos);
dds_qos_to_rmw_qos(fastdds_dw->get_qos(), &dw_qos);

// Check if the QoS of the data reader and the data writer match
if (dr_qos.history != dw_qos.history ||
dr_qos.depth != dw_qos.depth ||
dr_qos.reliability != dw_qos.reliability ||
dr_qos.durability != dw_qos.durability ||
dr_qos.liveliness != dw_qos.liveliness ||
dr_qos.deadline.sec != dw_qos.deadline.sec ||
dr_qos.deadline.nsec != dw_qos.deadline.nsec ||
dr_qos.lifespan.sec != dw_qos.lifespan.sec ||
dr_qos.lifespan.nsec != dw_qos.lifespan.nsec ||
dr_qos.liveliness_lease_duration.sec != dw_qos.liveliness_lease_duration.sec ||
dr_qos.liveliness_lease_duration.nsec != dw_qos.liveliness_lease_duration.nsec ||
dr_qos.avoid_ros_namespace_conventions != dw_qos.avoid_ros_namespace_conventions)
{
// 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
// reader and a different for the writer. Currently seems to only happen to durability,
// which is set to volatile for data readers, and transient local for data writers.
RMW_SET_ERROR_MSG("client's datawriter QoS does not match client's datareader QoS");
return RMW_RET_ERROR;
}
auto cli = static_cast<CustomClientInfo *>(client->data);
eprosima::fastdds::dds::DataWriter * fastdds_rw = cli->request_writer_;
dds_qos_to_rmw_qos(fastdds_rw->get_qos(), qos);
return RMW_RET_OK;
}

*qos = dw_qos;
rmw_ret_t
__rmw_client_response_subscription_get_actual_qos(
const rmw_client_t * client,
rmw_qos_profile_t * qos)
{
auto cli = static_cast<CustomClientInfo *>(client->data);
eprosima::fastdds::dds::DataReader * fastdds_dr = cli->response_reader_;
dds_qos_to_rmw_qos(fastdds_dr->get_qos(), qos);
return RMW_RET_OK;
}
} // namespace rmw_fastrtps_shared_cpp
51 changes: 14 additions & 37 deletions rmw_fastrtps_shared_cpp/src/rmw_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,47 +140,24 @@ __rmw_destroy_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)
{
auto info = static_cast<CustomServiceInfo *>(service->data);

eprosima::fastdds::dds::DataReader * fastdds_dr = info->request_reader_;
eprosima::fastdds::dds::DataWriter * fastdds_dw = info->response_writer_;

rmw_qos_profile_t dr_qos = rmw_qos_profile_default;
rmw_qos_profile_t dw_qos = rmw_qos_profile_default;

dds_qos_to_rmw_qos(fastdds_dr->get_qos(), &dr_qos);
dds_qos_to_rmw_qos(fastdds_dw->get_qos(), &dw_qos);

// Check if the QoS of the data reader and the data writer match
if (dr_qos.history != dw_qos.history ||
dr_qos.depth != dw_qos.depth ||
dr_qos.reliability != dw_qos.reliability ||
dr_qos.durability != dw_qos.durability ||
dr_qos.liveliness != dw_qos.liveliness ||
dr_qos.deadline.sec != dw_qos.deadline.sec ||
dr_qos.deadline.nsec != dw_qos.deadline.nsec ||
dr_qos.lifespan.sec != dw_qos.lifespan.sec ||
dr_qos.lifespan.nsec != dw_qos.lifespan.nsec ||
dr_qos.liveliness_lease_duration.sec != dw_qos.liveliness_lease_duration.sec ||
dr_qos.liveliness_lease_duration.nsec != dw_qos.liveliness_lease_duration.nsec ||
dr_qos.avoid_ros_namespace_conventions != dw_qos.avoid_ros_namespace_conventions)
{
// 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
// reader and a different for the writer. Currently seems to only happen to durability,
// which is set to volatile for data readers, and transient local for data writers.
RMW_SET_ERROR_MSG("server's datawriter QoS does not match client's datareader QoS");
return RMW_RET_ERROR;
}

// The service has a single QoS, we can set it either as the qos
// of the data reader or data writer, as they match.
*qos = dw_qos;
auto srv = static_cast<CustomServiceInfo *>(service->data);
eprosima::fastdds::dds::DataWriter * fastdds_rw = srv->response_writer_;
dds_qos_to_rmw_qos(fastdds_rw->get_qos(), qos);
return RMW_RET_OK;
}

rmw_ret_t
__rmw_service_request_subscription_get_actual_qos(
const rmw_service_t * service,
rmw_qos_profile_t * qos)
{
auto srv = static_cast<CustomServiceInfo *>(service->data);
eprosima::fastdds::dds::DataReader * fastdds_rr = srv->request_reader_;
dds_qos_to_rmw_qos(fastdds_rr->get_qos(), qos);
return RMW_RET_OK;
}
} // namespace rmw_fastrtps_shared_cpp

0 comments on commit c5ae5b3

Please sign in to comment.