|
|
@ -412,10 +412,6 @@ void NavEKF2_core::UpdateFilter(bool predict) |
|
|
|
// Set the flag to indicate to the filter that the front-end has given permission for a new state prediction cycle to be started
|
|
|
|
// Set the flag to indicate to the filter that the front-end has given permission for a new state prediction cycle to be started
|
|
|
|
startPredictEnabled = predict; |
|
|
|
startPredictEnabled = predict; |
|
|
|
|
|
|
|
|
|
|
|
// zero the delta quaternion used by the strapdown navigation because it is published
|
|
|
|
|
|
|
|
// and we need to return a zero rotation of the INS fails to update it
|
|
|
|
|
|
|
|
correctedDelAngQuat.initialise(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// don't run filter updates if states have not been initialised
|
|
|
|
// don't run filter updates if states have not been initialised
|
|
|
|
if (!statesInitialised) { |
|
|
|
if (!statesInitialised) { |
|
|
|
return; |
|
|
|
return; |
|
|
@ -481,29 +477,35 @@ void NavEKF2_core::UpdateFilter(bool predict) |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
void NavEKF2_core::UpdateStrapdownEquationsNED() |
|
|
|
void NavEKF2_core::UpdateStrapdownEquationsNED() |
|
|
|
{ |
|
|
|
{ |
|
|
|
// apply correction for earths rotation rate
|
|
|
|
// remove gyro scale factor errors
|
|
|
|
// % * - and + operators have been overloaded
|
|
|
|
imuDataDelayed.delAng.x = imuDataDelayed.delAng.x * stateStruct.gyro_scale.x; |
|
|
|
correctedDelAng = imuDataDelayed.delAng - prevTnb * earthRateNED*imuDataDelayed.delAngDT; |
|
|
|
imuDataDelayed.delAng.y = imuDataDelayed.delAng.y * stateStruct.gyro_scale.y; |
|
|
|
|
|
|
|
imuDataDelayed.delAng.z = imuDataDelayed.delAng.z * stateStruct.gyro_scale.z; |
|
|
|
|
|
|
|
|
|
|
|
// convert the rotation vector to its equivalent quaternion
|
|
|
|
// remove sensor bias errors
|
|
|
|
correctedDelAngQuat.from_axis_angle(correctedDelAng); |
|
|
|
imuDataDelayed.delAng -= stateStruct.gyro_bias * (imuDataDelayed.delAngDT / dtEkfAvg); |
|
|
|
|
|
|
|
imuDataDelayed.delVel.z -= stateStruct.accel_zbias * (imuDataDelayed.delVelDT / dtEkfAvg); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// apply correction for earth's rotation rate
|
|
|
|
|
|
|
|
// % * - and + operators have been overloaded
|
|
|
|
|
|
|
|
imuDataDelayed.delAng -= prevTnb * earthRateNED*imuDataDelayed.delAngDT; |
|
|
|
|
|
|
|
|
|
|
|
// update the quaternion states by rotating from the previous attitude through
|
|
|
|
// update the quaternion states by rotating from the previous attitude through
|
|
|
|
// the delta angle rotation quaternion and normalise
|
|
|
|
// the delta angle rotation quaternion and normalise
|
|
|
|
stateStruct.quat *= correctedDelAngQuat; |
|
|
|
stateStruct.quat.rotate(imuDataDelayed.delAng); |
|
|
|
stateStruct.quat.normalize(); |
|
|
|
stateStruct.quat.normalize(); |
|
|
|
|
|
|
|
|
|
|
|
// calculate the body to nav cosine matrix
|
|
|
|
|
|
|
|
Matrix3f Tbn_temp; |
|
|
|
|
|
|
|
stateStruct.quat.rotation_matrix(Tbn_temp); |
|
|
|
|
|
|
|
prevTnb = Tbn_temp.transposed(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// transform body delta velocities to delta velocities in the nav frame
|
|
|
|
// transform body delta velocities to delta velocities in the nav frame
|
|
|
|
|
|
|
|
// use the nav frame from previous time step as the delta velocities
|
|
|
|
|
|
|
|
// have been rotated into that frame
|
|
|
|
// * and + operators have been overloaded
|
|
|
|
// * and + operators have been overloaded
|
|
|
|
Vector3f delVelNav; // delta velocity vector in earth axes
|
|
|
|
Vector3f delVelNav; // delta velocity vector in earth axes
|
|
|
|
delVelNav = Tbn_temp*imuDataDelayed.delVel; |
|
|
|
delVelNav = prevTnb.mul_transpose(imuDataDelayed.delVel); |
|
|
|
delVelNav.z += GRAVITY_MSS*imuDataDelayed.delVelDT; |
|
|
|
delVelNav.z += GRAVITY_MSS*imuDataDelayed.delVelDT; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// calculate the body to nav cosine matrix
|
|
|
|
|
|
|
|
stateStruct.quat.inverse().rotation_matrix(prevTnb); |
|
|
|
|
|
|
|
|
|
|
|
// calculate the rate of change of velocity (used for launch detect and other functions)
|
|
|
|
// calculate the rate of change of velocity (used for launch detect and other functions)
|
|
|
|
velDotNED = delVelNav / imuDataDelayed.delVelDT; |
|
|
|
velDotNED = delVelNav / imuDataDelayed.delVelDT; |
|
|
|
|
|
|
|
|
|
|
|