Skip to content

Commit

Permalink
Corrected with PR comments.
Browse files Browse the repository at this point in the history
Signed-off-by: ivanpauno <ivanpauno@ekumenlabs.com>
  • Loading branch information
ivanpauno committed Mar 27, 2019
1 parent 997d65d commit 7fd06bd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
12 changes: 9 additions & 3 deletions rclcpp/include/rclcpp/publisher.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,16 @@ class PublisherBase
size_t
get_intra_process_subscription_count() const;

/// Get actual qos settings
/** \return The number of subscriptions. */
/// Get the actual QoS settings, after the defaults have been determined.
/**
* The actual configuration applied when using RMW_QOS_POLICY_*_SYSTEM_DEFAULT
* can only be resolved after the creation of the publisher, 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_QOS_POLICY_*_UNKNOWN.
* \return The actual qos settings. */
RCLCPP_PUBLIC
std::shared_ptr<rmw_qos_profile_t>
rmw_qos_profile_t
get_actual_qos() const;

/// Compare this publisher to a gid.
Expand Down
16 changes: 3 additions & 13 deletions rclcpp/src/rclcpp/publisher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,24 +197,14 @@ PublisherBase::get_intra_process_subscription_count() const
return ipm->get_subscription_count(intra_process_publisher_id_);
}

std::shared_ptr<rmw_qos_profile_t>
rmw_qos_profile_t
PublisherBase::get_actual_qos() const
{
auto qos = std::make_shared<rmw_qos_profile_t>();
rmw_qos_profile_t qos;

rcl_ret_t status = rcl_publisher_get_actual_qos(
&publisher_handle_,
qos.get());
if (RCL_RET_PUBLISHER_INVALID == status) {
rcl_reset_error(); /* next call will reset error message if not context */
if (rcl_publisher_is_valid_except_context(&publisher_handle_)) {
rcl_context_t * context = rcl_publisher_get_context(&publisher_handle_);
if (nullptr != context && !rcl_context_is_valid(context)) {
/* publisher is invalid due to context being shutdown */
return 0;
}
}
}
&qos);
if (RCL_RET_OK != status) {
rclcpp::exceptions::throw_from_rcl_error(status, "failed to get qos settings");
}
Expand Down

0 comments on commit 7fd06bd

Please sign in to comment.