Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.
Merged
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
90 changes: 90 additions & 0 deletions rmw_connext_cpp/src/rmw_subscription.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,96 @@ rmw_subscription_count_matched_publishers(
return RMW_RET_OK;
}

rmw_ret_t
rmw_subscription_get_actual_qos(
const rmw_subscription_t * subscription,
rmw_qos_profile_t * qos)
{
RMW_CHECK_ARGUMENT_FOR_NULL(subscription, RMW_RET_INVALID_ARGUMENT);
RMW_CHECK_ARGUMENT_FOR_NULL(qos, RMW_RET_INVALID_ARGUMENT);

auto info = static_cast<ConnextStaticSubscriberInfo *>(subscription->data);
if (!info) {
RMW_SET_ERROR_MSG("subscription internal data is invalid");
return RMW_RET_ERROR;
}
DDS::DataReader * data_reader = info->topic_reader_;
if (!data_reader) {
RMW_SET_ERROR_MSG("subscription internal data reader is invalid");
return RMW_RET_ERROR;
}
DDS::DataReaderQos dds_qos;
DDS::ReturnCode_t status = data_reader->get_qos(dds_qos);
if (DDS::RETCODE_OK != status) {
RMW_SET_ERROR_MSG("subscription can't get data reader qos policies");
return RMW_RET_ERROR;
}

if (!data_reader) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this check needed? I think the one in L382 is enough. I know that the same was done in:

DDS::DataWriter * data_writer = info->topic_writer_;
if (!data_writer) {
RMW_SET_ERROR_MSG("publisher internal data writer is invalid");
return RMW_RET_ERROR;
}
DDS::DataWriterQos dds_qos;
DDS::ReturnCode_t status = data_writer->get_qos(dds_qos);
if (DDS::RETCODE_OK != status) {
RMW_SET_ERROR_MSG("publisher can't get data writer qos policies");
return RMW_RET_ERROR;
}
if (!data_writer) {
RMW_SET_ERROR_MSG("publisher internal dds publisher is invalid");
return RMW_RET_ERROR;
}

But I don't think it has sense. If you agree, delete the duplicated check in the publisher function too

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

RMW_SET_ERROR_MSG("subscription internal dds subscriber is invalid");
return RMW_RET_ERROR;
}

switch (dds_qos.history.kind) {
case DDS_KEEP_LAST_HISTORY_QOS:
qos->history = RMW_QOS_POLICY_HISTORY_KEEP_LAST;
break;
case DDS_KEEP_ALL_HISTORY_QOS:
qos->history = RMW_QOS_POLICY_HISTORY_KEEP_ALL;
break;
default:
qos->history = RMW_QOS_POLICY_HISTORY_UNKNOWN;
break;
}
qos->depth = static_cast<size_t>(dds_qos.history.depth);

switch (dds_qos.reliability.kind) {
case DDS_BEST_EFFORT_RELIABILITY_QOS:
qos->reliability = RMW_QOS_POLICY_RELIABILITY_BEST_EFFORT;
break;
case DDS_RELIABLE_RELIABILITY_QOS:
qos->reliability = RMW_QOS_POLICY_RELIABILITY_RELIABLE;
break;
default:
qos->reliability = RMW_QOS_POLICY_RELIABILITY_UNKNOWN;
break;
}

switch (dds_qos.durability.kind) {
case DDS_TRANSIENT_LOCAL_DURABILITY_QOS:
qos->durability = RMW_QOS_POLICY_DURABILITY_TRANSIENT_LOCAL;
break;
case DDS_VOLATILE_DURABILITY_QOS:
qos->durability = RMW_QOS_POLICY_DURABILITY_VOLATILE;
break;
default:
qos->durability = RMW_QOS_POLICY_DURABILITY_UNKNOWN;
break;
}

qos->deadline.sec = dds_qos.deadline.period.sec;
qos->deadline.nsec = dds_qos.deadline.period.nanosec;

switch (dds_qos.liveliness.kind) {
case DDS_AUTOMATIC_LIVELINESS_QOS:
qos->liveliness = RMW_QOS_POLICY_LIVELINESS_AUTOMATIC;
break;
case DDS_MANUAL_BY_PARTICIPANT_LIVELINESS_QOS:
qos->liveliness = RMW_QOS_POLICY_LIVELINESS_MANUAL_BY_NODE;
break;
case DDS_MANUAL_BY_TOPIC_LIVELINESS_QOS:
qos->liveliness = RMW_QOS_POLICY_LIVELINESS_MANUAL_BY_TOPIC;
break;
default:
qos->liveliness = RMW_QOS_POLICY_LIVELINESS_UNKNOWN;
break;
}
qos->liveliness_lease_duration.sec = dds_qos.liveliness.lease_duration.sec;
qos->liveliness_lease_duration.nsec = dds_qos.liveliness.lease_duration.nanosec;

return RMW_RET_OK;
}

rmw_ret_t
rmw_destroy_subscription(rmw_node_t * node, rmw_subscription_t * subscription)
{
Expand Down