overhauled flight model

Eggheads talking about bytes and stuff.
Post Reply
User avatar
Krishty
Site Admin
Posts: 1271
Joined: 2022-Jan-09, 00:59

overhauled flight model

Post by Krishty »

I’ve pushed the overhauled F-22 flight model to the repo.

There are just a few functional changes:

New Pitching Behavior

The plane doesn’t pitch as abruptly as before. It seems to me like this was a bug in ADF/TAW: the proportional gain for handling pitch demand was set ~20× too high. It moves a lot smoother now.

Notice that there were two additional mechanisms in place for making pitch less abrupt: First, key input was smoothed out to give a nice slope over time when pressing a key. Then, the FCS has internal limiters to prevent sudden demand changes and smooth roll/pitch/yaw demand over time. These are now probably useless, but I’ll conduct more testing before I disable them. (If I get this wrong, the plane will explode during high-speed turns.)

Small Bugfixes

Several coefficients were computed incorrectly. This included typos (confused axes or variables); off-by-one errors in lookup tables; confusing wings for elevators. The effects are very minor.

A nice example: A term was written out as 1/8 * cos(phi). In C/C++, all constants are integer by default. Dividing the integer 1 by the integer 8 yields zero, thus the expression always resulted in zero. It was clearly meant to be 1./8. * cos(phi), i.e. the constants being floating-point numbers.

Testing Workarounds

There are at least two workarounds in the flight model: Resistance to AoA and resistance to sideslip.

The flight model uses a somewhat scientifically accurate formula to derive the air resistance of rudders from their geometric description. But then it just throws it all away and replaces it with the constant -2. before using it to compensate for sideslip.

Luckily, their compiler didn’t optimize away the original function, so I re-enabled it. I found, however, that it hardly works. The plane yaws left/right just fine, but it keeps flying straight no matter what. The flight path just doesn’t change. So they hard-coded the -2, which makes the rudder response way to hard at low speeds, but at least it makes the rudders usable at all.

There is a similar situation for the AoA compensation. When I re-enabled the scientifically correct formula, the F-22 reached much higher AoA during curves, but had a tendency to stall. It did feel much more realistic, but much less fun.

I kept the workarounds but I also left the original functions in the code for later re-evaluation.


… but there are more important changes under the hood:

Full Refactoring

The flight model code has been 100% refactored. Almost everything has been renamed or commented. It is finally somewhat maintainable.

Autopilot Preparations

I’ve prepared an autopilot. It’s not yet usable because it lacks infrastructure: There is no GUI to configure it. There is no mission system to provide waypoints. There is no airport system to provide correct waypoints for taxiing on ground. There is no radio system to coordinate air refueling. There is no terrain-following radar to provide elevation data along the path.

With a few hard-coded waypoints, however, I can make the F-22 autopilot
  1. get the plane rolling from a parked position;
  2. follow the road to the runway;
  3. take off;
  4. reach a specific altitude and/or heading;
  5. target a specific waypoint at a specific speed and altitude;
  6. perform negative G rolls to descent to waypoints at lower altitude.
All of this works surprisingly well, and I’ll test air refueling / formation flight / landing soon. Maybe the autorecovery mode will make it into the next check-in 🙂

Other Flight Models

The flight model has been modified to support other planes in the future, just like ADF/TAW’s does. The ejection seat would be a first candidate, though I’m not yet so far.
mikew
Data Genius
Posts: 558
Joined: 2022-Jan-09, 20:21

Re: overhauled flight model

Post by mikew »

Cool! Maybe you could read the mission files (.mdl ?) and maybe start the sim at the first 'in the air' waypoint. We could then compare TAW's and TFXplorer's autopilot behaviour in parallel.
I think I'd find that amusing at least. :)
User avatar
Krishty
Site Admin
Posts: 1271
Joined: 2022-Jan-09, 00:59

Re: overhauled flight model

Post by Krishty »

Yes, we absolutely could, but there is a more urgent problem with waypoints:

What you see in the missions are “logical” waypoints. E.g.
  • waypoint 1 is takeoff;
  • waypoint 2 is CAP;
  • waypoint 3 is land.
But the autopilot uses a more sophisticated waypoint system internally:
  • waypoint 1 is from your parking position to the first accessible road;
  • waypoint 2 is from that road to the first curve you have to take;
  • waypoint 3 is where you enter the road to the runway (you may stop here and wait for other planes to pass);
  • waypoint 4 is before you enter the runway;
  • waypoint 5 is where you enter the runway (and possibly HOLD);
  • waypoint 6 is where you wait for departure;
  • waypoint 7 is in the air at the end of the runway (so the plane takes off);
  • … AI planes taking off and ascending in ovals until they reach their target altitude indicate that there are even more waypoints in the air before the autopilot targets the first logical waypoint.
