According the documentation:
EK2_ALT_SOURCE
This parameter controls which height sensor is used by the EKF. If the selected optionn cannot be used, it will default to Baro as the primary height source. Setting 0 will use the baro altitude at all times. Setting 1 uses the range finder and is only available in combination with optical flow navigation (EK2_GPS_TYPE = 3). Setting 2 uses GPS. When height sources other than Baro are in use, the offset between the Baro height and EKF height estimate is continually updated. If a switch to Baro height needs to be made when the filter is operating, then the Baro height is corrected for the learned offset to prevent a sudden step in height estimate.
If setting EK2_ALT_SOURCE to zero is using the Baro altitude, why is the helicopter not at the correct altitude when the Baro obviously shows it’s not at the correct altitude? Taking a snapshot of this one waypoint the command altitude value (flight plan) was 7.62 meters, which is 25 feet. The helicopter was actually at 1.5 meters, or 5 feet (my visual estimation was 1 meter, or about 3 feet).
Further, since the command altitude was 7.62 meters, why is the CTUN.DAlt only 1.58 meters? How can you have a desired relative altitude of 1.58 meters at that point and space in time when the flight plan is plainly 7.62 meters? Doesn’t make sense. Isn’t the flight plan command altitude the desired altitude?
Tracing the GPS altitude estimate from the beginning of the flight to the end, the GPS estimate (height above the reference ellipsoid) agrees with the flight plan. None of the rest does except right at the beginning of the flight, and it went downhill from there (pardun the pun). So my conclusion is that it used GPS altitude for the entire flight and totally ignored the barometer. In other words, what the documentation says it’s supposed to do vs what it actually does in the real world is two different things. All the EKF2 settings are default:
EK2_ABIAS_P_NSE , 0.005
EK2_ACC_P_NSE , 0.6
EK2_ALT_M_NSE , 3
EK2_ALT_SOURCE , 0
EK2_BCN_DELAY , 50
EK2_BCN_I_GTE , 500
EK2_BCN_M_NSE , 1
EK2_CHECK_SCALE , 100
EK2_EAS_I_GATE , 400
EK2_EAS_M_NSE , 1.4
EK2_ENABLE , 1
EK2_FLOW_DELAY , 10
EK2_FLOW_I_GATE , 300
EK2_FLOW_M_NSE , 0.25
EK2_GBIAS_P_NSE , 0.0001
EK2_GLITCH_RAD , 25
EK2_GPS_CHECK , 31
EK2_GPS_DELAY , 220
EK2_GPS_TYPE , 0
EK2_GSCL_P_NSE , 0.0005
EK2_GYRO_P_NSE , 0.03
EK2_HGT_DELAY , 60
EK2_HGT_I_GATE , 500
EK2_IMU_MASK , 3
EK2_LOG_MASK , 1
EK2_MAGB_P_NSE , 0.0001
EK2_MAGE_P_NSE , 0.001
EK2_MAG_CAL , 3
EK2_MAG_I_GATE , 300
EK2_MAG_MASK , 0
EK2_MAG_M_NSE , 0.05
EK2_MAX_FLOW , 2.5
EK2_NOAID_M_NSE , 10
EK2_POSNE_M_NSE , 1
EK2_POS_I_GATE , 500
EK2_RNG_I_GATE , 500
EK2_RNG_M_NSE , 0.5
EK2_RNG_USE_HGT , -1
EK2_RNG_USE_SPD , 2
EK2_TAU_OUTPUT , 25
EK2_TERR_GRAD , 0.1
EK2_VELD_M_NSE , 0.7
EK2_VELNE_M_NSE , 0.5
EK2_VEL_I_GATE , 500
EK2_WIND_PSCALE , 0.5
EK2_WIND_P_NSE , 0.1
EK2_YAW_I_GATE , 300
EK2_YAW_M_NSE , 0.5
The maths that make this system tick are way over my head. But at the minimum I’m going to say whatever it’s trying to do has a serious anomaly.