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 Nov 29, 2023
1 parent 0d932e8 commit e625608
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions libraries/AP_NavEKF3/AP_NavEKF3_Measurements.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,26 @@ void NavEKF3_core::readGpsData()
// check for new GPS data
const auto &gps = dal.gps();

Vector3f magNED;
getMagNED(magNED);
if (gps.status() == AP_DAL_GPS::NO_GPS && validOrigin) {
printf("No GPS but valid origin\n");
// print origin
printf("Origin: %d %d %d\n", EKF_origin.lat, EKF_origin.lng, EKF_origin.alt);
// if there is not gps, we should still align if we have a valid origin
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;
}
}
return;
}

// limit update rate to avoid overflowing the FIFO buffer
if (gps.last_message_time_ms(selected_gps) - lastTimeGpsReceived_ms <= frontend->sensorIntervalMin_ms) {
return;
Expand Down

0 comments on commit e625608

Please sign in to comment.