Skip to content

Commit

Permalink
Implement get_actual_qos() for subscriptions (#455)
Browse files Browse the repository at this point in the history
Signed-off-by: Miaofei <[email protected]>
  • Loading branch information
mm318 authored and ivanpauno committed Jun 12, 2019
1 parent ec8539b commit b6f4bc9
Show file tree
Hide file tree
Showing 4 changed files with 315 additions and 34 deletions.
26 changes: 26 additions & 0 deletions rcl/include/rcl/subscription.h
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,32 @@ rcl_subscription_get_publisher_count(
const rcl_subscription_t * subscription,
size_t * publisher_count);

/// Get the actual qos settings of the subscription.
/**
* Used to get the actual qos settings of the subscription.
* The actual configuration applied when using RMW_*_SYSTEM_DEFAULT
* can only be resolved after the creation of the subscription, and it
* depends on the underlying rmw implementation.
* If the underlying setting in use can't be represented in ROS terms,
* it will be set to RMW_*_UNKNOWN.
* The returned struct is only valid as long as the rcl_subscription_t is valid.
*
* <hr>
* Attribute | Adherence
* ------------------ | -------------
* Allocates Memory | No
* Thread-Safe | Yes
* Uses Atomics | No
* Lock-Free | Yes
*
* \param[in] subscription pointer to the rcl subscription
* \return qos struct if successful, otherwise `NULL`
*/
RCL_PUBLIC
RCL_WARN_UNUSED
const rmw_qos_profile_t *
rcl_subscription_get_actual_qos(const rcl_subscription_t * subscription);

#ifdef __cplusplus
}
#endif
Expand Down
20 changes: 20 additions & 0 deletions rcl/src/rcl/subscription.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,17 @@ rcl_subscription_init(
RCL_SET_ERROR_MSG(rmw_get_error_string().str);
goto fail;
}
// get actual qos, and store it
rmw_ret = rmw_subscription_get_actual_qos(
subscription->impl->rmw_handle,
&subscription->impl->actual_qos);
if (RMW_RET_OK != rmw_ret) {
RCL_SET_ERROR_MSG(rmw_get_error_string().str);
ret = RCL_RET_ERROR;
goto fail;
}
subscription->impl->actual_qos.avoid_ros_namespace_conventions =
options->qos.avoid_ros_namespace_conventions;
// options
subscription->impl->options = *options;
RCUTILS_LOG_DEBUG_NAMED(ROS_PACKAGE_NAME, "Subscription initialized");
Expand Down Expand Up @@ -359,6 +370,15 @@ rcl_subscription_get_publisher_count(
return RCL_RET_OK;
}

const rmw_qos_profile_t *
rcl_subscription_get_actual_qos(const rcl_subscription_t * subscription)
{
if (!rcl_subscription_is_valid(subscription)) {
return NULL;
}
return &subscription->impl->actual_qos;
}

#ifdef __cplusplus
}
#endif
1 change: 1 addition & 0 deletions rcl/src/rcl/subscription_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
typedef struct rcl_subscription_impl_t
{
rcl_subscription_options_t options;
rmw_qos_profile_t actual_qos;
rmw_subscription_t * rmw_handle;
} rcl_subscription_impl_t;

Expand Down
Loading

0 comments on commit b6f4bc9

Please sign in to comment.