From a1bfea36abd4b2abf7f66aa5eea108896f8f9d4e Mon Sep 17 00:00:00 2001 From: Joshua Davidson Date: Mon, 17 Apr 2017 00:10:36 -0400 Subject: [PATCH] proper JSBsim based FBW logic for inputs now, should be MUCH better to fly --- A319-100-IAE.xml | 3 +- A320-200-IAE.xml | 3 +- A320-main.xml | 7 +- A321-200-IAE.xml | 3 +- ACJ-IAE.xml | 3 +- AircraftConfig/fbw.xml | 8 +- Nasal/it-fbw.nas | 166 +++---------- Systems/it-fbw-b.xml | 450 +++++++++++++++++++++++++++++++++ Systems/it-fbw.xml | 550 +++++++++-------------------------------- 9 files changed, 605 insertions(+), 588 deletions(-) create mode 100644 Systems/it-fbw-b.xml diff --git a/A319-100-IAE.xml b/A319-100-IAE.xml index 1eac00cf..6e088171 100644 --- a/A319-100-IAE.xml +++ b/A319-100-IAE.xml @@ -560,7 +560,8 @@ YAW MOI_________3950000______23089847_______24848934 - + + diff --git a/A320-200-IAE.xml b/A320-200-IAE.xml index 64718245..99b7c85b 100644 --- a/A320-200-IAE.xml +++ b/A320-200-IAE.xml @@ -560,7 +560,8 @@ YAW MOI_________3950000______23089847_______24848934 - + + diff --git a/A320-main.xml b/A320-main.xml index 12e0f865..365f9966 100644 --- a/A320-main.xml +++ b/A320-main.xml @@ -35,7 +35,7 @@ - Aircraft/A320Family/Systems/it-fbw.xml + Aircraft/A320Family/Systems/it-fbw-b.xml Aircraft/A320Family/Systems/it-autoflight.xml @@ -295,11 +295,6 @@ - - 0 - 0 - - 0 0 diff --git a/A321-200-IAE.xml b/A321-200-IAE.xml index 570e2863..b0e0983b 100644 --- a/A321-200-IAE.xml +++ b/A321-200-IAE.xml @@ -560,7 +560,8 @@ YAW MOI_________3950000______23089847_______24848934 - + + diff --git a/ACJ-IAE.xml b/ACJ-IAE.xml index cc29d68e..f07e357b 100644 --- a/ACJ-IAE.xml +++ b/ACJ-IAE.xml @@ -560,7 +560,8 @@ YAW MOI_________3950000______23089847_______24848934 - + + diff --git a/AircraftConfig/fbw.xml b/AircraftConfig/fbw.xml index 0f0b2543..65786d0b 100644 --- a/AircraftConfig/fbw.xml +++ b/AircraftConfig/fbw.xml @@ -38,7 +38,7 @@ nasal @@ -50,7 +50,7 @@ nasal @@ -62,7 +62,7 @@ nasal @@ -74,7 +74,7 @@ nasal diff --git a/Nasal/it-fbw.nas b/Nasal/it-fbw.nas index 3048eb84..3eb9bcd7 100644 --- a/Nasal/it-fbw.nas +++ b/Nasal/it-fbw.nas @@ -1,5 +1,5 @@ # Airbus A3XX FBW System by Joshua Davidson (it0uchpods/411) -# V0.9.2 +# V0.9.6 ######################## # Roll Update Function # @@ -8,66 +8,23 @@ var roll_input = func { var ail = getprop("/controls/flight/aileron"); - - if (getprop("/it-autoflight/output/ap1") == 0 and getprop("/it-autoflight/output/ap2") == 0 and ((getprop("/it-fbw/law") == "NORMAL") or (getprop("/it-fbw/law") == "ALTERNATE"))) { - - if (ail >= 0.05 and ail < 0.15) { - var rfbw = getprop("/it-fbw/roll-deg"); - setprop("/it-fbw/roll-deg", rfbw + "0.01"); - } else if (ail >= 0.15 and ail < 0.3) { - var rfbw = getprop("/it-fbw/roll-deg"); - setprop("/it-fbw/roll-deg", rfbw + "0.05"); - } else if (ail >= 0.3 and ail < 0.5) { - var rfbw = getprop("/it-fbw/roll-deg"); - setprop("/it-fbw/roll-deg", rfbw + "0.1"); - } else if (ail >= 0.5 and ail < 0.7) { - var rfbw = getprop("/it-fbw/roll-deg"); - setprop("/it-fbw/roll-deg", rfbw + "0.2"); - } else if (ail >= 0.7 and ail <= 1) { - var rfbw = getprop("/it-fbw/roll-deg"); - setprop("/it-fbw/roll-deg", rfbw + "0.3"); - } - if (ail <= -0.05 and ail > -0.15) { - var rfbw = getprop("/it-fbw/roll-deg"); - setprop("/it-fbw/roll-deg", rfbw - "0.01"); - } else if (ail <= -0.15 and ail > -0.3) { - var rfbw = getprop("/it-fbw/roll-deg"); - setprop("/it-fbw/roll-deg", rfbw - "0.05"); - } else if (ail <= -0.3 and ail > -0.5) { - var rfbw = getprop("/it-fbw/roll-deg"); - setprop("/it-fbw/roll-deg", rfbw - "0.01"); - } else if (ail <= -0.5 and ail > -0.7) { - var rfbw = getprop("/it-fbw/roll-deg"); - setprop("/it-fbw/roll-deg", rfbw - "0.2"); - } else if (ail <= -0.7 and ail >= -1) { - var rfbw = getprop("/it-fbw/roll-deg"); - setprop("/it-fbw/roll-deg", rfbw - "0.3"); - } - } - - if (getprop("/it-fbw/roll-deg") >= 33) { - if (getprop("/it-fbw/law") == "NORMAL") { - if (ail > 0.4) { - if (getprop("/it-fbw/roll-deg") >= 67) { - setprop("/it-fbw/roll-deg", "67"); - } - } else { + if (getprop("/it-fbw/law") == 0) { + if (ail > 0.4 or ail < -0.4) { + setprop("/it-fbw/roll-lim-max", "67"); + setprop("/it-fbw/roll-lim-min", "-67"); + } else { + setprop("/it-fbw/roll-lim-max", "33"); + setprop("/it-fbw/roll-lim-min", "-33"); + if (getprop("/it-fbw/law") > 33) { setprop("/it-fbw/roll-deg", "33"); - } - } - } - - if (getprop("/it-fbw/roll-deg") <= -33) { - if (getprop("/it-fbw/law") == "NORMAL") { - if (ail < -0.4) { - if (getprop("/it-fbw/roll-deg") <= -67) { - setprop("/it-fbw/roll-deg", "-67"); - } - } else { + } else if (getprop("/it-fbw/law") < -33) { setprop("/it-fbw/roll-deg", "-33"); } } + } else { + setprop("/it-fbw/roll-lim-max", "160"); + setprop("/it-fbw/roll-lim-min", "-160"); } if (getprop("/gear/gear[0]/wow") == 1) { @@ -82,87 +39,26 @@ var roll_input = func { var pitch_input = func { var elev = getprop("/controls/flight/elevator"); - - if (getprop("/it-autoflight/output/ap1") == 0 and getprop("/it-autoflight/output/ap2") == 0 and ((getprop("/it-fbw/law") == "NORMAL") or (getprop("/it-fbw/law") == "ALTERNATE"))) { - - if (elev >= 0.05 and elev < 0.15) { - var pfbw = getprop("/it-fbw/pitch-deg"); - setprop("/it-fbw/pitch-deg", pfbw - "0.005"); - } else if (elev >= 0.15 and elev < 0.3) { - var pfbw = getprop("/it-fbw/pitch-deg"); - setprop("/it-fbw/pitch-deg", pfbw - "0.01"); - } else if (elev >= 0.3 and elev < 0.5) { - var pfbw = getprop("/it-fbw/pitch-deg"); - setprop("/it-fbw/pitch-deg", pfbw - "0.05"); - } else if (elev >= 0.5 and elev < 0.7) { - var pfbw = getprop("/it-fbw/pitch-deg"); - setprop("/it-fbw/pitch-deg", pfbw - "0.1"); - } else if (elev >= 0.7 and elev <= 1) { - var pfbw = getprop("/it-fbw/pitch-deg"); - setprop("/it-fbw/pitch-deg", pfbw - "0.2"); - } - if (elev <= -0.05 and elev > -0.15) { - var pfbw = getprop("/it-fbw/pitch-deg"); - setprop("/it-fbw/pitch-deg", pfbw + "0.005"); - } else if (elev <= -0.15 and elev > -0.3) { - var pfbw = getprop("/it-fbw/pitch-deg"); - setprop("/it-fbw/pitch-deg", pfbw + "0.01"); - } else if (elev <= -0.3 and elev > -0.5) { - var pfbw = getprop("/it-fbw/pitch-deg"); - setprop("/it-fbw/pitch-deg", pfbw + "0.05"); - } else if (elev <= -0.5 and elev > -0.7) { - var pfbw = getprop("/it-fbw/pitch-deg"); - setprop("/it-fbw/pitch-deg", pfbw + "0.1"); - } else if (elev <= -0.7 and elev >= -1) { - var pfbw = getprop("/it-fbw/pitch-deg"); - setprop("/it-fbw/pitch-deg", pfbw + "0.2"); - } - - if ((getprop("/controls/flight/flap-lever") >= 3) and (getprop("/controls/engines/engine[0]/throttle") < 0.65) and (getprop("/controls/engines/engine[1]/throttle") < 0.65) and (getprop("/position/gear-agl-ft") <= 50)) { - if (elev > -0.05 and elev < 0.05) { - var pfbw = getprop("/it-fbw/pitch-deg"); - setprop("/it-fbw/pitch-deg", pfbw - "0.003"); - } - var gear1 = setlistener("/gear/gear[1]/wow", func { - if (getprop("/gear/gear[1]/wow") == 1 and getprop("/gear/gear[2]/wow") == 1) { - removelistener(gear1); - setprop("/controls/flight/elevator-trim", -0.1); - } - }); - var gear2 = setlistener("/gear/gear[2]/wow", func { - if (getprop("/gear/gear[1]/wow") == 1 and getprop("/gear/gear[2]/wow") == 1) { - removelistener(gear2); - setprop("/controls/flight/elevator-trim", -0.1); - } - }); - } - } - - if (getprop("/it-fbw/pitch-deg") >= 15) { - if (getprop("/position/gear-agl-ft") <= 30) { - setprop("/it-fbw/pitch-deg", "15"); - } - if (getprop("/it-fbw/pitch-deg") >= 30) { - if (getprop("/it-fbw/law") == "NORMAL") { - setprop("/it-fbw/pitch-deg", "30"); - } - } - } - - if (getprop("/it-fbw/pitch-deg") <= -15) { - if (getprop("/it-fbw/law") == "NORMAL") { - setprop("/it-fbw/pitch-deg", "-15"); - } + if (getprop("/it-fbw/law") == 0) { + setprop("/it-fbw/pitch-lim-max", "30"); + setprop("/it-fbw/pitch-lim-min", "-15"); + } else { + setprop("/it-fbw/pitch-lim-max", "160"); + setprop("/it-fbw/pitch-lim-min", "-160"); } if (getprop("/gear/gear[0]/wow") == 1) { - if (elev > -0.1 and elev < 0.1) { + if (elev > -0.05 and elev < 0.05) { setprop("/it-fbw/pitch-deg", getprop("/orientation/pitch-deg")); } } } +########################### +# Various Other Functions # +########################### + setlistener("/it-autoflight/output/ap1", func { if (getprop("/it-autoflight/output/ap1") == 0) { setprop("/it-fbw/roll-deg", getprop("/orientation/roll-deg")); @@ -178,17 +74,17 @@ setlistener("/it-autoflight/output/ap2", func { }); setlistener("/it-fbw/law", func { - if (getprop("/it-fbw/law") == "NORMAL") { + if (getprop("/it-fbw/law") == 0) { setprop("/it-fbw/roll-deg", getprop("/orientation/roll-deg")); setprop("/it-fbw/pitch-deg", getprop("/orientation/pitch-deg")); - } else if (getprop("/it-fbw/law") == "ALTERNATE") { + } else if (getprop("/it-fbw/law") == 1) { setprop("/it-fbw/roll-deg", getprop("/orientation/roll-deg")); setprop("/it-fbw/pitch-deg", getprop("/orientation/pitch-deg")); } }); setlistener("/sim/signals/fdm-initialized", func { - setprop("/it-fbw/law", "DIRECT"); + setprop("/it-fbw/law", 2); update_roll.start(); update_pitch.start(); print("AIRBUS FBW ... OK!"); @@ -196,12 +92,12 @@ setlistener("/sim/signals/fdm-initialized", func { setlistener("/systems/electrical/bus/ac-ess", func { if (getprop("/systems/electrical/bus/ac-ess") >= 110) { - if (getprop("/it-fbw/law") != "NORMAL") { - setprop("/it-fbw/law", "NORMAL"); + if (getprop("/it-fbw/law") != 0) { + setprop("/it-fbw/law", 0); } } else { - if (getprop("/it-fbw/law") != "DIRECT") { - setprop("/it-fbw/law", "DIRECT"); + if (getprop("/it-fbw/law") != 2) { + setprop("/it-fbw/law", 2); } } }); diff --git a/Systems/it-fbw-b.xml b/Systems/it-fbw-b.xml new file mode 100644 index 00000000..3e97bd04 --- /dev/null +++ b/Systems/it-fbw-b.xml @@ -0,0 +1,450 @@ + + + + + + + + + + + + IT-FBW: ROLL + false + + + + + /it-autoflight/output/ap1 + 0 + + + /it-autoflight/output/ap2 + 0 + + + /gear/gear[1]/wow + 0 + + + /gear/gear[2]/wow + 0 + + + + /it-fbw/law + 0 + + + /it-fbw/law + 1 + + + + + + + /orientation/roll-deg + + + /it-fbw/roll-deg + + + /controls/flight/aileron-fbw-cmd + + + 0.12 + 1 + 0.1 + 0 + 10 + 0.00001 + -1 + 1 + + + + + IT-FBW: ROLL OPTION + false + true + output + + + + + /it-autoflight/output/ap1 + 0 + + + /it-autoflight/output/ap2 + 0 + + + /gear/gear[1]/wow + 0 + + + /gear/gear[2]/wow + 0 + + + + /it-fbw/law + 0 + + + /it-fbw/law + 1 + + + + + /controls/flight/aileron-fbw-cmd + + + + + + /it-autoflight/output/ap1 + 1 + + + /it-autoflight/output/ap2 + 1 + + + /gear/gear[1]/wow + 1 + + + /gear/gear[2]/wow + 1 + + + /it-fbw/law + 2 + + + + /controls/flight/aileron + + + + + /it-fbw/law + 3 + + + 0 + + /controls/flight/aileron-fbw + noise-spike + 10 + + + + + + + + IT-FBW: PITCH + false + + + + + /it-autoflight/output/ap1 + 0 + + + /it-autoflight/output/ap2 + 0 + + + /gear/gear[1]/wow + 0 + + + /gear/gear[2]/wow + 0 + + + + /it-fbw/law + 0 + + + /it-fbw/law + 1 + + + + + + + /orientation/pitch-deg + + + /it-fbw/pitch-deg + + + /controls/flight/elevator-fbw-cmd + + + -0.20 + 1 + 0.1 + 0 + 10 + 0.00001 + -1 + 1 + + + + + IT-FBW: PITCH OPTION + false + true + output + + + + + /it-autoflight/output/ap1 + 0 + + + /it-autoflight/output/ap2 + 0 + + + /gear/gear[1]/wow + 0 + + + /gear/gear[2]/wow + 0 + + + + /it-fbw/law + 0 + + + /it-fbw/law + 1 + + + + + /controls/flight/elevator-fbw-cmd + + + + + + /it-autoflight/output/ap1 + 1 + + + /it-autoflight/output/ap2 + 1 + + + /gear/gear[1]/wow + 1 + + + /gear/gear[2]/wow + 1 + + + /it-fbw/law + 2 + + + + /controls/flight/elevator + + + + + /it-fbw/law + 3 + + + 0 + + /controls/flight/elevator-fbw + noise-spike + 10 + + + + AP PITCH HELPER PLUS + false + + + + + /controls/flight/elevator-fbw + 0.1 + + + /it-autoflight/output/ap1 + 0 + + + /it-autoflight/output/ap2 + 0 + + + + /it-fbw/law + 0 + + + /it-fbw/law + 1 + + + + /position/gear-agl-ft + 50 + + + + + + 0 + + + 1 + + + /controls/flight/elevator-trim-cmd + + + 0.08 + 1.0 + 0.1 + 0.0 + 10 + 0.00001 + -1.00 + 1.00 + + + + + FBW PITCH HELPER MINUS + false + + + + + /controls/flight/elevator-fbw + -0.1 + + + /it-autoflight/output/ap1 + 0 + + + /it-autoflight/output/ap2 + 0 + + + + /it-fbw/law + 0 + + + /it-fbw/law + 1 + + + + /position/gear-agl-ft + 50 + + + + + + 0 + + + 1 + + + /controls/flight/elevator-trim-cmd + + + -0.08 + 1.0 + 0.1 + 0.0 + 10 + 0.00001 + -1.00 + 1.00 + + + + + IT-FBW: PITCH TRIM FILTER + false + true + output + + + + + + /it-autoflight/output/ap1 + 0 + + + /it-autoflight/output/ap2 + 0 + + + + /it-fbw/law + 0 + + + /it-fbw/law + 1 + + + + /position/gear-agl-ft + 50 + + + + + /controls/flight/elevator-fbw + 0.05 + + + /controls/flight/elevator-fbw + -0.05 + + + + + + + /controls/flight/elevator-trim-cmd + + /controls/flight/elevator-trim + noise-spike + 0.01 + + + diff --git a/Systems/it-fbw.xml b/Systems/it-fbw.xml index 3ded3499..4693d8b7 100644 --- a/Systems/it-fbw.xml +++ b/Systems/it-fbw.xml @@ -1,450 +1,122 @@ - + + /it-fbw/law + /it-fbw/roll-deg + /it-fbw/pitch-deg + /it-fbw/roll-lim-max + /it-fbw/roll-lim-min + /it-fbw/pitch-lim-max + /it-fbw/pitch-lim-min - - - - - - - - - - IT-FBW: ROLL - false - - - - - /it-autoflight/output/ap1 - 0 - - - /it-autoflight/output/ap2 - 0 - - - /gear/gear[1]/wow - 0 - - - /gear/gear[2]/wow - 0 - - - - /it-fbw/law - NORMAL - - - /it-fbw/law - ALTERNATE - - - - - - - /orientation/roll-deg - - - /it-fbw/roll-deg - - - /controls/flight/aileron-fbw-cmd - - - 0.12 - 1 - 0.1 - 0 - 10 - 0.00001 - -1 - 1 - - - - - IT-FBW: ROLL OPTION - false - true - output - - - - - /it-autoflight/output/ap1 - 0 - - - /it-autoflight/output/ap2 - 0 - - - /gear/gear[1]/wow - 0 - - - /gear/gear[2]/wow - 0 - - - - /it-fbw/law - NORMAL - - - /it-fbw/law - ALTERNATE - - - - - /controls/flight/aileron-fbw-cmd - - - - - - /it-autoflight/output/ap1 - 1 - - - /it-autoflight/output/ap2 - 1 - - - /gear/gear[1]/wow - 1 - - - /gear/gear[2]/wow - 1 - - - /it-fbw/law - DIRECT - - - - /controls/flight/aileron - - - - - /it-fbw/law - BACKUP - - - 0 - - /controls/flight/aileron-fbw - noise-spike - 10 - - - - - - - - IT-FBW: PITCH - false - - - - - /it-autoflight/output/ap1 - 0 - - - /it-autoflight/output/ap2 - 0 - - - /gear/gear[1]/wow - 0 - - - /gear/gear[2]/wow - 0 - - - - /it-fbw/law - NORMAL - - - /it-fbw/law - ALTERNATE - - - - - - - /orientation/pitch-deg - - - /it-fbw/pitch-deg - - - /controls/flight/elevator-fbw-cmd - - - -0.20 - 1 - 0.1 - 0 - 10 - 0.00001 - -1 - 1 - - - - - IT-FBW: PITCH OPTION - false - true - output - - - - - /it-autoflight/output/ap1 - 0 - - - /it-autoflight/output/ap2 - 0 - - - /gear/gear[1]/wow - 0 - - - /gear/gear[2]/wow - 0 - - - - /it-fbw/law - NORMAL - - - /it-fbw/law - ALTERNATE - - - - - /controls/flight/elevator-fbw-cmd - - - - - - /it-autoflight/output/ap1 - 1 - - - /it-autoflight/output/ap2 - 1 - - - /gear/gear[1]/wow - 1 - - - /gear/gear[2]/wow - 1 - - - /it-fbw/law - DIRECT - - - - /controls/flight/elevator - - - - - /it-fbw/law - BACKUP - - - 0 - - /controls/flight/elevator-fbw - noise-spike - 10 - - - - AP PITCH HELPER PLUS - false - - - - - /controls/flight/elevator-fbw - 0.1 - - - /it-autoflight/output/ap1 - 0 - - - /it-autoflight/output/ap2 - 0 - - - - /it-fbw/law - NORMAL - - - /it-fbw/law - ALTERNATE - - - - /position/gear-agl-ft - 50 - - - - - - 0 - - - 1 - - - /controls/flight/elevator-trim-cmd - - - 0.08 - 1.0 - 0.1 - 0.0 - 10 - 0.00001 - -1.00 - 1.00 - - - - - FBW PITCH HELPER MINUS - false - - - - - /controls/flight/elevator-fbw - -0.1 - - - /it-autoflight/output/ap1 - 0 - - - /it-autoflight/output/ap2 - 0 - - - - /it-fbw/law - NORMAL - - - /it-fbw/law - ALTERNATE - - - - /position/gear-agl-ft - 50 - - - - - - 0 - - - 1 - - - /controls/flight/elevator-trim-cmd - - - -0.08 - 1.0 - 0.1 - 0.0 - 10 - 0.00001 - -1.00 - 1.00 - - - - - IT-FBW: PITCH TRIM FILTER - false - true - output - - - + + + + - + /it-autoflight/output/ap1 0 - - + + /it-autoflight/output/ap2 0 - + + + /gear/gear[0]/wow + 0 + - + /it-fbw/law - NORMAL - - + 0 + + /it-fbw/law - ALTERNATE - + 1 + - - /position/gear-agl-ft - 50 - - - - /controls/flight/elevator-fbw - 0.05 - - - /controls/flight/elevator-fbw - -0.05 - - - - - - - /controls/flight/elevator-trim-cmd - - /controls/flight/elevator-trim - noise-spike - 0.01 - - - + + /it-fbw/roll-deg + + /controls/flight/aileron + + -1.0 -0.2 + -0.7 -0.1 + -0.5 -0.05 + -0.3 -0.01 + -0.15 -0.005 + -0.05 -0.001 + 0.00 0.00 + 0.05 0.001 + 0.15 0.005 + 0.3 0.01 + 0.5 0.05 + 0.7 0.1 + 1.0 0.2 + +
+
+ 0 + + + + /it-fbw/roll-lim-min + /it-fbw/roll-lim-max + + +
+ + + + + + + /it-autoflight/output/ap1 + 0 + + + /it-autoflight/output/ap2 + 0 + + + + /it-fbw/law + 0 + + + /it-fbw/law + 1 + + + + + /it-fbw/pitch-deg + + /controls/flight/elevator + + -1.0 0.1 + -0.7 0.05 + -0.5 0.02 + -0.3 0.01 + -0.15 0.005 + -0.05 0.001 + 0.00 0.00 + 0.05 -0.001 + 0.15 -0.005 + 0.3 -0.01 + 0.5 -0.02 + 0.7 -0.05 + 1.0 -0.1 + +
+
+ 0 +
+
+ + /it-fbw/pitch-lim-min + /it-fbw/pitch-lim-max + +
+
+