|
|
|
@ -281,8 +281,7 @@ void NavEKF3_core::InitialiseVariables()
@@ -281,8 +281,7 @@ void NavEKF3_core::InitialiseVariables()
|
|
|
|
|
gpsVertVelFilt = 0.0f; |
|
|
|
|
gpsHorizVelFilt = 0.0f; |
|
|
|
|
memset(&statesArray, 0, sizeof(statesArray)); |
|
|
|
|
posDownDerivative = 0.0f; |
|
|
|
|
posDown = 0.0f; |
|
|
|
|
memset(&vertCompFiltState, 0, sizeof(vertCompFiltState)); |
|
|
|
|
posVelFusionDelayed = false; |
|
|
|
|
optFlowFusionDelayed = false; |
|
|
|
|
flowFusionActive = false; |
|
|
|
@ -760,6 +759,24 @@ void NavEKF3_core::calcOutputStates()
@@ -760,6 +759,24 @@ void NavEKF3_core::calcOutputStates()
|
|
|
|
|
// sum delta velocities to get velocity
|
|
|
|
|
outputDataNew.velocity += delVelNav; |
|
|
|
|
|
|
|
|
|
// Implement third order complementary filter for height and height rate
|
|
|
|
|
// Reference Paper :
|
|
|
|
|
// Optimizing the Gains of the Baro-Inertial Vertical Channel
|
|
|
|
|
// Widnall W.S, Sinha P.K,
|
|
|
|
|
// AIAA Journal of Guidance and Control, 78-1307R
|
|
|
|
|
|
|
|
|
|
// Perform filter calculation using backwards Euler integration
|
|
|
|
|
// Coefficients selected to place all three filter poles at omega
|
|
|
|
|
const float CompFiltOmega = M_2PI * constrain_float(frontend->_hrt_filt_freq, 0.1f, 100.0f); |
|
|
|
|
float omega2 = CompFiltOmega * CompFiltOmega; |
|
|
|
|
float pos_err = outputDataNew.position.z - vertCompFiltState.pos; |
|
|
|
|
float integ1_input = pos_err * omega2 * CompFiltOmega * imuDataNew.delVelDT; |
|
|
|
|
vertCompFiltState.acc += integ1_input; |
|
|
|
|
float integ2_input = delVelNav.z + (vertCompFiltState.acc + pos_err * omega2 * 3.0f) * imuDataNew.delVelDT; |
|
|
|
|
vertCompFiltState.vel += integ2_input; |
|
|
|
|
float integ3_input = (vertCompFiltState.vel + pos_err * CompFiltOmega * 3.0f) * imuDataNew.delVelDT; |
|
|
|
|
vertCompFiltState.pos += integ3_input;
|
|
|
|
|
|
|
|
|
|
// apply a trapezoidal integration to velocities to calculate position
|
|
|
|
|
outputDataNew.position += (outputDataNew.velocity + lastVelocity) * (imuDataNew.delVelDT*0.5f); |
|
|
|
|
|
|
|
|
@ -1409,8 +1426,8 @@ void NavEKF3_core::StoreOutputReset()
@@ -1409,8 +1426,8 @@ void NavEKF3_core::StoreOutputReset()
|
|
|
|
|
} |
|
|
|
|
outputDataDelayed = outputDataNew; |
|
|
|
|
// reset the states for the complementary filter used to provide a vertical position derivative output
|
|
|
|
|
posDown = stateStruct.position.z; |
|
|
|
|
posDownDerivative = stateStruct.velocity.z; |
|
|
|
|
vertCompFiltState.pos = stateStruct.position.z; |
|
|
|
|
vertCompFiltState.vel = stateStruct.velocity.z; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Reset the stored output quaternion history to current EKF state
|
|
|
|
|