I’m very interested in finding out how TAW computes that. I’d suppose that the road graph for airfields is either hard-coded per airfield type or written into the SSD file.

The reason I’m interested is: That’s very very closely related to how AI seems to work. AI does not use the autopilot nor the F-22 flight model (maybe except F-22 enemies, but you get it) and actual waypoints may be direct output of the high-level AI.
User avatar
Krishty
Site Admin
Posts: 1271
Joined: 2022-Jan-09, 00:59

Re: overhauled flight model

Post by Krishty »

Reading MDL files would be a huge step towards a usable GUI, though. We could display actual TAW missions with actual briefings … ❤️
mikew
Data Genius
Posts: 558
Joined: 2022-Jan-09, 20:21

Re: overhauled flight model

Post by mikew »

The file 'airbase.txt' looks like it describes the nodes for the 15 or so different airbases, but I think some of it is overridden by hardcoded values.
One think I never worked out was that if I replace the Learjets in the takeoff missions with F-14s, they will spawn in the military part of the airfield by the F-22 rather than where the Learjets normally spawn. I don't see anything in 'airbase.txt' that differentiates military and civilian parking areas.
Here''s the entry for Luxor-type airbases:

Code: Select all

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

AIRBASE_TYPE LUXOR_AIRBASE

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

NUM_AIRBASE_NODES 105

; Descriptor,type,size,rotation,x-ofset,z_offset,number_of_connections,id,id,...

