Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ jobs:
env:
- CI_NAME: clang-format
CLANG_FORMAT_CHECK: file
CLANG_FORMAT_VERSION: 10
CLANG_FORMAT_VERSION: 12
- CI_NAME: build-and-test rolling
- CI_NAME: build-and-test galactic
ROS_DISTRO: galactic
- CI_NAME: build-and-test humble
ROS_DISTRO: humble
- CI_NAME: clang-tidy
CLANG_TIDY: true

Expand Down
64 changes: 59 additions & 5 deletions src/rosparam_shortcuts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,74 @@
// this package
#include <rosparam_shortcuts/rosparam_shortcuts.h>

#include <rclcpp/parameter_value.hpp>

// Eigen/TF conversion
#if __has_include(<tf2_eigen/tf2_eigen.hpp>)
#include <tf2_eigen/tf2_eigen.hpp>
#else
#include <tf2_eigen/tf2_eigen.h>
#endif

static const rclcpp::Logger LOGGER = rclcpp::get_logger("rosparam_shortcuts");

namespace {
// Convert standard types to rclcpp::ParameterType
template <typename T>
struct rclcpp_type_converter
{};

template <>
struct rclcpp_type_converter<bool>
{ static constexpr rclcpp::ParameterType value = rclcpp::ParameterType::PARAMETER_BOOL; };

template <>
struct rclcpp_type_converter<int>
{ static constexpr rclcpp::ParameterType value = rclcpp::ParameterType::PARAMETER_INTEGER; };

template <>
struct rclcpp_type_converter<int64_t>
{ static constexpr rclcpp::ParameterType value = rclcpp::ParameterType::PARAMETER_INTEGER; };

template <>
struct rclcpp_type_converter<double>
{ static constexpr rclcpp::ParameterType value = rclcpp::ParameterType::PARAMETER_DOUBLE; };

template <>
struct rclcpp_type_converter<std::string>
{ static constexpr rclcpp::ParameterType value = rclcpp::ParameterType::PARAMETER_STRING; };

template <>
struct rclcpp_type_converter<std::vector<uint8_t>>
{ static constexpr rclcpp::ParameterType value = rclcpp::ParameterType::PARAMETER_BYTE_ARRAY; };

template <>
struct rclcpp_type_converter<std::vector<bool>>
{ static constexpr rclcpp::ParameterType value = rclcpp::ParameterType::PARAMETER_BOOL_ARRAY; };

template <>
struct rclcpp_type_converter<std::vector<int>>
{ static constexpr rclcpp::ParameterType value = rclcpp::ParameterType::PARAMETER_INTEGER_ARRAY; };

template <>
struct rclcpp_type_converter<std::vector<int64_t>>
{ static constexpr rclcpp::ParameterType value = rclcpp::ParameterType::PARAMETER_INTEGER_ARRAY; };

template <>
struct rclcpp_type_converter<std::vector<double>>
{ static constexpr rclcpp::ParameterType value = rclcpp::ParameterType::PARAMETER_DOUBLE_ARRAY; };

template <>
struct rclcpp_type_converter<std::vector<float>>
{ static constexpr rclcpp::ParameterType value = rclcpp::ParameterType::PARAMETER_DOUBLE_ARRAY; };

template <>
struct rclcpp_type_converter<std::vector<std::string>>
{ static constexpr rclcpp::ParameterType value = rclcpp::ParameterType::PARAMETER_STRING_ARRAY; };

template <typename T>
inline constexpr bool rclcpp_type_converter_v = rclcpp_type_converter<T>::value;

template <typename T>
void declare_parameter(const rclcpp::Node::SharedPtr& node, const std::string& param_name) {
if (!node->has_parameter(param_name))
node->declare_parameter<T>(param_name);
node->declare_parameter(param_name, rclcpp_type_converter_v<T>);
}

template <typename T>
Expand Down