diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 44cefeb..5bcd87e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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 diff --git a/src/rosparam_shortcuts.cpp b/src/rosparam_shortcuts.cpp index a56e648..33d83a7 100644 --- a/src/rosparam_shortcuts.cpp +++ b/src/rosparam_shortcuts.cpp @@ -37,20 +37,74 @@ // this package #include +#include + // Eigen/TF conversion -#if __has_include() #include -#else -#include -#endif static const rclcpp::Logger LOGGER = rclcpp::get_logger("rosparam_shortcuts"); namespace { +// Convert standard types to rclcpp::ParameterType +template +struct rclcpp_type_converter +{}; + +template <> +struct rclcpp_type_converter +{ static constexpr rclcpp::ParameterType value = rclcpp::ParameterType::PARAMETER_BOOL; }; + +template <> +struct rclcpp_type_converter +{ static constexpr rclcpp::ParameterType value = rclcpp::ParameterType::PARAMETER_INTEGER; }; + +template <> +struct rclcpp_type_converter +{ static constexpr rclcpp::ParameterType value = rclcpp::ParameterType::PARAMETER_INTEGER; }; + +template <> +struct rclcpp_type_converter +{ static constexpr rclcpp::ParameterType value = rclcpp::ParameterType::PARAMETER_DOUBLE; }; + +template <> +struct rclcpp_type_converter +{ static constexpr rclcpp::ParameterType value = rclcpp::ParameterType::PARAMETER_STRING; }; + +template <> +struct rclcpp_type_converter> +{ static constexpr rclcpp::ParameterType value = rclcpp::ParameterType::PARAMETER_BYTE_ARRAY; }; + +template <> +struct rclcpp_type_converter> +{ static constexpr rclcpp::ParameterType value = rclcpp::ParameterType::PARAMETER_BOOL_ARRAY; }; + +template <> +struct rclcpp_type_converter> +{ static constexpr rclcpp::ParameterType value = rclcpp::ParameterType::PARAMETER_INTEGER_ARRAY; }; + +template <> +struct rclcpp_type_converter> +{ static constexpr rclcpp::ParameterType value = rclcpp::ParameterType::PARAMETER_INTEGER_ARRAY; }; + +template <> +struct rclcpp_type_converter> +{ static constexpr rclcpp::ParameterType value = rclcpp::ParameterType::PARAMETER_DOUBLE_ARRAY; }; + +template <> +struct rclcpp_type_converter> +{ static constexpr rclcpp::ParameterType value = rclcpp::ParameterType::PARAMETER_DOUBLE_ARRAY; }; + +template <> +struct rclcpp_type_converter> +{ static constexpr rclcpp::ParameterType value = rclcpp::ParameterType::PARAMETER_STRING_ARRAY; }; + +template +inline constexpr bool rclcpp_type_converter_v = rclcpp_type_converter::value; + template void declare_parameter(const rclcpp::Node::SharedPtr& node, const std::string& param_name) { if (!node->has_parameter(param_name)) - node->declare_parameter(param_name); + node->declare_parameter(param_name, rclcpp_type_converter_v); } template