AIRBASE_NODE RUNEND 0 0 -214 -457 4 1 26 27 25 
AIRBASE_NODE TAXI 0 0 -222 -480 5 25 2 26 27 0 
AIRBASE_NODE TAXI 0 0 -277 -461 2 65 1 
AIRBASE_NODE TAXI 0 0 -124 -40 4 73 45 24 64 
AIRBASE_NODE TAXI 0 0 -269 55 3 45 11 36 
AIRBASE_NODE TAXI 0 0 -131 263 3 56 79 61 
AIRBASE_NODE TAXI 0 0 -21 372 4 7 59 60 80 
AIRBASE_NODE TAXI 0 0 21 356 6 98 99 81 96 74 6 
AIRBASE_NODE TAXI 0 0 97 568 4 62 104 101 9 
AIRBASE_NODE TAXI 0 0 152 548 2 10 8 
AIRBASE_NODE RUNEND 0 0 144 525 1 9 
AIRBASE_NODE TAXI 0 0 -276 -40 3 13 12 4 
AIRBASE_NODE TAXI 0 0 -258 -48 3 13 22 11 
AIRBASE_NODE TAXI 0 0 -268 -60 7 70 20 18 21 19 12 11 
AIRBASE_NODE HANG 1 53368 -265 -111 1 70 
AIRBASE_NODE HANG 1 20126 -295 -96 1 70 
AIRBASE_NODE HANG 1 53988 -259 -100 1 70 
AIRBASE_NODE HANG 1 20197 -291 -85 1 70 
AIRBASE_NODE HANG 1 53988 -255 -90 1 13 
AIRBASE_NODE HANG 1 20339 -287 -73 1 13 
AIRBASE_NODE HANG 1 53505 -250 -78 1 13 
AIRBASE_NODE HANG 1 20197 -283 -62 1 13 
AIRBASE_NODE HANG 1 52894 -246 -67 1 12 
AIRBASE_NODE TAXI 0 0 -178 -184 3 58 24 66 
AIRBASE_NODE TAXI 0 0 -164 -147 3 57 23 3 
AIRBASE_NODE TAXI 0 0 -156 -493 4 30 26 1 0 
AIRBASE_NODE TAXI 0 0 -142 -466 5 29 27 25 1 0 
AIRBASE_NODE TAXI 0 0 -128 -442 4 28 26 1 0 
AIRBASE_NODE APRON 1 52894 -96 -454 1 27 
AIRBASE_NODE APRON 1 52496 -104 -480 1 26 
AIRBASE_NODE APRON 1 52496 -114 -506 1 25 
AIRBASE_NODE RUNWAY 0 0 13 166 2 76 63 
AIRBASE_NODE TAXI 0 0 277 -139 2 71 53 
AIRBASE_NODE TAXI 0 0 319 -166 2 71 55 
AIRBASE_NODE TAXI 0 0 299 -154 2 71 54 
AIRBASE_NODE TAXI 0 0 -215 128 5 94 37 44 48 38 
AIRBASE_NODE APRON 2 22844 -262 104 2 94 4 
AIRBASE_NODE APRON 2 21790 -252 122 2 94 35 
AIRBASE_NODE APRON 2 22018 -216 170 2 93 35 
AIRBASE_NODE APRON 2 22018 -204 190 2 93 56 
AIRBASE_NODE APRON 1 39480 -119 114 2 47 77 
AIRBASE_NODE APRON 1 39660 -129 122 2 47 77 
AIRBASE_NODE APRON 1 39228 -139 130 2 48 47 
AIRBASE_NODE APRON 1 39798 -151 139 2 48 47 
AIRBASE_NODE APRON 3 55612 -212 85 2 48 35 
AIRBASE_NODE TAXI 0 0 -179 -7 3 46 4 3 
AIRBASE_NODE TAXI 0 0 -132 66 5 49 50 77 47 45 
AIRBASE_NODE TAXI 0 0 -154 101 11 49 50 48 51 77 52 46 43 42 41 40 
AIRBASE_NODE TAXI 0 0 -188 116 8 93 52 51 47 44 43 42 35 
AIRBASE_NODE APRON 1 6892 -161 49 2 47 46 
AIRBASE_NODE APRON 1 6712 -171 57 2 47 46 
AIRBASE_NODE APRON 1 6712 -181 65 2 48 47 
AIRBASE_NODE APRON 1 6712 -191 73 2 48 47 
AIRBASE_NODE HANG 1 5634 267 -156 1 32 
AIRBASE_NODE HANG 1 6460 288 -171 1 34 
AIRBASE_NODE HANG 1 5634 307 -182 1 33 
AIRBASE_NODE TAXI 0 0 -161 221 4 93 78 39 5 
AIRBASE_NODE HANG 1 19728 -169 -144 1 24 
AIRBASE_NODE HANG 1 21220 -182 -180 1 23 
AIRBASE_NODE HANG 2 23882 -63 376 1 6 
AIRBASE_NODE HANG 2 23962 -82 354 2 80 6 
AIRBASE_NODE HANG 2 23622 -103 330 3 80 79 5 
AIRBASE_NODE TAXI 0 0 70 489 6 104 98 102 100 69 8 
AIRBASE_NODE TAXI 0 0 -34 198 5 83 97 73 79 31 
AIRBASE_NODE RUNWAY 0 0 -70 -60 1 3 
AIRBASE_NODE TAXI 0 0 -244 -376 3 68 66 2 
AIRBASE_NODE TAXI 0 0 -186 -218 3 67 65 23 
AIRBASE_NODE RUNWAY 0 0 -132 -236 1 66 
AIRBASE_NODE RUNWAY 0 0 -191 -393 1 65 
AIRBASE_NODE RUNWAY 0 0 124 470 1 62 
AIRBASE_NODE TAXI 0 0 -274 -88 5 17 16 15 14 13 
AIRBASE_NODE TAXI 0 0 298 -85 4 86 34 33 32 
AIRBASE_NODE RUNWAY 0 0 -4 119 2 73 91 
AIRBASE_NODE TAXI 0 0 -53 153 4 78 72 63 3 
AIRBASE_NODE RUNWAY 0 0 75 338 1 7 
AIRBASE_NODE TAXI 0 0 165 2 8 91 76 87 92 90 86 88 89 
AIRBASE_NODE TAXI 0 0 194 42 2 75 31 
AIRBASE_NODE TAXI 0 0 -119 89 5 78 47 46 41 40 
AIRBASE_NODE TAXI 0 0 -69 160 3 77 73 56 
AIRBASE_NODE TAXI 0 0 -79 228 4 80 63 61 5 
AIRBASE_NODE TAXI 0 0 -47 307 4 79 61 60 6 
AIRBASE_NODE APRON 4 20339 -7 354 2 96 7 
AIRBASE_NODE APRON 4 20600 -30 298 2 96 95 
AIRBASE_NODE APRON 4 21220 -54 234 2 97 63 
AIRBASE_NODE APRON 4 20600 -42 264 2 95 97 
AIRBASE_NODE APRON 4 20251 -19 327 1 96 
AIRBASE_NODE TAXI 0 0 230 -41 4 89 88 75 71 
AIRBASE_NODE APRON 4 6000 139 -42 1 75 
AIRBASE_NODE APRON 4 5467 172 -63 2 86 75 
AIRBASE_NODE APRON 4 5406 204 -81 2 86 75 
AIRBASE_NODE APRON 4 5870 80 1 2 91 75 
AIRBASE_NODE TAXI 0 0 107 43 4 92 90 75 72 
AIRBASE_NODE APRON 4 7178 110 -20 2 91 75 
AIRBASE_NODE TAXI 0 0 -195 170 4 56 48 39 38 
AIRBASE_NODE TAXI 0 0 -244 100 3 37 36 35 
AIRBASE_NODE TAXI 0 0 -6 278 4 97 96 84 82 
AIRBASE_NODE TAXI 0 0 7 317 5 95 85 82 81 7 
AIRBASE_NODE TAXI 0 0 -21 237 4 95 84 83 63 
AIRBASE_NODE TAXI 0 0 45 422 5 99 103 100 62 7 
AIRBASE_NODE APRON 4 20019 -6 403 2 98 7 
AIRBASE_NODE APRON 4 20054 18 473 2 98 62 
AIRBASE_NODE APRON 4 20339 60 583 1 8 
AIRBASE_NODE APRON 4 20531 33 507 1 62 
AIRBASE_NODE APRON 4 20923 6 441 1 98 
AIRBASE_NODE APRON 4 19728 50 544 2 62 8 

