diff --git a/sw/airborne/modules/ins/ins_ekf2.cpp b/sw/airborne/modules/ins/ins_ekf2.cpp index 436f488446..2e0d92231b 100644 --- a/sw/airborne/modules/ins/ins_ekf2.cpp +++ b/sw/airborne/modules/ins/ins_ekf2.cpp @@ -522,13 +522,13 @@ void ins_ekf2_init(void) /* Initialize the origin from flight plan */ #if USE_INS_NAV_INIT - if(ekf.setEkfGlobalOrigin(NAV_LAT0*1e-7, NAV_LON0*1e-7, (NAV_ALT0 + NAV_MSL0)*1e-3)) + if(ekf.setEkfGlobalOrigin(NAV_LAT0*1e-7, NAV_LON0*1e-7, (NAV_ALT0)*1e-3)) // EKF2 works HMSL { struct LlaCoor_i llh_nav0; /* Height above the ellipsoid */ llh_nav0.lat = NAV_LAT0; llh_nav0.lon = NAV_LON0; /* NAV_ALT0 = ground alt above msl, NAV_MSL0 = geoid-height (msl) over ellipsoid */ - llh_nav0.alt = NAV_ALT0 + NAV_MSL0; + llh_nav0.alt = NAV_ALT0 + NAV_MSL0; // in millimeters above WGS84 reference ellipsoid ltp_def_from_lla_i(&ekf2.ltp_def, &llh_nav0); ekf2.ltp_def.hmsl = NAV_ALT0; @@ -621,7 +621,7 @@ void ins_ekf2_update(void) if (ekf_origin_valid && (origin_time > ekf2.ltp_stamp)) { lla_ref.lat = ekf_origin_lat * 1e7; // WGS-84 lat lla_ref.lon = ekf_origin_lon * 1e7; // WGS-84 lon - lla_ref.alt = ref_alt * 1e3 + wgs84_ellipsoid_to_geoid_i(lla_ref.lat, lla_ref.lon); // WGS-84 height + lla_ref.alt = ref_alt * 1e3 + wgs84_ellipsoid_to_geoid_i(lla_ref.lat, lla_ref.lon); // in millimeters above WGS84 reference ellipsoid (ref_alt is in HMSL) ltp_def_from_lla_i(&ekf2.ltp_def, &lla_ref); ekf2.ltp_def.hmsl = ref_alt * 1e3; stateSetLocalOrigin_i(&ekf2.ltp_def); @@ -854,7 +854,7 @@ static void gps_cb(uint8_t sender_id __attribute__((unused)), struct LlaCoor_i lla_pos = lla_int_from_gps(gps_s); gps_msg.lat = lla_pos.lat; gps_msg.lon = lla_pos.lon; - gps_msg.alt = lla_pos.alt; + gps_msg.alt = gps_s->hmsl; // EKF2 works with HMSL #if INS_EKF2_GPS_COURSE_YAW gps_msg.yaw = wrap_pi((float)gps_s->course / 1e7); gps_msg.yaw_offset = 0;