From 38cbd1a18211f1702b403915ab37d5e22626432f Mon Sep 17 00:00:00 2001 From: Matthias Grob Date: Tue, 9 Jun 2020 22:04:02 +0200 Subject: [PATCH] AlphaFilter: prevent setParameters division by zero --- EKF/AlphaFilter.hpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/EKF/AlphaFilter.hpp b/EKF/AlphaFilter.hpp index ebf838a42c..ce68b08cd1 100644 --- a/EKF/AlphaFilter.hpp +++ b/EKF/AlphaFilter.hpp @@ -42,6 +42,8 @@ #pragma once +#include "../ecl.h" + template class AlphaFilter { public: @@ -65,7 +67,11 @@ public: * * @param alpha [0,1] filter weight for the previous state. High value - long time constant. */ - void setAlpha(float alpha) { _alpha = alpha; } + void setAlpha(float alpha) { + if (ISFINITE(alpha)) { + _alpha = alpha; + } + } /** * Set filter state to an initial value