Change how position of FPV is calculated - copy from MD11
This commit is contained in:
parent
cf4089d82e
commit
3881bdd381
2 changed files with 44 additions and 34 deletions
|
@ -16,6 +16,7 @@ var elapsedtime = 0;
|
||||||
var altTens = 0;
|
var altTens = 0;
|
||||||
var altPolarity = "";
|
var altPolarity = "";
|
||||||
var track_diff = 0;
|
var track_diff = 0;
|
||||||
|
var AICenter = nil; # FPV
|
||||||
|
|
||||||
# Fetch nodes:
|
# Fetch nodes:
|
||||||
var state1 = props.globals.getNode("/systems/thrust/state1", 1);
|
var state1 = props.globals.getNode("/systems/thrust/state1", 1);
|
||||||
|
@ -137,7 +138,7 @@ var adr_1_fault = props.globals.getNode("/controls/navigation/adirscp/lights/adr
|
||||||
var adr_2_fault = props.globals.getNode("/controls/navigation/adirscp/lights/adr-2-fault", 1);
|
var adr_2_fault = props.globals.getNode("/controls/navigation/adirscp/lights/adr-2-fault", 1);
|
||||||
var adr_3_fault = props.globals.getNode("/controls/navigation/adirscp/lights/adr-3-fault", 1);
|
var adr_3_fault = props.globals.getNode("/controls/navigation/adirscp/lights/adr-3-fault", 1);
|
||||||
var air_data_switch = props.globals.getNode("/controls/navigation/switching/air-data", 1);
|
var air_data_switch = props.globals.getNode("/controls/navigation/switching/air-data", 1);
|
||||||
|
var alpha = props.globals.getNode("/fdm/jsbsim/aero/alpha-deg", 1); # TODO - Is this used anywhere?
|
||||||
|
|
||||||
# Create Nodes:
|
# Create Nodes:
|
||||||
var alt_diff = props.globals.initNode("/instrumentation/pfd/alt-diff", 0.0, "DOUBLE");
|
var alt_diff = props.globals.initNode("/instrumentation/pfd/alt-diff", 0.0, "DOUBLE");
|
||||||
|
@ -149,9 +150,7 @@ var horizon_ground = props.globals.initNode("/instrumentation/pfd/horizon-ground
|
||||||
var hdg_diff = props.globals.initNode("/instrumentation/pfd/hdg-diff", 0.0, "DOUBLE");
|
var hdg_diff = props.globals.initNode("/instrumentation/pfd/hdg-diff", 0.0, "DOUBLE");
|
||||||
var hdg_scale = props.globals.initNode("/instrumentation/pfd/heading-scale", 0.0, "DOUBLE");
|
var hdg_scale = props.globals.initNode("/instrumentation/pfd/heading-scale", 0.0, "DOUBLE");
|
||||||
var track = props.globals.initNode("/instrumentation/pfd/track-deg", 0.0, "DOUBLE");
|
var track = props.globals.initNode("/instrumentation/pfd/track-deg", 0.0, "DOUBLE");
|
||||||
# This always seems to return 0 if TRK FPA selected, which is incorrect. I don't know how/where this value is set.
|
#var track_diff = props.globals.initNode("/instrumentation/pfd/track-hdg-diff", 0.0, "DOUBLE"); # returns incorrect value and can calculate on the fly
|
||||||
# So I've commented it out and calculate it using the difference between magnetic track and heading.
|
|
||||||
#var track_diff = props.globals.initNode("/instrumentation/pfd/track-hdg-diff", 0.0, "DOUBLE");
|
|
||||||
var du1_test = props.globals.initNode("/instrumentation/du/du1-test", 0, "BOOL");
|
var du1_test = props.globals.initNode("/instrumentation/du/du1-test", 0, "BOOL");
|
||||||
var du1_test_time = props.globals.initNode("/instrumentation/du/du1-test-time", 0.0, "DOUBLE");
|
var du1_test_time = props.globals.initNode("/instrumentation/du/du1-test-time", 0.0, "DOUBLE");
|
||||||
var du1_offtime = props.globals.initNode("/instrumentation/du/du1-off-time", 0.0, "DOUBLE");
|
var du1_offtime = props.globals.initNode("/instrumentation/du/du1-off-time", 0.0, "DOUBLE");
|
||||||
|
@ -214,6 +213,9 @@ var canvas_PFD_base = {
|
||||||
me.AI_horizon_hdg_trans = me["AI_heading"].createTransform();
|
me.AI_horizon_hdg_trans = me["AI_heading"].createTransform();
|
||||||
me.AI_horizon_hdg_rot = me["AI_heading"].createTransform();
|
me.AI_horizon_hdg_rot = me["AI_heading"].createTransform();
|
||||||
|
|
||||||
|
me.AI_fpv_trans = me["FPV"].createTransform();
|
||||||
|
me.AI_fpv_rot = me["FPV"].createTransform();
|
||||||
|
|
||||||
me.page = canvas_group;
|
me.page = canvas_group;
|
||||||
|
|
||||||
return me;
|
return me;
|
||||||
|
@ -1026,8 +1028,7 @@ var canvas_PFD_base = {
|
||||||
me["AI_heading"].update();
|
me["AI_heading"].update();
|
||||||
},
|
},
|
||||||
|
|
||||||
# Dim the yellow outline of fixed aircraft symbol on PFDs
|
# Dim the yellow outline of fixed aircraft symbol on PFDs (eg when crew select TRK)
|
||||||
# eg when crew select TRK
|
|
||||||
# 1 == dim
|
# 1 == dim
|
||||||
# 0 == undim
|
# 0 == undim
|
||||||
dimFixedAircraftOutline: func(dim_bool) {
|
dimFixedAircraftOutline: func(dim_bool) {
|
||||||
|
@ -1059,23 +1060,6 @@ var canvas_PFD_base = {
|
||||||
return nil;
|
return nil;
|
||||||
},
|
},
|
||||||
|
|
||||||
# Returns Y (vertical) translation value for FPV - accounting for angle of roll
|
|
||||||
# (On the PFD the FPA is perpendicular to the artificial horizon, which is not always horizontal.)
|
|
||||||
getFPVYTranslation: func(track_x_translation, fpa_deg) {
|
|
||||||
|
|
||||||
var FPV_Y_COEFFICIENT = 12.5; # query if it should be 12.5 or 11.825
|
|
||||||
|
|
||||||
var pitch_px = pitch.getValue() * FPV_Y_COEFFICIENT;
|
|
||||||
var roll_rad = roll.getValue() * D2R;
|
|
||||||
|
|
||||||
var pitch_y_translation = math.tan(roll_rad) * (( pitch_px/math.sin(roll_rad)) + track_x_translation);
|
|
||||||
|
|
||||||
var fpa_y_translation = (fpa_deg * FPV_Y_COEFFICIENT)/math.cos(roll_rad);
|
|
||||||
|
|
||||||
return pitch_y_translation + ((-1) * fpa_y_translation);
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
# Convert difference between magnetic heading and track measured in degrees to pixel for display on PFDs
|
# Convert difference between magnetic heading and track measured in degrees to pixel for display on PFDs
|
||||||
# And set max and minimum values
|
# And set max and minimum values
|
||||||
getTrackDiffPixels: func(track_diff_deg) {
|
getTrackDiffPixels: func(track_diff_deg) {
|
||||||
|
@ -1154,6 +1138,7 @@ var canvas_PFD_1 = {
|
||||||
|
|
||||||
# FPV
|
# FPV
|
||||||
# If TRK FPA selected on the FCU, display FPV on PFD1
|
# If TRK FPA selected on the FCU, display FPV on PFD1
|
||||||
|
# Display FPV in red and freeze if FPA outside the range of -9.9 degrees or 9.9 degrees
|
||||||
if (ap_trk_sw.getValue() == 0 ) {
|
if (ap_trk_sw.getValue() == 0 ) {
|
||||||
me["FPV"].hide();
|
me["FPV"].hide();
|
||||||
me.dimFixedAircraftOutline(0);
|
me.dimFixedAircraftOutline(0);
|
||||||
|
@ -1163,15 +1148,26 @@ var canvas_PFD_1 = {
|
||||||
me["FPV"].hide();
|
me["FPV"].hide();
|
||||||
me.dimFixedAircraftOutline(0);
|
me.dimFixedAircraftOutline(0);
|
||||||
} else {
|
} else {
|
||||||
|
var roll_deg = roll.getValue() or 0;
|
||||||
|
var alpha_deg = aoa;
|
||||||
|
var fpa_deg = pitch.getValue() - alpha_deg;
|
||||||
|
|
||||||
|
AICenter = me["AI_center"].getCenter();
|
||||||
var track_x_translation = me.getTrackDiffPixels(track_diff);
|
var track_x_translation = me.getTrackDiffPixels(track_diff);
|
||||||
var fpa_deg = pitch.getValue() - aoa;
|
|
||||||
if (fpa_deg > 9.9 or fpa_deg < -9.9) {
|
if (fpa_deg > 9.9) {
|
||||||
fpa_deg = math.clamp(fpa_deg, -9.9, 9.9);
|
alpha_deg = alpha_deg + (fpa_deg - 9.9);
|
||||||
|
me["FPV"].setColor(1, 0, 0);
|
||||||
|
} else if (fpa_deg < -9.9) {
|
||||||
|
alpha_deg = alpha_deg + (fpa_deg + 9.9);
|
||||||
me["FPV"].setColor(1, 0, 0);
|
me["FPV"].setColor(1, 0, 0);
|
||||||
} else {
|
} else {
|
||||||
me["FPV"].setColor(0.066666667, 0.752941176, 0.294117647);
|
me["FPV"].setColor(0.066666667, 0.752941176, 0.294117647);
|
||||||
}
|
}
|
||||||
me["FPV"].setTranslation(track_x_translation, me.getFPVYTranslation(track_x_translation, fpa_deg));
|
|
||||||
|
me.AI_fpv_trans.setTranslation(track_x_translation, math.clamp(alpha_deg, -20, 20) * 12.5);
|
||||||
|
me.AI_fpv_rot.setRotation(-roll_deg * D2R, AICenter);
|
||||||
|
me["FPV"].setRotation(roll_deg * D2R); # It shouldn't be rotated, only the axis should be
|
||||||
me["FPV"].show();
|
me["FPV"].show();
|
||||||
me.dimFixedAircraftOutline(1);
|
me.dimFixedAircraftOutline(1);
|
||||||
}
|
}
|
||||||
|
@ -1918,6 +1914,7 @@ var canvas_PFD_2 = {
|
||||||
|
|
||||||
# FPV
|
# FPV
|
||||||
# If TRK FPA selected on the FCU, display FPV on PFD2
|
# If TRK FPA selected on the FCU, display FPV on PFD2
|
||||||
|
# Display FPV in red and freeze if FPA outside the range of -9.9 degrees or 9.9 degrees
|
||||||
if (ap_trk_sw.getValue() == 0 ) {
|
if (ap_trk_sw.getValue() == 0 ) {
|
||||||
me["FPV"].hide();
|
me["FPV"].hide();
|
||||||
me.dimFixedAircraftOutline(0);
|
me.dimFixedAircraftOutline(0);
|
||||||
|
@ -1927,15 +1924,26 @@ var canvas_PFD_2 = {
|
||||||
me["FPV"].hide();
|
me["FPV"].hide();
|
||||||
me.dimFixedAircraftOutline(0);
|
me.dimFixedAircraftOutline(0);
|
||||||
} else {
|
} else {
|
||||||
|
var roll_deg = roll.getValue() or 0;
|
||||||
|
var alpha_deg = aoa;
|
||||||
|
var fpa_deg = pitch.getValue() - alpha_deg;
|
||||||
|
|
||||||
|
AICenter = me["AI_center"].getCenter();
|
||||||
var track_x_translation = me.getTrackDiffPixels(track_diff);
|
var track_x_translation = me.getTrackDiffPixels(track_diff);
|
||||||
var fpa_deg = pitch.getValue() - aoa;
|
|
||||||
if (fpa_deg > 9.9 or fpa_deg < -9.9) {
|
if (fpa_deg > 9.9) {
|
||||||
fpa_deg = math.clamp(fpa_deg, -9.9, 9.9);
|
alpha_deg = alpha_deg + (fpa_deg - 9.9);
|
||||||
|
me["FPV"].setColor(1, 0, 0);
|
||||||
|
} else if (fpa_deg < -9.9) {
|
||||||
|
alpha_deg = alpha_deg + (fpa_deg + 9.9);
|
||||||
me["FPV"].setColor(1, 0, 0);
|
me["FPV"].setColor(1, 0, 0);
|
||||||
} else {
|
} else {
|
||||||
me["FPV"].setColor(0.066666667, 0.752941176, 0.294117647);
|
me["FPV"].setColor(0.066666667, 0.752941176, 0.294117647);
|
||||||
}
|
}
|
||||||
me["FPV"].setTranslation(track_x_translation, me.getFPVYTranslation(track_x_translation, fpa_deg));
|
|
||||||
|
me.AI_fpv_trans.setTranslation(track_x_translation, math.clamp(alpha_deg, -20, 20) * 12.5);
|
||||||
|
me.AI_fpv_rot.setRotation(-roll_deg * D2R, AICenter);
|
||||||
|
me["FPV"].setRotation(roll_deg * D2R); # It shouldn't be rotated, only the axis should be
|
||||||
me["FPV"].show();
|
me["FPV"].show();
|
||||||
me.dimFixedAircraftOutline(1);
|
me.dimFixedAircraftOutline(1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,8 +46,8 @@
|
||||||
inkscape:zoom="6.0943624"
|
inkscape:zoom="6.0943624"
|
||||||
showgrid="true"
|
showgrid="true"
|
||||||
id="namedview371"
|
id="namedview371"
|
||||||
inkscape:window-height="835"
|
inkscape:window-height="1015"
|
||||||
inkscape:window-width="1600"
|
inkscape:window-width="1920"
|
||||||
inkscape:pageshadow="2"
|
inkscape:pageshadow="2"
|
||||||
inkscape:pageopacity="1"
|
inkscape:pageopacity="1"
|
||||||
guidetolerance="10"
|
guidetolerance="10"
|
||||||
|
@ -6659,7 +6659,9 @@
|
||||||
y="74.429939"
|
y="74.429939"
|
||||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:35.9995px;line-height:1.25;font-family:'Liberation Sans';-inkscape-font-specification:'Liberation Sans';text-align:center;text-anchor:middle;fill:#ffffff;fill-opacity:1;stroke-width:0.657577">FLX</tspan></text>
|
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:35.9995px;line-height:1.25;font-family:'Liberation Sans';-inkscape-font-specification:'Liberation Sans';text-align:center;text-anchor:middle;fill:#ffffff;fill-opacity:1;stroke-width:0.657577">FLX</tspan></text>
|
||||||
<g
|
<g
|
||||||
id="FPV">
|
id="FPV"
|
||||||
|
style="stroke:#11c04b;stroke-opacity:1"
|
||||||
|
transform="translate(0.03412367,-0.04316723)">
|
||||||
<circle
|
<circle
|
||||||
style="fill:none;fill-opacity:1;stroke:#11c04b;stroke-width:5.92816;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
style="fill:none;fill-opacity:1;stroke:#11c04b;stroke-width:5.92816;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||||
id="path1861"
|
id="path1861"
|
||||||
|
|
Before Width: | Height: | Size: 368 KiB After Width: | Height: | Size: 368 KiB |
Loading…
Reference in a new issue