Merge pull request #764 from PX4/inav_nan_checks

position_estimator_inav: added NaN checks
This commit is contained in:
Thomas Gubler 2014-03-21 17:28:40 +01:00
commit 0cc7270b83
1 changed files with 15 additions and 9 deletions

View File

@ -5,16 +5,21 @@
* Author: Anton Babushkin <rk3dov@gmail.com>
*/
#include <math.h>
#include "inertial_filter.h"
void inertial_filter_predict(float dt, float x[3])
{
if (isfinite(dt)) {
x[0] += x[1] * dt + x[2] * dt * dt / 2.0f;
x[1] += x[2] * dt;
}
}
void inertial_filter_correct(float e, float dt, float x[3], int i, float w)
{
if (isfinite(e) && isfinite(w) && isfinite(dt)) {
float ewdt = e * w * dt;
x[i] += ewdt;
@ -25,4 +30,5 @@ void inertial_filter_correct(float e, float dt, float x[3], int i, float w)
} else if (i == 1) {
x[2] += w * ewdt;
}
}
}