Relative alt in HIL


in QGC there is a QGCXplaneLink class. There in readBytes() method is such code snippet:

else if (p.index == 20)
//qDebug() << “LAT/LON/ALT:” << p.f[0] << p.f[1] << p.f[2];
lat = p.f[0];
lon = p.f[1];
alt = p.f[2] * 0.3048f; // convert feet (MSL) to meters
alt_agl = p.f[3] * 0.3048f; //convert feet (AGL) to meters

alt is altitude above sea level, alt_agl is altitude above ground. Altitude above sea level is used further in signal:

emit sensorHilGpsChanged(QGC::groundTimeUsecs(), lat, lon, alt, gps_fix_type, eph, epv, vel, vx, vy, vz, cog, satellites);

but alt_agl isn’t used and isn’t being sent to px. But px send relative_alt in GLOBAL_POSITION_INT message. So how px4 determine altitude above ground?

Relative to the HOME position, which is initialized the first time the vehicle gets a GPS fix, and updates whenever it goes from landed -> flying.