Browse Source

AP_NavEKF3: move posvel fusion health booleans to be on the stack

c415-sdk
Peter Barker 4 years ago committed by Peter Barker
parent
commit
b79a26135c
  1. 21
      libraries/AP_NavEKF3/AP_NavEKF3_PosVelFusion.cpp
  2. 3
      libraries/AP_NavEKF3/AP_NavEKF3_core.h

21
libraries/AP_NavEKF3/AP_NavEKF3_PosVelFusion.cpp

@ -35,26 +35,21 @@ void NavEKF3_core::ResetVelocity(resetDataSource velResetSource)
stateStruct.velocity.y = gps_corrected.vel.y; stateStruct.velocity.y = gps_corrected.vel.y;
// set the variances using the reported GPS speed accuracy // set the variances using the reported GPS speed accuracy
P[5][5] = P[4][4] = sq(MAX(frontend->_gpsHorizVelNoise,gpsSpdAccuracy)); P[5][5] = P[4][4] = sq(MAX(frontend->_gpsHorizVelNoise,gpsSpdAccuracy));
// clear the timeout flags and counters
velTimeout = false;
lastVelPassTime_ms = imuSampleTime_ms;
} else if ((imuSampleTime_ms - extNavVelMeasTime_ms < 250 && velResetSource == resetDataSource::DEFAULT) || velResetSource == resetDataSource::EXTNAV) { } else if ((imuSampleTime_ms - extNavVelMeasTime_ms < 250 && velResetSource == resetDataSource::DEFAULT) || velResetSource == resetDataSource::EXTNAV) {
// use external nav data as the 2nd preference // use external nav data as the 2nd preference
// already corrected for sensor position // already corrected for sensor position
stateStruct.velocity.x = extNavVelDelayed.vel.x; stateStruct.velocity.x = extNavVelDelayed.vel.x;
stateStruct.velocity.y = extNavVelDelayed.vel.y; stateStruct.velocity.y = extNavVelDelayed.vel.y;
P[5][5] = P[4][4] = sq(extNavVelDelayed.err); P[5][5] = P[4][4] = sq(extNavVelDelayed.err);
velTimeout = false;
lastVelPassTime_ms = imuSampleTime_ms;
} else { } else {
stateStruct.velocity.x = 0.0f; stateStruct.velocity.x = 0.0f;
stateStruct.velocity.y = 0.0f; stateStruct.velocity.y = 0.0f;
// set the variances using the likely speed range // set the variances using the likely speed range
P[5][5] = P[4][4] = sq(25.0f); P[5][5] = P[4][4] = sq(25.0f);
// clear the timeout flags and counters
velTimeout = false;
lastVelPassTime_ms = imuSampleTime_ms;
} }
// clear the timeout flags and counters
velTimeout = false;
lastVelPassTime_ms = imuSampleTime_ms;
} }
for (uint8_t i=0; i<imu_buffer_length; i++) { for (uint8_t i=0; i<imu_buffer_length; i++) {
storedOutput[i].velocity.x = stateStruct.velocity.x; storedOutput[i].velocity.x = stateStruct.velocity.x;
@ -576,9 +571,9 @@ void NavEKF3_core::SelectVelPosFusion()
void NavEKF3_core::FuseVelPosNED() void NavEKF3_core::FuseVelPosNED()
{ {
// health is set bad until test passed // health is set bad until test passed
velHealth = false; bool velHealth = false; // boolean true if velocity measurements have passed innovation consistency check
posHealth = false; bool posHealth = false; // boolean true if position measurements have passed innovation consistency check
hgtHealth = false; bool hgtHealth = false; // boolean true if height measurements have passed innovation consistency check
// declare variables used to check measurement errors // declare variables used to check measurement errors
Vector3f velInnov; Vector3f velInnov;
@ -711,8 +706,6 @@ void NavEKF3_core::FuseVelPosNED()
velTestRatio = 0.0f; velTestRatio = 0.0f;
} }
} }
} else {
posHealth = false;
} }
} }
@ -757,8 +750,6 @@ void NavEKF3_core::FuseVelPosNED()
// Reset the normalised innovation to avoid failing the bad fusion tests // Reset the normalised innovation to avoid failing the bad fusion tests
velTestRatio = 0.0f; velTestRatio = 0.0f;
} }
} else {
velHealth = false;
} }
} }

3
libraries/AP_NavEKF3/AP_NavEKF3_core.h

@ -937,9 +937,6 @@ private:
// Variables // Variables
bool statesInitialised; // boolean true when filter states have been initialised bool statesInitialised; // boolean true when filter states have been initialised
bool velHealth; // boolean true if velocity measurements have passed innovation consistency check
bool posHealth; // boolean true if position measurements have passed innovation consistency check
bool hgtHealth; // boolean true if height measurements have passed innovation consistency check
bool magHealth; // boolean true if magnetometer has passed innovation consistency check bool magHealth; // boolean true if magnetometer has passed innovation consistency check
bool tasHealth; // boolean true if true airspeed has passed innovation consistency check bool tasHealth; // boolean true if true airspeed has passed innovation consistency check
bool velTimeout; // boolean true if velocity measurements have failed innovation consistency check and timed out bool velTimeout; // boolean true if velocity measurements have failed innovation consistency check and timed out

Loading…
Cancel
Save