make get_actual_qos return a rclcpp::QoS (#883)

* make get_actual_qos return a rclcpp::QoS

Signed-off-by: William Woodall <william@osrfoundation.org>

* make simpler following suggestion from review

Signed-off-by: William Woodall <william@osrfoundation.org>
This commit is contained in:
William Woodall 2019-10-08 15:15:08 -07:00 committed by GitHub
parent 9b4f049277
commit 27a97e868c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 7 deletions

View file

@ -29,6 +29,7 @@
#include "rclcpp/macros.hpp"
#include "rclcpp/mapped_ring_buffer.hpp"
#include "rclcpp/qos.hpp"
#include "rclcpp/qos_event.hpp"
#include "rclcpp/type_support_decl.hpp"
#include "rclcpp/visibility_control.hpp"
@ -153,10 +154,11 @@ public:
* 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
rclcpp::QoS
get_actual_qos() const;
/// Compare this publisher to a gid.

View file

@ -27,6 +27,7 @@
#include "rclcpp/any_subscription_callback.hpp"
#include "rclcpp/macros.hpp"
#include "rclcpp/qos.hpp"
#include "rclcpp/qos_event.hpp"
#include "rclcpp/type_support_decl.hpp"
#include "rclcpp/visibility_control.hpp"
@ -106,10 +107,11 @@ public:
* 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
rclcpp::QoS
get_actual_qos() const;
/// Borrow a new message.

View file

@ -205,7 +205,7 @@ PublisherBase::get_intra_process_subscription_count() const
return ipm->get_subscription_count(intra_process_publisher_id_);
}
rmw_qos_profile_t
rclcpp::QoS
PublisherBase::get_actual_qos() const
{
const rmw_qos_profile_t * qos = rcl_publisher_get_actual_qos(&publisher_handle_);
@ -214,7 +214,8 @@ PublisherBase::get_actual_qos() const
rcl_reset_error();
throw std::runtime_error(msg);
}
return *qos;
return rclcpp::QoS(rclcpp::QoSInitialization::from_rmw(*qos), *qos);
}
bool
@ -264,7 +265,8 @@ PublisherBase::setup_intra_process(
const rcl_publisher_options_t & intra_process_options)
{
// Intraprocess configuration is not allowed with "durability" qos policy non "volatile".
if (this->get_actual_qos().durability != RMW_QOS_POLICY_DURABILITY_VOLATILE) {
auto actual_durability = this->get_actual_qos().get_rmw_qos_profile().durability;
if (actual_durability != RMW_QOS_POLICY_DURABILITY_VOLATILE) {
throw std::invalid_argument(
"intraprocess communication is not allowed with durability qos policy non-volatile");
}

View file

@ -129,7 +129,7 @@ SubscriptionBase::get_event_handlers() const
return event_handlers_;
}
rmw_qos_profile_t
rclcpp::QoS
SubscriptionBase::get_actual_qos() const
{
const rmw_qos_profile_t * qos = rcl_subscription_get_actual_qos(subscription_handle_.get());
@ -138,7 +138,8 @@ SubscriptionBase::get_actual_qos() const
rcl_reset_error();
throw std::runtime_error(msg);
}
return *qos;
return rclcpp::QoS(rclcpp::QoSInitialization::from_rmw(*qos), *qos);
}
const rosidl_message_type_support_t &