mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-05-18 01:57:34 +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
|
||||
|
||||
#include "../ecl.h"
|
||||
|
||||
template <typename T>
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user