Skip to content

Commit

Permalink
backwards compatibility fix for humble
Browse files Browse the repository at this point in the history
  • Loading branch information
achim-k committed Jul 30, 2024
1 parent 8bab64c commit fc4b2c7
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions ros2_foxglove_bridge/src/parameter_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include <nlohmann/json.hpp>
#include <rclcpp/qos.hpp>
#include <rclcpp/version.h>

#include <foxglove_bridge/regex_utils.hpp>
#include <foxglove_bridge/utils.hpp>
Expand All @@ -10,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<std::string, std::string> getNodeAndParamName(
const std::string& nodeNameAndParamName) {
return {nodeNameAndParamName.substr(0UL, nodeNameAndParamName.find(PARAM_SEP)),
Expand Down Expand Up @@ -196,8 +203,8 @@ ParameterList ParameterInterface::getParams(const std::vector<std::string>& para
auto paramClientIt = _paramClientsByNode.find(nodeName);
if (paramClientIt == _paramClientsByNode.end()) {
const auto insertedPair = _paramClientsByNode.emplace(
nodeName, rclcpp::AsyncParametersClient::make_shared(
_node, nodeName, rclcpp::ParametersQoS(), _callbackGroup));
nodeName,
rclcpp::AsyncParametersClient::make_shared(_node, nodeName, parameterQoS, _callbackGroup));
paramClientIt = insertedPair.first;
}

Expand Down Expand Up @@ -239,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, rclcpp::ParametersQoS(), _callbackGroup));
nodeName,
rclcpp::AsyncParametersClient::make_shared(_node, nodeName, parameterQoS, _callbackGroup));
paramClientIt = insertedPair.first;
}

Expand Down Expand Up @@ -282,8 +289,8 @@ void ParameterInterface::subscribeParams(const std::vector<std::string>& paramNa
auto paramClientIt = _paramClientsByNode.find(nodeName);
if (paramClientIt == _paramClientsByNode.end()) {
const auto insertedPair = _paramClientsByNode.emplace(
nodeName, rclcpp::AsyncParametersClient::make_shared(
_node, nodeName, rclcpp::ParametersQoS(), _callbackGroup));
nodeName,
rclcpp::AsyncParametersClient::make_shared(_node, nodeName, parameterQoS, _callbackGroup));
paramClientIt = insertedPair.first;
}

Expand Down

0 comments on commit fc4b2c7

Please sign in to comment.