Add function to get publisher actual qos settings (#667)
* Added get_actual_qos method to publisher. Signed-off-by: ivanpauno <ivanpauno@ekumenlabs.com>
This commit is contained in:
parent
4f2f8def98
commit
1f2904f980
2 changed files with 27 additions and 1 deletions
|
@ -128,6 +128,20 @@ public:
|
||||||
size_t
|
size_t
|
||||||
get_intra_process_subscription_count() const;
|
get_intra_process_subscription_count() const;
|
||||||
|
|
||||||
|
/// 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.
|
||||||
|
* May throw runtime_error when an unexpected error occurs.
|
||||||
|
* \return The actual qos settings.
|
||||||
|
*/
|
||||||
|
RCLCPP_PUBLIC
|
||||||
|
rmw_qos_profile_t
|
||||||
|
get_actual_qos() const;
|
||||||
|
|
||||||
/// Compare this publisher to a gid.
|
/// Compare this publisher to a gid.
|
||||||
/**
|
/**
|
||||||
* Note that this function calls the next function.
|
* Note that this function calls the next function.
|
||||||
|
|
|
@ -159,7 +159,7 @@ PublisherBase::get_subscription_count() const
|
||||||
{
|
{
|
||||||
size_t inter_process_subscription_count = 0;
|
size_t inter_process_subscription_count = 0;
|
||||||
|
|
||||||
rmw_ret_t status = rcl_publisher_get_subscription_count(
|
rcl_ret_t status = rcl_publisher_get_subscription_count(
|
||||||
&publisher_handle_,
|
&publisher_handle_,
|
||||||
&inter_process_subscription_count);
|
&inter_process_subscription_count);
|
||||||
|
|
||||||
|
@ -197,6 +197,18 @@ PublisherBase::get_intra_process_subscription_count() const
|
||||||
return ipm->get_subscription_count(intra_process_publisher_id_);
|
return ipm->get_subscription_count(intra_process_publisher_id_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rmw_qos_profile_t
|
||||||
|
PublisherBase::get_actual_qos() const
|
||||||
|
{
|
||||||
|
const rmw_qos_profile_t * qos = rcl_publisher_get_actual_qos(&publisher_handle_);
|
||||||
|
if (!qos) {
|
||||||
|
auto msg = std::string("failed to get qos settings: ") + rcl_get_error_string().str;
|
||||||
|
rcl_reset_error();
|
||||||
|
throw std::runtime_error(msg);
|
||||||
|
}
|
||||||
|
return *qos;
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
PublisherBase::operator==(const rmw_gid_t & gid) const
|
PublisherBase::operator==(const rmw_gid_t & gid) const
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue