From 611659d4f1a311b684769b580c0e90e6018f40b2 Mon Sep 17 00:00:00 2001 From: Bluefairy-ljy <3099568863@qq.com> Date: Thu, 5 Nov 2026 16:18:50 +0800 Subject: [PATCH] Add clamp helper. --- rm_common/include/rm_common/math_utilities.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/rm_common/include/rm_common/math_utilities.h b/rm_common/include/rm_common/math_utilities.h index 841a5674..08aac317 100644 --- a/rm_common/include/rm_common/math_utilities.h +++ b/rm_common/include/rm_common/math_utilities.h @@ -76,3 +76,13 @@ T alpha(T cutoff, double freq) T te = 1.0 / freq; return 1.0 / (1.0 + tau / te); } + +template +T limit(T val, T min, T max) +{ + if (val > max) + return max; + if (val < min) + return min; + return val; +}