TwinFan / XPMP2

Multiplayer library for X-Plane 11/12 with instancing, TCAS override, and sound
https://twinfan.github.io/XPMP2/
Other
24 stars 16 forks source link

Support XP12 Wake dataRefs #41

Closed TwinFan closed 2 years ago

TwinFan commented 2 years ago

Current Situation / Problem

Up to XP11, planes driven by TCAS dataRefs did not produce wake turbulences. With XP12, a solution is provided: https://developer.x-plane.com/article/plugin-traffic-wake-turbulence/

Suggested Solution

Wake dataRefs

Support the newly provided sim/cockpit2/tcas/targets/wake dataRefs. A few new attributes in the XPMP2::Aircraft will be required and linked to those dataRefs.

sim/cockpit2/tcas/targets/wake/wing_span_m  float[64]   y   meter   wing span of the aircraft creating wake turbulence
sim/cockpit2/tcas/targets/wake/wing_area_m2 float[64]   y   meter   wing area (total area of both wings combined) of the aircraft creating wake turbulence
sim/cockpit2/tcas/targets/wake/wake_cat int[64] y   enum    wake category of the aircraft. This is for information purposes only and is not used to calculate the actual strength of the turbulence. 0 = Light, 1 = Medium, 2 = Heavy, 3 = Super
sim/cockpit2/tcas/targets/wake/mass_kg  float[64]   y   kg  actual mass of the aircraft creating the wake
sim/cockpit2/tcas/targets/wake/aoa  float[64]   y   degrees angle of attack of the wing creating the wake
sim/cockpit2/tcas/targets/wake/lift_N   float[64]   y   Newton  instantaneous lift force of the whole wing generated right now, in Newtons

From this post by Philipp, after asking which dataRefs really require being written to:

All of them, for an accurate wake size and strength and lifetime duration estimate. That's why they are there! The wing area, span, t/o weight are public data for all aircraft types (maybe not all military ones), so you should be able to build a lookup table for ICAO type A320 to 123sqm of wing area and 34m of wing span. The weight you could use a certain percentage of MTOW, which would also be a lookup by type. Maybe you could change the weight based on the departure/destination airports if they are known, so that a long range flight weighs closer to maximum than a short range flight.

The lift force in Newtons is weight times 9.81 almost all of the time. You set it to 0 once the weight is carried by the wheels, so you don't leave a wake when taxiing on the ground so you don't blow people of the taxi way. During takeoff you can phase it in when approaching lift-off speed. During flight, lift force should equal weight times g, otherwise the plane wouldn't fly. If you wanted to be super accurate, you could calculate the acceleration vector along a trajectory of the aircraft of a few seconds to determine turning forces (i.e. calculate the g the pilot is pulling to achieve the turn radius given the speed). But for airplanes other than military or aerobatic I don't think the difference from 1g will ever be significant.

Defaults based on WTC

XPMP2 is aware of a plane's wake turbulence category (WTC) from Doc8643 data: L, L/M, M, H, and J. So the idea is to provide some default data per WTC value.

Alternatives

In case of no change, X-Plane will always apply a default assumed plane size matching a 10t business jet (see above developer article).

Benefits

Wake turbulences...so don't fly close to the generated traffic!

Additional context

There is a long-standing issue TwinFan/LiveTraffic#59.