10 #include <nlohmann/json.hpp>
12 #include "rclcpp/rclcpp.hpp"
14 #include "rcl_interfaces/msg/set_parameters_result.hpp"
15 #include "rcl_interfaces/msg/floating_point_range.hpp"
16 #include "rcl_interfaces/msg/parameter_descriptor.hpp"
28 template<typename T, typename = typename std::enable_if<std::is_arithmetic<T>::value, T>::type>
30 rclcpp::Parameter
const& param,
31 rcl_interfaces::msg::SetParametersResult& result,
32 T min = numeric_limits<T>::min(),
33 T max = numeric_limits<T>::max()
37 if( std::is_same<T, int>::value ) {
38 if( param.get_type() == rclcpp::ParameterType::PARAMETER_INTEGER ) {
39 paramValue = param.as_int();
42 result.successful =
false;
43 result.reason +=
"[" + param.get_name() +
"] Type wrong. Must be INTEGER; ";
47 else if ( std::is_same<T, double>::value || std::is_same<T, float>::value ) {
48 if( param.get_type() == rclcpp::ParameterType::PARAMETER_DOUBLE ) {
49 paramValue = param.as_double();
52 result.successful =
false;
53 result.reason +=
"[" + param.get_name() +
"] Type wrong. Must be DOUBLE; ";
58 result.successful =
false;
59 result.reason +=
"[" + param.get_name() +
"] Type wrong.; ";
63 if( paramValue < min ) {
64 result.successful =
false;
65 result.reason +=
"[" + param.get_name() +
"] Value too low. Must be larger or equal to " + std::to_string(min) +
" ; ";
68 if( paramValue > max ) {
69 result.successful =
false;
70 result.reason +=
"[" + param.get_name() +
"] Value too high. Must be lower or equal to " + std::to_string(max) +
" ; ";
108 #endif // _SETTINGS_H_