A3XX: Improve NAV Mode

This commit is contained in:
Joshua Davidson 2017-12-14 21:28:19 -05:00
parent dd1959b8df
commit 17d363df1d
5 changed files with 52 additions and 37 deletions

View file

@ -10,7 +10,7 @@
<sim> <sim>
<author>it0uchpods Design Group: Joshua Davidson (it0uchpods), Jonathan Redpath (legoboyvdlp), Thorsten Herrmann (TH-555), Charlie Schwehm (Wecsje)</author> <author>it0uchpods Design Group: Joshua Davidson (it0uchpods), Jonathan Redpath (legoboyvdlp), Thorsten Herrmann (TH-555)</author>
<status>Pre V1.0</status> <status>Pre V1.0</status>

View file

@ -43,7 +43,7 @@
</text> </text>
<text> <text>
<halign>left</halign> <halign>left</halign>
<label>Joshua Davidson (it0uchpods), Jonanthan Redpath (legoboyvdlp), Charlie Schwehm (Wecsje), J Maverick 16, Thorsten Herrmann (TH-555)</label> <label>Joshua Davidson (it0uchpods), Jonanthan Redpath (legoboyvdlp), Thorsten Herrmann (TH-555)</label>
</text> </text>
<hrule/> <hrule/>

View file

@ -26,6 +26,19 @@ setlistener("/sim/signals/fdm-initialized", func {
var FPangle = 0; var FPangle = 0;
var gear1 = getprop("/gear/gear[1]/wow"); var gear1 = getprop("/gear/gear[1]/wow");
var gear2 = getprop("/gear/gear[2]/wow"); var gear2 = getprop("/gear/gear[2]/wow");
var gnds_mps = 0;
var current_course = 0;
var wp_fly_to = 0;
var next_course = 0;
var max_bank_limit = 0;
var delta_angle = 0;
var max_bank = 0;
var radius = 0;
var time = 0;
var delta_angle_rad = 0;
var R = 0;
var dist_coeff = 0;
var turn_dist = 0;
}); });
var APinit = func { var APinit = func {
@ -525,6 +538,10 @@ var trkfpa_on = func {
} }
} }
setlistener("/autopilot/route-manager/current-wp", func {
setprop("/autopilot/internal/wp-change-time", getprop("/sim/time/elapsed-sec"));
});
var ap_various = func { var ap_various = func {
trueSpeedKts = getprop("/instrumentation/airspeed-indicator/true-speed-kt"); trueSpeedKts = getprop("/instrumentation/airspeed-indicator/true-speed-kt");
if (trueSpeedKts > 420) { if (trueSpeedKts > 420) {
@ -536,7 +553,35 @@ var ap_various = func {
} }
if (getprop("/autopilot/route-manager/route/num") > 0 and getprop("/autopilot/route-manager/active") == 1) { if (getprop("/autopilot/route-manager/route/num") > 0 and getprop("/autopilot/route-manager/active") == 1) {
if (getprop("/autopilot/route-manager/wp/dist") <= getprop("/it-autoflight/internal/lnav-advance-nm")) { gnds_mps = getprop("/velocities/groundspeed-kt") * 0.5144444444444;
current_course = getprop("/instrumentation/gps/wp/leg-true-course-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");
max_bank_limit = getprop("/it-autoflight/internal/bank-limit");
delta_angle = math.abs(geo.normdeg180(current_course - next_course));
max_bank = delta_angle * 1.5;
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));
delta_angle_rad = (180 - delta_angle) / 114.5915590262;
R = radius/math.sin(delta_angle_rad);
dist_coeff = delta_angle * -0.011111 + 2;
if (dist_coeff < 1) {
ist_coeff = 1;
}
turn_dist = math.cos(delta_angle_rad) * R * dist_coeff / 1852;
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);
}
if (getprop("/autopilot/route-manager/wp/dist") <= turn_dist) {
if ((getprop("/autopilot/route-manager/current-wp") + 1) < getprop("/autopilot/route-manager/route/num")) { if ((getprop("/autopilot/route-manager/current-wp") + 1) < getprop("/autopilot/route-manager/route/num")) {
setprop("/autopilot/route-manager/current-wp", getprop("/autopilot/route-manager/current-wp") + 1); setprop("/autopilot/route-manager/current-wp", getprop("/autopilot/route-manager/current-wp") + 1);
} }

View file

@ -438,36 +438,6 @@
<output>/instrumentation/pfd/track-deg</output> <output>/instrumentation/pfd/track-deg</output>
</filter> </filter>
<filter>
<name>LNAV ADVANCE</name>
<type>gain</type>
<gain>1.0</gain>
<input>
<expression>
<sum>
<table>
<property>/velocities/groundspeed-kt</property>
<entry><ind>120</ind><dep>1.0</dep></entry>
<entry><ind>400</ind><dep>1.2</dep></entry>
</table>
<table>
<abs>
<dif>
<property>/autopilot/route-manager/wp[1]/true-bearing-deg</property>
<property>/autopilot/route-manager/wp[0]/true-bearing-deg</property>
</dif>
</abs>
<entry><ind>30</ind><dep>0.0</dep></entry>
<entry><ind>70</ind><dep>1.0</dep></entry>
</table>
</sum>
</expression>
</input>
<output>/it-autoflight/internal/lnav-advance-nm</output>
<min>1.0</min>
<max>5.0</max>
</filter>
<filter> <filter>
<name>HEADING ERROR DEG</name> <name>HEADING ERROR DEG</name>
<debug>false</debug> <debug>false</debug>

View file

@ -11,7 +11,7 @@
<filter> <filter>
<name>Groundspeed Meters Per Second</name> <name>Groundspeed Meters Per Second</name>
<type>gain</type> <type>gain</type>
<gain>0.51444444444</gain> <gain>0.5144444444444</gain>
<input>/velocities/groundspeed-kt</input> <input>/velocities/groundspeed-kt</input>
<output>/velocities/groundspeed-mps</output> <output>/velocities/groundspeed-mps</output>
<min>0</min> <min>0</min>
@ -574,7 +574,7 @@
<input> <input>
<expression> <expression>
<product> <product>
<property>velocities/uBody-fps</property> <property>/velocities/uBody-fps</property>
<value>0.592484</value> <value>0.592484</value>
</product> </product>
</expression> </expression>
@ -589,11 +589,11 @@
<update-interval-secs type="double">0.05</update-interval-secs> <update-interval-secs type="double">0.05</update-interval-secs>
<input> <input>
<product> <product>
<property>fdm/jsbsim/inertia/weight-lbs</property> <property>/fdm/jsbsim/inertia/weight-lbs</property>
<value>0.45359237</value> <value>0.45359237</value>
</product> </product>
</input> </input>
<output>fdm/jsbsim/inertia/weight-kg</output> <output>/fdm/jsbsim/inertia/weight-kg</output>
</filter> </filter>
<filter> <filter>