@ -37,6 +37,7 @@
@@ -37,6 +37,7 @@
* @ author Lorenz Meier < lorenz @ px4 . io >
*/
# include <px4_defines.h>
# include "estimator_22states.h"
# include <string.h>
# include <stdio.h>
@ -2392,9 +2393,9 @@ int AttPosEKF::RecallStates(float* statesForFusion, uint64_t msec)
@@ -2392,9 +2393,9 @@ int AttPosEKF::RecallStates(float* statesForFusion, uint64_t msec)
if ( bestTimeDelta < 200 ) // only output stored state if < 200 msec retrieval error
{
for ( size_t i = 0 ; i < EKF_STATE_ESTIMATES ; i + + ) {
if ( std : : isfinite ( storedStates [ i ] [ bestStoreIndex ] ) ) {
if ( PX4_ISFINITE ( storedStates [ i ] [ bestStoreIndex ] ) ) {
statesForFusion [ i ] = storedStates [ i ] [ bestStoreIndex ] ;
} else if ( std : : isfinite ( states [ i ] ) ) {
} else if ( PX4_ISFINITE ( states [ i ] ) ) {
statesForFusion [ i ] = states [ i ] ;
} else {
// There is not much we can do here, except reporting the error we just
@ -2406,7 +2407,7 @@ int AttPosEKF::RecallStates(float* statesForFusion, uint64_t msec)
@@ -2406,7 +2407,7 @@ int AttPosEKF::RecallStates(float* statesForFusion, uint64_t msec)
else // otherwise output current state
{
for ( size_t i = 0 ; i < EKF_STATE_ESTIMATES ; i + + ) {
if ( std : : isfinite ( states [ i ] ) ) {
if ( PX4_ISFINITE ( states [ i ] ) ) {
statesForFusion [ i ] = states [ i ] ;
} else {
ret + + ;
@ -2630,7 +2631,7 @@ float AttPosEKF::ConstrainFloat(float val, float min_val, float max_val)
@@ -2630,7 +2631,7 @@ float AttPosEKF::ConstrainFloat(float val, float min_val, float max_val)
ret = val ;
}
if ( ! std : : isfinite ( val ) ) {
if ( ! PX4_ISFINITE ( val ) ) {
ekf_debug ( " constrain: non-finite! " ) ;
}
@ -2710,7 +2711,7 @@ void AttPosEKF::ConstrainStates()
@@ -2710,7 +2711,7 @@ void AttPosEKF::ConstrainStates()
// 19-21: Body Magnetic Field Vector - gauss (X,Y,Z)
// Constrain dtIMUfilt
if ( ! isfinite ( dtIMUfilt ) | | ( fabsf ( dtIMU - dtIMUfilt ) > 0.01f ) ) {
if ( ! PX4_ISFINITE ( dtIMUfilt ) | | ( fabsf ( dtIMU - dtIMUfilt ) > 0.01f ) ) {
dtIMUfilt = dtIMU ;
}
@ -2922,21 +2923,21 @@ bool AttPosEKF::StatesNaN() {
@@ -2922,21 +2923,21 @@ bool AttPosEKF::StatesNaN() {
bool err = false ;
// check all integrators
if ( ! std : : isfinite ( summedDelAng . x ) | | ! std : : isfinite ( summedDelAng . y ) | | ! std : : isfinite ( summedDelAng . z ) ) {
if ( ! PX4_ISFINITE ( summedDelAng . x ) | | ! PX4_ISFINITE ( summedDelAng . y ) | | ! PX4_ISFINITE ( summedDelAng . z ) ) {
current_ekf_state . angNaN = true ;
ekf_debug ( " summedDelAng NaN: x: %f y: %f z: %f " , ( double ) summedDelAng . x , ( double ) summedDelAng . y , ( double ) summedDelAng . z ) ;
err = true ;
goto out ;
} // delta angles
if ( ! std : : isfinite ( correctedDelAng . x ) | | ! std : : isfinite ( correctedDelAng . y ) | | ! std : : isfinite ( correctedDelAng . z ) ) {
if ( ! PX4_ISFINITE ( correctedDelAng . x ) | | ! PX4_ISFINITE ( correctedDelAng . y ) | | ! PX4_ISFINITE ( correctedDelAng . z ) ) {
current_ekf_state . angNaN = true ;
ekf_debug ( " correctedDelAng NaN: x: %f y: %f z: %f " , ( double ) correctedDelAng . x , ( double ) correctedDelAng . y , ( double ) correctedDelAng . z ) ;
err = true ;
goto out ;
} // delta angles
if ( ! std : : isfinite ( summedDelVel . x ) | | ! std : : isfinite ( summedDelVel . y ) | | ! std : : isfinite ( summedDelVel . z ) ) {
if ( ! PX4_ISFINITE ( summedDelVel . x ) | | ! PX4_ISFINITE ( summedDelVel . y ) | | ! PX4_ISFINITE ( summedDelVel . z ) ) {
current_ekf_state . summedDelVelNaN = true ;
ekf_debug ( " summedDelVel NaN: x: %f y: %f z: %f " , ( double ) summedDelVel . x , ( double ) summedDelVel . y , ( double ) summedDelVel . z ) ;
err = true ;
@ -2946,7 +2947,7 @@ bool AttPosEKF::StatesNaN() {
@@ -2946,7 +2947,7 @@ bool AttPosEKF::StatesNaN() {
// check all states and covariance matrices
for ( size_t i = 0 ; i < EKF_STATE_ESTIMATES ; i + + ) {
for ( size_t j = 0 ; j < EKF_STATE_ESTIMATES ; j + + ) {
if ( ! std : : isfinite ( KH [ i ] [ j ] ) ) {
if ( ! PX4_ISFINITE ( KH [ i ] [ j ] ) ) {
current_ekf_state . KHNaN = true ;
err = true ;
@ -2954,7 +2955,7 @@ bool AttPosEKF::StatesNaN() {
@@ -2954,7 +2955,7 @@ bool AttPosEKF::StatesNaN() {
goto out ;
} // intermediate result used for covariance updates
if ( ! std : : isfinite ( KHP [ i ] [ j ] ) ) {
if ( ! PX4_ISFINITE ( KHP [ i ] [ j ] ) ) {
current_ekf_state . KHPNaN = true ;
err = true ;
@ -2962,7 +2963,7 @@ bool AttPosEKF::StatesNaN() {
@@ -2962,7 +2963,7 @@ bool AttPosEKF::StatesNaN() {
goto out ;
} // intermediate result used for covariance updates
if ( ! std : : isfinite ( P [ i ] [ j ] ) ) {
if ( ! PX4_ISFINITE ( P [ i ] [ j ] ) ) {
current_ekf_state . covarianceNaN = true ;
err = true ;
@ -2970,7 +2971,7 @@ bool AttPosEKF::StatesNaN() {
@@ -2970,7 +2971,7 @@ bool AttPosEKF::StatesNaN() {
} // covariance matrix
}
if ( ! std : : isfinite ( Kfusion [ i ] ) ) {
if ( ! PX4_ISFINITE ( Kfusion [ i ] ) ) {
current_ekf_state . kalmanGainsNaN = true ;
ekf_debug ( " Kfusion NaN " ) ;
@ -2978,7 +2979,7 @@ bool AttPosEKF::StatesNaN() {
@@ -2978,7 +2979,7 @@ bool AttPosEKF::StatesNaN() {
goto out ;
} // Kalman gains
if ( ! std : : isfinite ( states [ i ] ) ) {
if ( ! PX4_ISFINITE ( states [ i ] ) ) {
current_ekf_state . statesNaN = true ;
ekf_debug ( " states NaN: i: %u val: %f " , i , ( double ) states [ i ] ) ;