From 5f177908551f54fc11eba3d1ac2e9cf0e8760e2b Mon Sep 17 00:00:00 2001 From: Christoph Froehlich Date: Mon, 18 Nov 2024 19:31:29 +0000 Subject: [PATCH] Use std::numeric_limits::quiet_NaN() --- include/control_toolbox/rate_limiter.hpp | 41 +++++++++++++++--------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/include/control_toolbox/rate_limiter.hpp b/include/control_toolbox/rate_limiter.hpp index 5e036dfc..9208e08a 100644 --- a/include/control_toolbox/rate_limiter.hpp +++ b/include/control_toolbox/rate_limiter.hpp @@ -20,6 +20,7 @@ #define CONTROL_TOOLBOX__RATE_LIMITER_HPP_ #include +#include #include #include @@ -48,10 +49,14 @@ class RateLimiter * If min_first_derivative_pos/max_first_derivative_neg values are NAN, symmetric limits are used */ RateLimiter( - T min_value = NAN, T max_value = NAN, - T min_first_derivative_neg = NAN, T max_first_derivative_pos = NAN, - T min_first_derivative_pos = NAN, T max_first_derivative_neg = NAN, - T min_second_derivative = NAN, T max_second_derivative = NAN); + T min_value = std::numeric_limits::quiet_NaN(), + T max_value = std::numeric_limits::quiet_NaN(), + T min_first_derivative_neg = std::numeric_limits::quiet_NaN(), + T max_first_derivative_pos = std::numeric_limits::quiet_NaN(), + T min_first_derivative_pos = std::numeric_limits::quiet_NaN(), + T max_first_derivative_neg = std::numeric_limits::quiet_NaN(), + T min_second_derivative = std::numeric_limits::quiet_NaN(), + T max_second_derivative = std::numeric_limits::quiet_NaN()); /** * \brief Limit the value and first_derivative @@ -109,10 +114,14 @@ class RateLimiter * If min_first_derivative_pos/max_first_derivative_neg values are NAN, symmetric limits are used */ void set_params( - T min_value = NAN, T max_value = NAN, - T min_first_derivative_neg = NAN, T max_first_derivative_pos = NAN, - T min_first_derivative_pos = NAN, T max_first_derivative_neg = NAN, - T min_second_derivative = NAN, T max_second_derivative = NAN); + T min_value = std::numeric_limits::quiet_NaN(), + T max_value = std::numeric_limits::quiet_NaN(), + T min_first_derivative_neg = std::numeric_limits::quiet_NaN(), + T max_first_derivative_pos = std::numeric_limits::quiet_NaN(), + T min_first_derivative_pos = std::numeric_limits::quiet_NaN(), + T max_first_derivative_neg = std::numeric_limits::quiet_NaN(), + T min_second_derivative = std::numeric_limits::quiet_NaN(), + T max_second_derivative = std::numeric_limits::quiet_NaN()); private: // Enable/Disable value/first_derivative/second_derivative limits: @@ -121,18 +130,18 @@ class RateLimiter bool has_second_derivative_limits_ = true; // value limits: - T min_value_ = NAN; - T max_value_ = NAN; + T min_value_ = std::numeric_limits::quiet_NaN(); + T max_value_ = std::numeric_limits::quiet_NaN(); // first_derivative limits: - T min_first_derivative_neg_ = NAN; - T max_first_derivative_pos_ = NAN; - T min_first_derivative_pos_ = NAN; - T max_first_derivative_neg_ = NAN; + T min_first_derivative_neg_ = std::numeric_limits::quiet_NaN(); + T max_first_derivative_pos_ = std::numeric_limits::quiet_NaN(); + T min_first_derivative_pos_ = std::numeric_limits::quiet_NaN(); + T max_first_derivative_neg_ = std::numeric_limits::quiet_NaN(); // second_derivative limits: - T min_second_derivative_ = NAN; - T max_second_derivative_ = NAN; + T min_second_derivative_ = std::numeric_limits::quiet_NaN(); + T max_second_derivative_ = std::numeric_limits::quiet_NaN(); }; template