From edc4f9b1d64f5cd64919a693be136c73794269c5 Mon Sep 17 00:00:00 2001 From: Joshua Davidson Date: Fri, 15 Dec 2017 23:04:11 -0500 Subject: [PATCH 1/3] A3XX: Fix some FMGC bugs, #110 --- Nasal/FMGC-b.nas | 14 ++++++++++---- revision.txt | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Nasal/FMGC-b.nas b/Nasal/FMGC-b.nas index 22e9c84d..3dc4f31d 100644 --- a/Nasal/FMGC-b.nas +++ b/Nasal/FMGC-b.nas @@ -28,6 +28,7 @@ setlistener("/sim/signals/fdm-initialized", func { var gear2 = getprop("/gear/gear[2]/wow"); var gnds_mps = 0; var current_course = 0; + var wp_fly_from = 0; var wp_fly_to = 0; var next_course = 0; var max_bank_limit = 0; @@ -224,6 +225,7 @@ var fmabox = func { # Master Lateral setlistener("/it-autoflight/input/lat", func { if ((getprop("/gear/gear[1]/wow") == 0) and (getprop("/gear/gear[2]/wow") == 0)) { + setprop("/it-autoflight/input/lat-arm", 0); lateral(); } else { lat_arm(); @@ -554,12 +556,16 @@ var ap_various = func { if (getprop("/autopilot/route-manager/route/num") > 0 and getprop("/autopilot/route-manager/active") == 1) { gnds_mps = getprop("/velocities/groundspeed-kt") * 0.5144444444444; - current_course = getprop("/instrumentation/gps/wp/leg-true-course-deg"); + wp_fly_from = getprop("/autopilot/route-manager/current-wp"); + if (wp_fly_from < 0) { + wp_fly_from = 0; + } + current_course = getprop("/autopilot/route-manager/route/wp[" ~ wp_fly_from ~ "]/leg-bearing-true-deg"); wp_fly_to = getprop("/autopilot/route-manager/current-wp") + 1; if (wp_fly_to < 0) { wp_fly_to = 0; } - next_course = getprop("/autopilot/route-manager/route/wp["~wp_fly_to~"]/leg-bearing-true-deg"); + next_course = getprop("/autopilot/route-manager/route/wp[" ~ wp_fly_to ~ "]/leg-bearing-true-deg"); max_bank_limit = getprop("/it-autoflight/internal/bank-limit"); delta_angle = math.abs(geo.normdeg180(current_course - next_course)); @@ -567,8 +573,8 @@ var ap_various = func { if (max_bank > max_bank_limit) { max_bank = max_bank_limit; } - radius = (gnds_mps * gnds_mps) / (9.81 * math.tan(max_bank/57.2957795131)); - time = 0.64 * gnds_mps * delta_angle * 0.7 / (360 * math.tan(max_bank/57.2957795131)); + radius = (gnds_mps * gnds_mps) / (9.81 * math.tan(max_bank / 57.2957795131)); + time = 0.64 * gnds_mps * delta_angle * 0.7 / (360 * math.tan(max_bank / 57.2957795131)); delta_angle_rad = (180 - delta_angle) / 114.5915590262; R = radius/math.sin(delta_angle_rad); dist_coeff = delta_angle * -0.011111 + 2; diff --git a/revision.txt b/revision.txt index 29966f59..169d1445 100644 --- a/revision.txt +++ b/revision.txt @@ -1 +1 @@ -4070 \ No newline at end of file +4071 \ No newline at end of file From a138761dd25987bc6495f1e93a4aecde66034442 Mon Sep 17 00:00:00 2001 From: Joshua Davidson Date: Sat, 16 Dec 2017 20:47:53 -0500 Subject: [PATCH 2/3] A3XX: Fix FMGC NAV mode bugs --- AircraftConfig/error-mismatch.xml | 2 +- Nasal/FMGC-b.nas | 5 ++++- Systems/fmgc.xml | 2 +- revision.txt | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/AircraftConfig/error-mismatch.xml b/AircraftConfig/error-mismatch.xml index f3e33019..b2bd8c4a 100644 --- a/AircraftConfig/error-mismatch.xml +++ b/AircraftConfig/error-mismatch.xml @@ -112,7 +112,7 @@ left - + diff --git a/Nasal/FMGC-b.nas b/Nasal/FMGC-b.nas index 3dc4f31d..57e34d2f 100644 --- a/Nasal/FMGC-b.nas +++ b/Nasal/FMGC-b.nas @@ -579,9 +579,12 @@ var ap_various = func { R = radius/math.sin(delta_angle_rad); dist_coeff = delta_angle * -0.011111 + 2; if (dist_coeff < 1) { - ist_coeff = 1; + dist_coeff = 1; } turn_dist = math.cos(delta_angle_rad) * R * dist_coeff / 1852; + if (getprop("/gear/gear[0]/wow") == 1 and turn_dist < 1) { + turn_dist = 1; + } setprop("/it-autoflight/internal/lnav-advance-nm", turn_dist); if (getprop("/sim/time/elapsed-sec")-getprop("/autopilot/internal/wp-change-time") > 60) { setprop("/autopilot/internal/wp-change-check-period", time); diff --git a/Systems/fmgc.xml b/Systems/fmgc.xml index 3f76fe73..e9dcdd92 100644 --- a/Systems/fmgc.xml +++ b/Systems/fmgc.xml @@ -6,7 +6,7 @@ ############################################## --> - + /FMGC/internal/greendot-kts diff --git a/revision.txt b/revision.txt index 169d1445..5af20608 100644 --- a/revision.txt +++ b/revision.txt @@ -1 +1 @@ -4071 \ No newline at end of file +4072 \ No newline at end of file From a71cda533e37eede2ca4964268d472584ac00b9e Mon Sep 17 00:00:00 2001 From: Joshua Davidson Date: Sat, 16 Dec 2017 20:49:17 -0500 Subject: [PATCH 3/3] A32X: Whoops! --- Systems/fmgc.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Systems/fmgc.xml b/Systems/fmgc.xml index e9dcdd92..3f76fe73 100644 --- a/Systems/fmgc.xml +++ b/Systems/fmgc.xml @@ -6,7 +6,7 @@ ############################################## --> - + /FMGC/internal/greendot-kts