diff --git a/rclcpp/include/rclcpp/parameter_client.hpp b/rclcpp/include/rclcpp/parameter_client.hpp index 1bbe4c2ebc..7dff6e9ad6 100644 --- a/rclcpp/include/rclcpp/parameter_client.hpp +++ b/rclcpp/include/rclcpp/parameter_client.hpp @@ -39,6 +39,7 @@ #include "rclcpp/node.hpp" #include "rclcpp/parameter.hpp" #include "rclcpp/parameter_map.hpp" +#include "rclcpp/qos.hpp" #include "rclcpp/type_support_decl.hpp" #include "rclcpp/visibility_control.hpp" #include "rmw/rmw.h" @@ -51,6 +52,37 @@ class AsyncParametersClient public: RCLCPP_SMART_PTR_DEFINITIONS(AsyncParametersClient) + /// Create an async parameters client. + /** + * \param[in] node_base_interface The node base interface of the corresponding node. + * \param[in] node_topics_interface Node topic base interface. + * \param[in] node_graph_interface The node graph interface of the corresponding node. + * \param[in] node_services_interface Node service interface. + * \param[in] remote_node_name Name of the remote node + * \param[in] qos_profile The rmw qos profile to use to subscribe + * \param[in] group (optional) The async parameter client will be added to this callback group. + * \deprecated use rclcpp::QoS instead of rmw_qos_profile_t + */ + [[deprecated("use rclcpp::QoS instead of rmw_qos_profile_t")]] + RCLCPP_PUBLIC + AsyncParametersClient( + const rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_base_interface, + const rclcpp::node_interfaces::NodeTopicsInterface::SharedPtr node_topics_interface, + const rclcpp::node_interfaces::NodeGraphInterface::SharedPtr node_graph_interface, + const rclcpp::node_interfaces::NodeServicesInterface::SharedPtr node_services_interface, + const std::string & remote_node_name, + const rmw_qos_profile_t & qos_profile, + rclcpp::CallbackGroup::SharedPtr group = nullptr) + : AsyncParametersClient( + node_base_interface, + node_topics_interface, + node_graph_interface, + node_services_interface, + remote_node_name, + rclcpp::QoS(rclcpp::QoSInitialization::from_rmw(qos_profile)), + group) + {} + /// Create an async parameters client. /** * \param[in] node_base_interface The node base interface of the corresponding node. @@ -58,7 +90,7 @@ class AsyncParametersClient * \param[in] node_graph_interface The node graph interface of the corresponding node. * \param[in] node_services_interface Node service interface. * \param[in] remote_node_name (optional) name of the remote node - * \param[in] qos_profile (optional) The rmw qos profile to use to subscribe + * \param[in] qos_profile (optional) The qos profile to use to subscribe * \param[in] group (optional) The async parameter client will be added to this callback group. */ RCLCPP_PUBLIC @@ -68,21 +100,45 @@ class AsyncParametersClient const rclcpp::node_interfaces::NodeGraphInterface::SharedPtr node_graph_interface, const rclcpp::node_interfaces::NodeServicesInterface::SharedPtr node_services_interface, const std::string & remote_node_name = "", - const rmw_qos_profile_t & qos_profile = rmw_qos_profile_parameters, + const rclcpp::QoS & qos_profile = rclcpp::ParametersQoS(), rclcpp::CallbackGroup::SharedPtr group = nullptr); /// Constructor /** - * \param[in] node The async paramters client will be added to this node. + * \param[in] node The async parameters client will be added to this node. + * \param[in] remote_node_name name of the remote node + * \param[in] qos_profile The rmw qos profile to use to subscribe + * \param[in] group (optional) The async parameter client will be added to this callback group. + * \deprecated use rclcpp::QoS instead of rmw_qos_profile_t + */ + template + [[deprecated("use rclcpp::QoS instead of rmw_qos_profile_t")]] + AsyncParametersClient( + const std::shared_ptr node, + const std::string & remote_node_name, + const rmw_qos_profile_t & qos_profile, + rclcpp::CallbackGroup::SharedPtr group = nullptr) + : AsyncParametersClient( + node->get_node_base_interface(), + node->get_node_topics_interface(), + node->get_node_graph_interface(), + node->get_node_services_interface(), + remote_node_name, + rclcpp::QoS(rclcpp::QoSInitialization::from_rmw(qos_profile)), + group) + {} + + /** + * \param[in] node The async parameters client will be added to this node. * \param[in] remote_node_name (optional) name of the remote node - * \param[in] qos_profile (optional) The rmw qos profile to use to subscribe + * \param[in] qos_profile (optional) The qos profile to use to subscribe * \param[in] group (optional) The async parameter client will be added to this callback group. */ template explicit AsyncParametersClient( const std::shared_ptr node, const std::string & remote_node_name = "", - const rmw_qos_profile_t & qos_profile = rmw_qos_profile_parameters, + const rclcpp::QoS & qos_profile = rclcpp::ParametersQoS(), rclcpp::CallbackGroup::SharedPtr group = nullptr) : AsyncParametersClient( node->get_node_base_interface(), @@ -96,16 +152,40 @@ class AsyncParametersClient /// Constructor /** - * \param[in] node The async paramters client will be added to this node. + * \param[in] node The async parameters client will be added to this node. + * \param[in] remote_node_name Name of the remote node + * \param[in] qos_profile The rmw qos profile to use to subscribe + * \param[in] group (optional) The async parameter client will be added to this callback group. + * \deprecated use rclcpp::QoS instead of rmw_qos_profile_t + */ + template + [[deprecated("use rclcpp::QoS instead of rmw_qos_profile_t")]] + AsyncParametersClient( + NodeT * node, + const std::string & remote_node_name, + const rmw_qos_profile_t & qos_profile, + rclcpp::CallbackGroup::SharedPtr group = nullptr) + : AsyncParametersClient( + node->get_node_base_interface(), + node->get_node_topics_interface(), + node->get_node_graph_interface(), + node->get_node_services_interface(), + remote_node_name, + rclcpp::QoS(rclcpp::QoSInitialization::from_rmw(qos_profile)), + group) + {} + + /** + * \param[in] node The async parameters client will be added to this node. * \param[in] remote_node_name (optional) name of the remote node - * \param[in] qos_profile (optional) The rmw qos profile to use to subscribe + * \param[in] qos_profile (optional) The qos profile to use to subscribe * \param[in] group (optional) The async parameter client will be added to this callback group. */ template explicit AsyncParametersClient( NodeT * node, const std::string & remote_node_name = "", - const rmw_qos_profile_t & qos_profile = rmw_qos_profile_parameters, + const rclcpp::QoS & qos_profile = rclcpp::ParametersQoS(), rclcpp::CallbackGroup::SharedPtr group = nullptr) : AsyncParametersClient( node->get_node_base_interface(), @@ -211,9 +291,7 @@ class AsyncParametersClient typename rclcpp::Subscription::SharedPtr on_parameter_event( CallbackT && callback, - const rclcpp::QoS & qos = ( - rclcpp::QoS(rclcpp::QoSInitialization::from_rmw(rmw_qos_profile_parameter_events)) - ), + const rclcpp::QoS & qos = rclcpp::ParameterEventsQoS(), const rclcpp::SubscriptionOptionsWithAllocator & options = ( rclcpp::SubscriptionOptionsWithAllocator() )) @@ -238,9 +316,7 @@ class AsyncParametersClient on_parameter_event( NodeT && node, CallbackT && callback, - const rclcpp::QoS & qos = ( - rclcpp::QoS(rclcpp::QoSInitialization::from_rmw(rmw_qos_profile_parameter_events)) - ), + const rclcpp::QoS & qos = rclcpp::ParameterEventsQoS(), const rclcpp::SubscriptionOptionsWithAllocator & options = ( rclcpp::SubscriptionOptionsWithAllocator() )) @@ -307,11 +383,24 @@ class SyncParametersClient public: RCLCPP_SMART_PTR_DEFINITIONS(SyncParametersClient) + template + [[deprecated("use rclcpp::QoS instead of rmw_qos_profile_t")]] + SyncParametersClient( + std::shared_ptr node, + const std::string & remote_node_name, + const rmw_qos_profile_t & qos_profile) + : SyncParametersClient( + std::make_shared(), + node, + remote_node_name, + rclcpp::QoS(rclcpp::QoSInitialization::from_rmw(qos_profile))) + {} + template explicit SyncParametersClient( std::shared_ptr node, const std::string & remote_node_name = "", - const rmw_qos_profile_t & qos_profile = rmw_qos_profile_parameters) + const rclcpp::QoS & qos_profile = rclcpp::ParametersQoS()) : SyncParametersClient( std::make_shared(), node, @@ -319,12 +408,29 @@ class SyncParametersClient qos_profile) {} + template + [[deprecated("use rclcpp::QoS instead of rmw_qos_profile_t")]] + SyncParametersClient( + rclcpp::Executor::SharedPtr executor, + std::shared_ptr node, + const std::string & remote_node_name, + const rmw_qos_profile_t & qos_profile) + : SyncParametersClient( + executor, + node->get_node_base_interface(), + node->get_node_topics_interface(), + node->get_node_graph_interface(), + node->get_node_services_interface(), + remote_node_name, + rclcpp::QoS(rclcpp::QoSInitialization::from_rmw(qos_profile))) + {} + template SyncParametersClient( rclcpp::Executor::SharedPtr executor, std::shared_ptr node, const std::string & remote_node_name = "", - const rmw_qos_profile_t & qos_profile = rmw_qos_profile_parameters) + const rclcpp::QoS & qos_profile = rclcpp::ParametersQoS()) : SyncParametersClient( executor, node->get_node_base_interface(), @@ -335,11 +441,24 @@ class SyncParametersClient qos_profile) {} + template + [[deprecated("use rclcpp::QoS instead of rmw_qos_profile_t")]] + SyncParametersClient( + NodeT * node, + const std::string & remote_node_name, + const rmw_qos_profile_t & qos_profile) + : SyncParametersClient( + std::make_shared(), + node, + remote_node_name, + rclcpp::QoS(rclcpp::QoSInitialization::from_rmw(qos_profile))) + {} + template explicit SyncParametersClient( NodeT * node, const std::string & remote_node_name = "", - const rmw_qos_profile_t & qos_profile = rmw_qos_profile_parameters) + const rclcpp::QoS & qos_profile = rclcpp::ParametersQoS()) : SyncParametersClient( std::make_shared(), node, @@ -347,12 +466,29 @@ class SyncParametersClient qos_profile) {} + template + [[deprecated("use rclcpp::QoS instead of rmw_qos_profile_t")]] + SyncParametersClient( + rclcpp::Executor::SharedPtr executor, + NodeT * node, + const std::string & remote_node_name, + const rmw_qos_profile_t & qos_profile) + : SyncParametersClient( + executor, + node->get_node_base_interface(), + node->get_node_topics_interface(), + node->get_node_graph_interface(), + node->get_node_services_interface(), + remote_node_name, + rclcpp::QoS(rclcpp::QoSInitialization::from_rmw(qos_profile))) + {} + template SyncParametersClient( rclcpp::Executor::SharedPtr executor, NodeT * node, const std::string & remote_node_name = "", - const rmw_qos_profile_t & qos_profile = rmw_qos_profile_parameters) + const rclcpp::QoS & qos_profile = rclcpp::ParametersQoS()) : SyncParametersClient( executor, node->get_node_base_interface(), @@ -363,6 +499,28 @@ class SyncParametersClient qos_profile) {} + [[deprecated("use rclcpp::QoS instead of rmw_qos_profile_t")]] + RCLCPP_PUBLIC + SyncParametersClient( + rclcpp::Executor::SharedPtr executor, + const rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_base_interface, + const rclcpp::node_interfaces::NodeTopicsInterface::SharedPtr node_topics_interface, + const rclcpp::node_interfaces::NodeGraphInterface::SharedPtr node_graph_interface, + const rclcpp::node_interfaces::NodeServicesInterface::SharedPtr node_services_interface, + const std::string & remote_node_name, + const rmw_qos_profile_t & qos_profile) + : executor_(executor), node_base_interface_(node_base_interface) + { + async_parameters_client_ = + std::make_shared( + node_base_interface, + node_topics_interface, + node_graph_interface, + node_services_interface, + remote_node_name, + rclcpp::QoS(rclcpp::QoSInitialization::from_rmw(qos_profile))); + } + RCLCPP_PUBLIC SyncParametersClient( rclcpp::Executor::SharedPtr executor, @@ -371,7 +529,7 @@ class SyncParametersClient const rclcpp::node_interfaces::NodeGraphInterface::SharedPtr node_graph_interface, const rclcpp::node_interfaces::NodeServicesInterface::SharedPtr node_services_interface, const std::string & remote_node_name = "", - const rmw_qos_profile_t & qos_profile = rmw_qos_profile_parameters) + const rclcpp::QoS & qos_profile = rclcpp::ParametersQoS()) : executor_(executor), node_base_interface_(node_base_interface) { async_parameters_client_ = diff --git a/rclcpp/include/rclcpp/parameter_service.hpp b/rclcpp/include/rclcpp/parameter_service.hpp index 143a5223c8..a952939aca 100644 --- a/rclcpp/include/rclcpp/parameter_service.hpp +++ b/rclcpp/include/rclcpp/parameter_service.hpp @@ -28,6 +28,7 @@ #include "rclcpp/macros.hpp" #include "rclcpp/node.hpp" #include "rclcpp/parameter.hpp" +#include "rclcpp/qos.hpp" #include "rclcpp/visibility_control.hpp" #include "rmw/rmw.h" @@ -39,12 +40,26 @@ class ParameterService public: RCLCPP_SMART_PTR_DEFINITIONS(ParameterService) + [[deprecated("use rclcpp::QoS instead of rmw_qos_profile_t")]] RCLCPP_PUBLIC - explicit ParameterService( + ParameterService( const std::shared_ptr node_base, const std::shared_ptr node_services, rclcpp::node_interfaces::NodeParametersInterface * node_params, - const rmw_qos_profile_t & qos_profile = rmw_qos_profile_parameters); + const rmw_qos_profile_t & qos_profile) + : ParameterService( + node_base, + node_services, + node_params, + rclcpp::QoS(rclcpp::QoSInitialization::from_rmw(qos_profile))) + {} + + RCLCPP_PUBLIC + ParameterService( + const std::shared_ptr node_base, + const std::shared_ptr node_services, + rclcpp::node_interfaces::NodeParametersInterface * node_params, + const rclcpp::QoS & qos_profile = rclcpp::ParametersQoS()); private: rclcpp::Service::SharedPtr get_parameters_service_; diff --git a/rclcpp/src/rclcpp/parameter_client.cpp b/rclcpp/src/rclcpp/parameter_client.cpp index 64e415e82f..b60585ef00 100644 --- a/rclcpp/src/rclcpp/parameter_client.cpp +++ b/rclcpp/src/rclcpp/parameter_client.cpp @@ -35,7 +35,7 @@ AsyncParametersClient::AsyncParametersClient( const rclcpp::node_interfaces::NodeGraphInterface::SharedPtr node_graph_interface, const rclcpp::node_interfaces::NodeServicesInterface::SharedPtr node_services_interface, const std::string & remote_node_name, - const rmw_qos_profile_t & qos_profile, + const rclcpp::QoS & qos_profile, rclcpp::CallbackGroup::SharedPtr group) : node_topics_interface_(node_topics_interface) { @@ -46,7 +46,7 @@ AsyncParametersClient::AsyncParametersClient( } rcl_client_options_t options = rcl_client_get_default_options(); - options.qos = qos_profile; + options.qos = qos_profile.get_rmw_qos_profile(); using rclcpp::Client; using rclcpp::ClientBase; diff --git a/rclcpp/src/rclcpp/parameter_service.cpp b/rclcpp/src/rclcpp/parameter_service.cpp index 5c30917499..501ac399f8 100644 --- a/rclcpp/src/rclcpp/parameter_service.cpp +++ b/rclcpp/src/rclcpp/parameter_service.cpp @@ -29,7 +29,7 @@ ParameterService::ParameterService( const std::shared_ptr node_base, const std::shared_ptr node_services, rclcpp::node_interfaces::NodeParametersInterface * node_params, - const rmw_qos_profile_t & qos_profile) + const rclcpp::QoS & qos_profile) { const std::string node_name = node_base->get_name();