oprf_assets/missile-frigate/Systems/fdm.xml
2016-12-22 00:31:49 -08:00

411 lines
14 KiB
XML

<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2015 onox
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<PropertyList>
<!-- Simulate the groundspeed -->
<filter>
<name>FDM Groundspeed</name>
<type>noise-spike</type>
<input>
<property>/carrier/fbw/target/groundspeed-kt</property>
</input>
<output>
<property>/velocities/groundspeed-kt</property>
</output>
<!-- Reaching maximum speed takes 20 minutes -->
<max-rate-of-change>0.075</max-rate-of-change>
</filter>
<!-- Flags use true-heading-deg because only that property is available
in multiplayer.
-->
<filter>
<name>FDM True Heading For Flags</name>
<type>gain</type>
<input>
<property>/orientation/heading-deg</property>
</input>
<output>
<property>/orientation/true-heading-deg</property>
</output>
</filter>
<!-- ================================================================== -->
<!-- Waves -->
<!-- ================================================================== -->
<!-- Compute the heading of the waves relative to the ship. -90 or
90 if perpendicular, and 0 if colinear.
-->
<filter>
<name>FDM Wave Heading</name>
<type>gain</type>
<input>
<expression>
<difference>
<rad2deg>
<atan2>
<property>/environment/sea/surface/wind-from-east-fps</property>
<property>/environment/sea/surface/wind-from-north-fps</property>
</atan2>
</rad2deg>
<property>/orientation/heading-deg</property>
</difference>
</expression>
<period>
<min>-90</min>
<max>90</max>
</period>
</input>
<output>
<property>/carrier/fdm/output/wave-heading</property>
</output>
</filter>
<!-- Compute the normalized value of the relative wave heading. 1 if
perpendicular, 0 if sailing in to the wind.
-->
<filter>
<name>FDM Wave Perpendicular Normalized</name>
<type>gain</type>
<input>
<expression>
<div>
<abs>
<property>/carrier/fdm/output/wave-heading</property>
</abs>
<value>90.0</value>
</div>
</expression>
</input>
<output>
<property>/carrier/fdm/output/wave-perpendicular-norm</property>
</output>
</filter>
<!-- Computes the strength of the waves in knots -->
<filter>
<name>FDM Wave Strength</name>
<type>gain</type>
<input>
<expression>
<product>
<sqrt>
<sum>
<pow>
<property>/environment/sea/surface/wind-from-east-fps</property>
<value>2.0</value>
</pow>
<pow>
<property>/environment/sea/surface/wind-from-north-fps</property>
<value>2.0</value>
</pow>
</sum>
</sqrt>
<!-- fps to knots -->
<value>0.5924838012958964</value>
</product>
</expression>
</input>
<output>
<property>/carrier/fdm/output/wave-speed-kt</property>
</output>
</filter>
<filter>
<name>FDM Heel Wave Factor</name>
<type>gain</type>
<input>
<expression>
<div>
<min>
<product>
<property>/carrier/fdm/output/wave-speed-kt</property>
<sin>
<deg2rad>
<abs>
<property>/carrier/fdm/output/wave-heading</property>
</abs>
</deg2rad>
</sin>
</product>
<property>/carrier/fdm/settings/max-heel-oscillation-wave-kt</property>
</min>
<property>/carrier/fdm/settings/max-heel-oscillation-wave-kt</property>
</div>
</expression>
</input>
<output>
<property>/carrier/fdm/output/heel-wave-factor</property>
</output>
</filter>
<filter>
<name>FDM Trim Wave Factor</name>
<type>gain</type>
<input>
<expression>
<div>
<min>
<sum>
<product>
<property>/carrier/fdm/output/wave-speed-kt</property>
<cos>
<deg2rad>
<abs>
<property>/carrier/fdm/output/wave-heading</property>
</abs>
</deg2rad>
</cos>
</product>
<property>/velocities/groundspeed-kt</property>
</sum>
<property>/carrier/fdm/settings/max-trim-oscillation-wave-kt</property>
</min>
<property>/carrier/fdm/settings/max-trim-oscillation-wave-kt</property>
</div>
</expression>
</input>
<output>
<property>/carrier/fdm/output/trim-wave-factor</property>
</output>
</filter>
<!-- ================================================================== -->
<!-- Roll -->
<!-- ================================================================== -->
<!-- Simulate the movement of the rudder -->
<filter>
<name>FDM Rudder</name>
<type>noise-spike</type>
<input>
<property>/controls/flight/rudder</property>
</input>
<output>
<property>/surface-positions/rudder-pos-norm</property>
</output>
<!-- Moving the rudder to maximum deviation takes 5 seconds -->
<max-rate-of-change>0.2</max-rate-of-change>
</filter>
<!-- Simulate the roll of the ship depending on the rudder deflection
and groundspeed. A roll of 15 deg will be obtained at a groundspeed
of 30 knots and maximum rudder deflection.
-->
<filter>
<name>FDM Turn Centrifugal Force</name>
<type>gain</type>
<input>
<expression>
<product>
<div>
<property>/velocities/groundspeed-kt</property>
<value>30.0</value>
</div>
<property>/surface-positions/rudder-pos-norm</property>
<property>/carrier/fdm/settings/bank-limit</property>
<value>-1.0</value>
</product>
</expression>
</input>
<output>
<property>/carrier/fdm/target/roll-deg</property>
</output>
</filter>
<!-- PID controller used to simulate slowly reaching the target roll
degree representing the roll caused when turning.
-->
<pid-controller>
<name>FDM Turn PID</name>
<input>
<property>/carrier/roll-deg</property>
</input>
<reference>
<property>/carrier/fdm/target/roll-deg</property>
</reference>
<output>
<property>/carrier/fdm/output/roll-deg</property>
</output>
<config>
<Kp>0.5</Kp>
<Ti>2.0</Ti>
<u_min>
<property>/carrier/fdm/settings/bank-limit</property>
<scale>-1.0</scale>
</u_min>
<u_max>
<property>/carrier/fdm/settings/bank-limit</property>
</u_max>
</config>
</pid-controller>
<!-- An undamped oscillator simulating heeling (continuously rolling
around the longitudinal axis) of the ship. The output does not
oscillate around 0, instead it oscillates between 0 and some
negative value. See the gain filter below, which makes the value
oscillate around 0.
-->
<filter>
<name>FDM Heeling Force Oscillator</name>
<type>damped-oscillation</type>
<debug>false</debug>
<a>
<value>0.0</value>
</a>
<b>
<property>/carrier/fdm/settings/heel-frequency</property>
</b>
<c>
<expression>
<product>
<property>/carrier/fdm/settings/heel-frequency</property>
<property>/carrier/fdm/settings/heel-overshoot</property>
</product>
</expression>
</c>
<output>
<property>/carrier/fdm/output/heel-osci</property>
</output>
</filter>
<!-- Add the configured heel overshoot to make the oscillating value
oscillate around 0.
-->
<filter>
<name>FDM Heeling Degree</name>
<type>gain</type>
<input>
<expression>
<sum>
<property>/carrier/fdm/output/heel-osci</property>
<property>/carrier/fdm/settings/heel-overshoot</property>
</sum>
</expression>
</input>
<output>
<property>/carrier/fdm/output/heel-deg</property>
</output>
</filter>
<!-- Use the sum of the PID controller and the undamped oscillator
as the actual roll degree.
-->
<filter>
<name>FDM Roll</name>
<type>gain</type>
<input>
<condition>
<property>/carrier/fdm/settings/movement</property>
</condition>
<property>/carrier/fdm/output/roll-deg</property>
<offset>
<property>/carrier/fdm/output/heel-deg</property>
<scale>
<property>/carrier/fdm/output/heel-wave-factor</property>
</scale>
</offset>
</input>
<input>
<value>0.0</value>
</input>
<output>
<property>/carrier/roll-deg</property>
</output>
</filter>
<!-- ================================================================== -->
<!-- Pitch -->
<!-- ================================================================== -->
<!-- An undamped oscillator simulating trimming (continuously pitching
around the lateral axis) of the ship. The output does not
oscillate around 0, instead it oscillates between 0 and some
negative value. See the gain filter below, which makes the value
oscillate around 0.
-->
<filter>
<name>FDM Trimming Force Oscillator</name>
<type>damped-oscillation</type>
<debug>false</debug>
<a>
<value>0.0</value>
</a>
<b>
<property>/carrier/fdm/settings/trim-frequency</property>
</b>
<c>
<expression>
<product>
<property>/carrier/fdm/settings/trim-frequency</property>
<property>/carrier/fdm/settings/trim-overshoot</property>
</product>
</expression>
</c>
<output>
<property>/carrier/fdm/output/trim-osci</property>
</output>
</filter>
<!-- Add the configured trim overshoot to make the oscillating value
oscillate around 0.
-->
<filter>
<name>FDM Trimming Degree</name>
<type>gain</type>
<input>
<expression>
<sum>
<property>/carrier/fdm/output/trim-osci</property>
<property>/carrier/fdm/settings/trim-overshoot</property>
</sum>
</expression>
</input>
<output>
<property>/carrier/fdm/output/trim-deg</property>
</output>
</filter>
<filter>
<name>FDM Pitch</name>
<type>gain</type>
<input>
<condition>
<property>/carrier/fdm/settings/movement</property>
</condition>
<property>/carrier/fdm/output/trim-deg</property>
<scale>
<property>/carrier/fdm/output/trim-wave-factor</property>
</scale>
</input>
<input>
<value>0.0</value>
</input>
<output>
<property>/carrier/pitch-deg</property>
</output>
</filter>
</PropertyList>