diff --git a/ros2_foxglove_bridge/src/parameter_interface.cpp b/ros2_foxglove_bridge/src/parameter_interface.cpp index 7135af4..2ff4b0d 100644 --- a/ros2_foxglove_bridge/src/parameter_interface.cpp +++ b/ros2_foxglove_bridge/src/parameter_interface.cpp @@ -1,6 +1,8 @@ #include "foxglove_bridge/parameter_interface.hpp" #include +#include +#include #include #include @@ -9,6 +11,12 @@ namespace { constexpr char PARAM_SEP = '.'; +#if RCLCPP_VERSION_MAJOR > 16 +const rclcpp::ParametersQoS parameterQoS; +#else +const rmw_qos_profile_t& parameterQoS = rmw_qos_profile_parameters; +#endif + static std::pair getNodeAndParamName( const std::string& nodeNameAndParamName) { return {nodeNameAndParamName.substr(0UL, nodeNameAndParamName.find(PARAM_SEP)), @@ -195,8 +203,8 @@ ParameterList ParameterInterface::getParams(const std::vector& para auto paramClientIt = _paramClientsByNode.find(nodeName); if (paramClientIt == _paramClientsByNode.end()) { const auto insertedPair = _paramClientsByNode.emplace( - nodeName, rclcpp::AsyncParametersClient::make_shared( - _node, nodeName, rmw_qos_profile_parameters, _callbackGroup)); + nodeName, + rclcpp::AsyncParametersClient::make_shared(_node, nodeName, parameterQoS, _callbackGroup)); paramClientIt = insertedPair.first; } @@ -238,8 +246,8 @@ void ParameterInterface::setParams(const ParameterList& parameters, auto paramClientIt = _paramClientsByNode.find(nodeName); if (paramClientIt == _paramClientsByNode.end()) { const auto insertedPair = _paramClientsByNode.emplace( - nodeName, rclcpp::AsyncParametersClient::make_shared( - _node, nodeName, rmw_qos_profile_parameters, _callbackGroup)); + nodeName, + rclcpp::AsyncParametersClient::make_shared(_node, nodeName, parameterQoS, _callbackGroup)); paramClientIt = insertedPair.first; } @@ -281,8 +289,8 @@ void ParameterInterface::subscribeParams(const std::vector& paramNa auto paramClientIt = _paramClientsByNode.find(nodeName); if (paramClientIt == _paramClientsByNode.end()) { const auto insertedPair = _paramClientsByNode.emplace( - nodeName, rclcpp::AsyncParametersClient::make_shared( - _node, nodeName, rmw_qos_profile_parameters, _callbackGroup)); + nodeName, + rclcpp::AsyncParametersClient::make_shared(_node, nodeName, parameterQoS, _callbackGroup)); paramClientIt = insertedPair.first; }