Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Systems: Auto-GCAS #601

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 49 additions & 7 deletions Systems/jsb-autoflight.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,17 @@
<default value="1"/>
<test logic="OR" value="0"> <!-- Add conditions where AP fails here -->
position/wow eq 1
elec/bus/emergency-dc-2 lt 20
</test>
<!-- TODO: Rewrite this? -->
<test value="1">
/systems/agcas/engage eq 1
</test>
<test logic="OR" value="0">
attitude/roll-rad gt 1.0472
attitude/roll-rad lt -1.0472
attitude/pitch-rad lt -1.0472
attitude/pitch-rad gt 1.0472
elec/bus/emergency-dc-2 lt 20
</test>
</switch>

Expand Down Expand Up @@ -128,11 +134,15 @@
/sim/time/elapsed-sec lt autoflight/ss/reset-time-delay
</test>
</switch>

<!-- TODO: Do agcas switching here or in autoflight/switch-xxx? -->
<switch name="autoflight/output/roll-master">
<default value="0"/>
<test logic="AND" value="1"> <!-- autoflight/switch-pitch is not a typo -->
autoflight/switch-pitch ne 0
<test logic="AND" value="1">
<test logic="OR"> <!-- autoflight/switch-pitch is not a typo -->
autoflight/switch-pitch ne 0
<!-- TODO: Should this depend on agcas engage? -->
/systems/agcas/roll-cmd ne 0
</test>
autoflight/can-engage eq 1
autoflight/ss/force eq 0
position/wow eq 0
Expand All @@ -142,7 +152,11 @@
<switch name="autoflight/output/pitch-master">
<default value="0"/>
<test logic="AND" value="1">
autoflight/switch-pitch ne 0
<test logic="OR">
autoflight/switch-pitch ne 0
<!-- TODO: Should this depend on agcas engage? -->
/systems/agcas/pitch-cmd ne 0
</test>
autoflight/can-engage eq 1
autoflight/ss/force eq 0
position/wow eq 0
Expand Down Expand Up @@ -422,6 +436,10 @@

<switch name="autoflight/roll/roll-rad-input">
<default value="attitude/roll-rad"/>
<test logic="AND" value="0">
autoflight/output/roll-master eq 1
/systems/agcas/roll-cmd eq 3
</test>
<test logic="AND" value="autoflight/roll/roll-cmd-target">
autoflight/output/roll-master eq 1
autoflight/switch-roll ne 0
Expand Down Expand Up @@ -561,7 +579,8 @@
</function>
</fcs_function>

<switch name="autoflight/roll/roll-rate-demand">
<!-- TODO: Rename this? -->
<switch name="autoflight/roll/roll-rate-demand1">
<default value="0"/>
<test logic="AND" value="autoflight/roll/roll-rate-deg">
autoflight/output/roll-master eq 1
Expand All @@ -572,6 +591,19 @@
</clipto>
</switch>

<switch name="autoflight/roll/roll-rate-demand">
<default value="autoflight/roll/roll-rate-demand1"/>
<test value="0">
autoflight/output/roll-master ne 1
</test>
<test value="180">
/systems/agcas/roll-cmd eq 1
</test>
<test value="-180">
/systems/agcas/roll-cmd eq 2
</test>
</switch>

</channel>

<channel name="Autoflight: Pitch Channel">
Expand Down Expand Up @@ -791,7 +823,8 @@
</clipto>
</fcs_function>

<switch name="autoflight/pitch/g-demand-switched">
<!-- TODO: Rename this? -->
<switch name="autoflight/pitch/g-demand-switched1">
<default value="0"/>
<test logic="AND" value="autoflight/pitch/g-demand">
autoflight/output/pitch-master eq 1
Expand All @@ -802,6 +835,15 @@
</clipto>
</switch>

<switch name="autoflight/pitch/g-demand-switched">
<default value="autoflight/pitch/g-demand-switched1"/>
<test value="0">
autoflight/output/pitch-master ne 1
</test>
<test value="2.0">
/systems/agcas/pitch-cmd ne 0
</test>
</switch>
</channel>

</system>
84 changes: 84 additions & 0 deletions Systems/jsb-misc.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1254,4 +1254,88 @@
</switch>
</channel>

<channel name="Auto-GCAS" execrate="8">
<switch name="/systems/agcas/serviceable">
<default value="0"/>
<test logic="AND" value="1">
/systems/agcas/switch == 1
</test>
</switch>
<switch name="/systems/agcas/engage">
<description>
<!-- TODO: Find documentation for this -->
Engage auto-gcas when flyup is initiated (8s before predicted impact time)
</description>
<default value="0"/>
<!-- Disable if not serviceable -->
<test logic="AND" value="0">
/systems/agcas/switch == 0
</test>
<test value="1">
/systems/agcas/manual-enable == 1
</test>
<!-- TODO: Disable AGCAS via manual-override -->
<!-- Test if time-till-crash is between 0-8 seconds -->
<test logic="AND" value="1">
/instrumentation/radar/time-till-crash gt 0
/instrumentation/radar/time-till-crash lt 8
</test>
<!-- Stay engaged until determined to be safe -->
<test value="0">
/instrumentation/radar/time-till-crash == 15
</test>
<test value="1">
/systems/agcas/engage == 1
</test>
</switch>

<switch name="/systems/agcas/roll-cmd">
<description>Roll to wings-level (180 deg/sec)</description>
<!--
Modes:
0 = Disabled
1 = Command roll right to wings-level
2 = Command roll left to wings-level
3 = Hold roll angle
-->
<default value="0"/>
<test value="0">
/systems/agcas/engage == 0
</test>
<test logic="AND" value="3">
/orientation/roll-deg lt 20
/orientation/roll-deg gt -20
</test>
<test value="1">
/orientation/roll-deg lt 0
</test>
<test value="2">
/orientation/roll-deg gt 0
</test>
</switch>

<switch name="/systems/agcas/pitch-cmd">
<description>Pull-up command (4G/sec)</description>
<!--
Modes:
0 = Disabled
1 = Target 5G
2 = Target max AoA
-->
<test logic="OR" value="0">
/systems/agcas/engage == 0

/orientation/roll-deg gt 90
/orientation/roll-deg lt -90
</test>
<!-- TODO: Remove mode 2? -->
<test value="2">
<!-- Max AoA is 25, using 20 so we don't prematurely exceed that -->
/orientation/alpha-deg gt 20
</test>
<default value="1"/>

</switch>
</channel>

</system>
9 changes: 9 additions & 0 deletions f16-base.xml
Original file line number Diff line number Diff line change
Expand Up @@ -992,6 +992,15 @@
<offset-z-m>0.68</offset-z-m>
<max-fuel-transfer-lbs-min>6000</max-fuel-transfer-lbs-min>
</refuel>
<agcas>
<engage type="bool">false</engage>
<manual-enable type="bool">false</manual-enable>
<pitch-cmd type="int">0</pitch-cmd>
<roll-cmd type="int">0</roll-cmd>
<serviceable type="bool">true</serviceable>
<stage type="int">1</stage>
<switch type="bool">true</switch>
</agcas>
</systems>
<instrumentation>
<altimeter>
Expand Down