AP_NavEKF3: handle external nav position reset

This commit is contained in:
Randy Mackay 2020-04-16 20:15:29 +09:00
parent cbb25311bb
commit f79d5d2d2c
2 changed files with 71 additions and 1 deletions

View File

@ -153,6 +153,64 @@ void NavEKF3_core::ResetPosition(void)
}
// reset the stateStruct's NE position to the specified position
// posResetNE is updated to hold the change in position
// storedOutput, outputDataNew and outputDataDelayed are updated with the change in position
// lastPosReset_ms is updated with the time of the reset
void NavEKF3_core::ResetPositionNE(float posN, float posE)
{
// Store the position before the reset so that we can record the reset delta
const Vector3f posOrig = stateStruct.position;
// Set the position states to the new position
stateStruct.position.x = posN;
stateStruct.position.y = posE;
// Calculate the position offset due to the reset
posResetNE.x = stateStruct.position.x - posOrig.x;
posResetNE.y = stateStruct.position.y - posOrig.y;
// Add the offset to the output observer states
for (uint8_t i=0; i<imu_buffer_length; i++) {
storedOutput[i].position.x += posResetNE.x;
storedOutput[i].position.y += posResetNE.y;
}
outputDataNew.position.x += posResetNE.x;
outputDataNew.position.y += posResetNE.y;
outputDataDelayed.position.x += posResetNE.x;
outputDataDelayed.position.y += posResetNE.y;
// store the time of the reset
lastPosReset_ms = imuSampleTime_ms;
}
// reset the stateStruct's D position
// posResetD is updated to hold the change in position
// storedOutput, outputDataNew and outputDataDelayed are updated with the change in position
// lastPosResetD_ms is updated with the time of the reset
void NavEKF3_core::ResetPositionD(float posD)
{
// Store the position before the reset so that we can record the reset delta
const float posDOrig = stateStruct.position.z;
// write to the state vector
stateStruct.position.z = posD;
// Calculate the position jump due to the reset
posResetD = stateStruct.position.z - posDOrig;
// Add the offset to the output observer states
outputDataNew.position.z += posResetD;
vertCompFiltState.pos = outputDataNew.position.z;
outputDataDelayed.position.z += posResetD;
for (uint8_t i=0; i<imu_buffer_length; i++) {
storedOutput[i].position.z += posResetD;
}
// store the time of the reset
lastPosResetD_ms = imuSampleTime_ms;
}
// reset the vertical position state using the last height measurement
void NavEKF3_core::ResetHeight(void)
{
@ -426,7 +484,13 @@ void NavEKF3_core::SelectVelPosFusion()
}
}
// To-Do: add external nav position reset handling here?
// check for external nav position reset
if (extNavDataToFuse && (PV_AidingMode == AID_ABSOLUTE) && (frontend->_fusionModeGPS == 3) && extNavDataDelayed.posReset) {
ResetPositionNE(extNavDataDelayed.pos.x, extNavDataDelayed.pos.y);
if (activeHgtSource == HGT_SOURCE_EXTNAV) {
ResetPositionD(-hgtMea);
}
}
// If we are operating without any aiding, fuse in the last known position
// to constrain tilt drift. This assumes a non-manoeuvring vehicle

View File

@ -771,6 +771,12 @@ private:
// reset the horizontal position states uing the last GPS measurement
void ResetPosition(void);
// reset the stateStruct's NE position to the specified position
void ResetPositionNE(float posN, float posE);
// reset the stateStruct's D position
void ResetPositionD(float posD);
// reset velocity states using the last GPS measurement
void ResetVelocity(void);