NUM_HELIPADS 16
; Descriptor,size,rotation,x-ofset,z_offset
HELIPAD 1 0 -61 63		;(0_deg)
HELIPAD 1 0 -55 78		;(0_deg)
HELIPAD 1 0 -48 93		;(0_deg)
HELIPAD 1 0 -41 108		;(0_deg)
HELIPAD 1 19728 -321 -371	;(108_deg)
HELIPAD 1 19054 -364 -371	;(104_deg)
HELIPAD 1 19357 -363 -337	;(106_deg)
HELIPAD 1 20019 -314 -339	;(109_deg)
HELIPAD 1 19281 -314 -304	;(105_deg)
HELIPAD 1 20923 -361 -298	;(114_deg)
HELIPAD 1 21220 -216 265	;(116_deg)
HELIPAD 1 19728 -202 297	;(108_deg)
HELIPAD 1 23096 -178 336	;(126_deg)
HELIPAD 1 23096 -148 316	;(126_deg)
HELIPAD 1 22137 -168 280	;(121_deg)
HELIPAD 1 22749 -187 248	;(124_deg)

NUM_RUNWAYS 1
; Descriptor,x-ofset,z_offset,length,width,rotation,number_of_conns,id,id,...
RUNWAY -37 28 1118 20 3620 9 0 10 31 64 67 68 69 72 74

END_AIRBASE
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
User avatar
Krishty
Site Admin
Posts: 1271
Joined: 2022-Jan-09, 00:59

Re: overhauled flight model

Post by Krishty »

This is indeed exactly the data I was looking for!
Luxor-type airbases

Code: Select all

AIRBASE_TYPE LUXOR_AIRBASE
Has it occurred to you that this is the reason we see strings like LUXOR in Typhoon? This doesn’t seem to describe Luxor in particular, but rather a type of airbase with two crossing runways “like Luxor”. It would make sense to recycle this for other games; not changing the names makes sense when you’re under time pressure.
mikew
Data Genius
Posts: 558
Joined: 2022-Jan-09, 20:21

Re: overhauled flight model

Post by mikew »

Actually, 'airbase.txt' should be 'airbase.dat'. It's a text only file though.

Interesting theory, but I don't think Typhoon has anywhere near TAW's level of airbase sophistication.
User avatar
Krishty
Site Admin
Posts: 1271
Joined: 2022-Jan-09, 00:59

Re: overhauled flight model

Post by Krishty »

I have just verified that the autopilot in the new flight model is able to track a tanker as well as land on an airfield.

For fun, here are two F-22s competing for their place at a 747’s coordinate origin …
2022-03-31 autopilot.png
2022-03-31 autopilot.png (1.17 MiB) Viewed 1488 times

This functionality will not be available for some time as I had to generate the waypoint data synthetically, which was quite a hassle. The target was a verification of the flight control system’s autopilot parts, not an implementation of the actual autopilot.

One problem I’ve seen arising: While tracking a tanker, the control inputs have to become finer and softer the closer you get to the target. At one point, the F-22 will inevitably miss the target position by a millimeter or so, and the FCS will go OMG I’M LEFT OF MY TARGET LET’S TURN RIGHT and initiate a right turn. This will, of course, overshoot by a dozen meters, and the FCS will panic again, but in the opposite direction.

So the approach is really soft and safe until you’re within a few centimeters of the boom, and then the FCS will start oscillating like crazy, and it’ll look like the autopilot losing control. I have to keep that in mind for when we start working on the autopilot.
Post Reply