mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-05-18 03:37:35 +08:00
AlphaFilter: prevent setParameters division by zero
This commit is contained in:
committed by
Daniel Agar
parent
b7d54b5477
commit
38cbd1a182
+7
-1
@@ -42,6 +42,8 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "../ecl.h"
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
class AlphaFilter {
|
class AlphaFilter {
|
||||||
public:
|
public:
|
||||||
@@ -65,7 +67,11 @@ public:
|
|||||||
*
|
*
|
||||||
* @param alpha [0,1] filter weight for the previous state. High value - long time constant.
|
* @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
|
* Set filter state to an initial value
|
||||||
|
|||||||
Reference in New Issue
Block a user