Skip to content

Commit

Permalink
EKF3: allow earth-frame fields to be estimated with an origin but no GPS
Browse files Browse the repository at this point in the history
  • Loading branch information
Williangalvani committed Dec 7, 2023
1 parent 4ede307 commit 449406e
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions libraries/AP_NavEKF3/AP_NavEKF3_Control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,20 @@ bool NavEKF3_core::setOrigin(const Location &loc)
validOrigin = true;
GCS_SEND_TEXT(MAV_SEVERITY_INFO, "EKF3 IMU%u origin set",(unsigned)imu_index);

Vector3f magNED;
getMagNED(magNED);

alignMagStateDeclination();
const auto &compass = dal.compass();
if (compass.have_scale_factor(magSelectIndex) &&
compass.auto_declination_enabled()) {
getEarthFieldTable(EKF_origin);
if (frontend->_mag_ef_limit > 0) {
// initialise earth field from tables
stateStruct.earth_magfield = table_earth_field_ga;
}
}

if (!frontend->common_origin_valid) {
frontend->common_origin_valid = true;
// put origin in frontend as well to ensure it stays in sync between lanes
Expand Down

0 comments on commit 449406e

Please sign in to comment.