Skip to content

Commit

Permalink
AP_NavEKF3: pos vel resets default to user defined source
Browse files Browse the repository at this point in the history
  • Loading branch information
rmackay9 committed Nov 21, 2024
1 parent 5647141 commit 0a8de23
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
40 changes: 40 additions & 0 deletions libraries/AP_NavEKF3/AP_NavEKF3_PosVelFusion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,26 @@
// Do not reset vertical velocity using GPS as there is baro alt available to constrain drift
void NavEKF3_core::ResetVelocity(resetDataSource velResetSource)
{
// if reset source is not specified then use user defined velocity source
if (velResetSource == resetDataSource::DEFAULT) {
switch (frontend->sources.getVelXYSource()) {
case AP_NavEKF_Source::SourceXY::GPS:
velResetSource = resetDataSource::GPS;
break;
case AP_NavEKF_Source::SourceXY::BEACON:
velResetSource = resetDataSource::RNGBCN;
break;
case AP_NavEKF_Source::SourceXY::EXTNAV:
velResetSource = resetDataSource::EXTNAV;
break;
case AP_NavEKF_Source::SourceXY::NONE:
case AP_NavEKF_Source::SourceXY::OPTFLOW:
case AP_NavEKF_Source::SourceXY::WHEEL_ENCODER:
// unhandled sources so stick with the default
break;
}
}

// Store the velocity before the reset so that we can record the reset delta
velResetNE.x = stateStruct.velocity.x;
velResetNE.y = stateStruct.velocity.y;
Expand Down Expand Up @@ -73,6 +93,26 @@ void NavEKF3_core::ResetVelocity(resetDataSource velResetSource)
// resets position states to last GPS measurement or to zero if in constant position mode
void NavEKF3_core::ResetPosition(resetDataSource posResetSource)
{
// if reset source is not specified thenn use the user defined position source
if (posResetSource == resetDataSource::DEFAULT) {
switch (frontend->sources.getPosXYSource()) {
case AP_NavEKF_Source::SourceXY::GPS:
posResetSource = resetDataSource::GPS;
break;
case AP_NavEKF_Source::SourceXY::BEACON:
posResetSource = resetDataSource::RNGBCN;
break;
case AP_NavEKF_Source::SourceXY::EXTNAV:
posResetSource = resetDataSource::EXTNAV;
break;
case AP_NavEKF_Source::SourceXY::NONE:
case AP_NavEKF_Source::SourceXY::OPTFLOW:
case AP_NavEKF_Source::SourceXY::WHEEL_ENCODER:
// invalid sources so stick with the default
break;
}
}

// Store the position before the reset so that we can record the reset delta
posResetNE.x = stateStruct.position.x;
posResetNE.y = stateStruct.position.y;
Expand Down
3 changes: 3 additions & 0 deletions libraries/AP_NavEKF3/AP_NavEKF3_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -838,6 +838,9 @@ class NavEKF3_core : public NavEKF_core_common
// zero stored variables related to mag
void InitialiseVariablesMag();

// get ResetDataSource using current position or velocity XY source
resetDataSource getResetDataSource(AP_NavEKF_Source::SourceXY source);

// reset the horizontal position states uing the last GPS measurement
void ResetPosition(resetDataSource posResetSource);

Expand Down

0 comments on commit 0a8de23

Please sign in to comment.