pilotclient icon indicating copy to clipboard operation
pilotclient copied to clipboard

Adjust true altitude to compensate for MSFS/XP12 realistic altimetry model

Open oktal3700 opened this issue 2 years ago • 5 comments

MSFS 2020 has an altimetry model that is more accurate/realistic than that of other sims, in that it simulates the effect of temperature on the pressure lapse rate in the atmosphere. Because of this, the indicated altitude that the pilot sees may be different from the true altitude of the aircraft. Since ATC clients show the reported true altitude in the data block when the aircraft is below the transition level, and since pilot clients render other aircraft at their reported true altitude, this creates an obvious problem. The more the temperature differs from a standard atmosphere, the greater the error.

And when X-Plane 12 is released, it will include a similar feature.

See the proposed solution by Ross.

oktal3700 avatar Jun 29 '22 17:06 oktal3700

The importance of this issue continues to grow as X-Plane 12 is now available to buy in early access.

oktal3700 avatar Sep 11 '22 17:09 oktal3700

Description from Ross of what vPilot is doing:

MSFS has a new simvar called INDICATED ALTITUDE CALIBRATED which is essentially "what the indicated altitude would be if the pilot set the kohlsman window setting to local sea level pressure" ... so it's a perfect value to use for sending the true altitude to the network

so what I'm doing is reading that value and sending it as the true altitude value in the @ packet, and I'm also using it to "correct" altitudes received from other pilots ... I get the difference between that value and the true altitude (PLANE ALTITUDE simvar) and apply that offset to incoming altitudes

I only apply that offset if the other aircraft is within 3000 feet of the user's aircraft, and I interpolate that offset down to zero if the other aircraft is between 3000 and 6000 feet of the user's aircraft, vertically

private double AdjustIncomingAltitude(double altitude)
{
    if (mActiveSimulatorType != ModelMatching.SimulatorType.Msfs) {
        return altitude;
    }

    double verticalDistance = Maths.Abs(mCurrentUserAircraftData.CalibratedIndicatedAltitude - altitude);
    if (verticalDistance > 6000.0) {
        return altitude;
    }

    double weight = 1.0;
    if (verticalDistance > 3000.0) {
        weight = 1.0 - ((verticalDistance - 3000.0) / 3000.0);
    }

    double offset = mCurrentUserAircraftData.CalibratedIndicatedAltitude - mCurrentUserAircraftData.TrueAltitude;
    return altitude - (offset * weight);
}

oktal3700 avatar Sep 13 '22 18:09 oktal3700

There is a new dataref in XP12 sim/flightmodel2/position/pressure_altitude to expose the pressure altitude including temperature calculation.

Remember though, we still need to support XP11.

oktal3700 avatar Oct 02 '22 18:10 oktal3700

Conceptual solution:

  • X-Plane 11

    • As before, true altitude provided by simulator
    • Pressure altitude calculated from true + QNH
  • X-Plane 12

    • Pressure altitude (1) provided by new dataref
    • True altitude provided by old dataref (note this includes the temperature effect, because the pilot is maintaining a pressure altitude that includes the temperature effect)
    • Pressure altitude (2) calculated from true + QNH (calculation assumes no temperature effect)
    • Pressure altitude (2) minus pressure altitude (1) = delta (altitude increase due to temperature)
      • Use QNH to convert delta from pressure to true altitude
      • own aircraft true altitude -= true delta
      • remote aircraft true altitude += true delta
  • FSX/P3D

    • As before, simulator provides simvars for both true and pressure altitude
  • MSFS

    • True altitude (1) provided by same simvar as before
    • New simvar provides true altitude (2) minus temperature effect
    • True altitude (1) minus true altitude (2) = delta (altitude increase due to temperature)
      • own aircraft true altitude = true altitude (2)
      • remote aircraft true altitude += true delta

oktal3700 avatar Oct 05 '22 18:10 oktal3700

Thank you for working on it. I can't comment on the changes needed in Swift. These were the changes in xPiIot so they got away with just using the new DataRef sim/flightmodel2/position/pressure_altitude.

jonaseberle avatar Oct 09 '22 11:10 jonaseberle