<?xml version="1.0"?>

<!--F-8E Crusader  WORK IN PROGRESS-->

    <!--<Kp></Kp> proportional gain -->
    <!--<beta></beta> input value weighing factor -->
   <!-- <alpha></alpha>  low pass filter weighing factor -->
   <!-- <gamma></gamma>  input value weighing factor for -->

   <!-- <Ti></Ti>  integrator time -->
    <!--<Td>1</Td> derivator time -->
    <!--<u_min>-</u_min> minimum output clamp -->
    <!--<u_max></u_max> maximum output clamp -->



<PropertyList>

	<!-- =============================================================== -->
	<!-- Roll Axis Modes                                                 -->
	<!-- =============================================================== -->

	<!-- Wing leveler -->
	<pid-controller>
		<name>Wing Leveler (Turn Coordinator based)</name>
		<debug>false</debug>
		<enable>
			<prop>/autopilot/locks/heading</prop>
			<value>wing-leveler</value>
		</enable>
		<input>
			<prop>/instrumentation/turn-indicator/indicated-turn-rate</prop>
		</input>
		<reference>
			<value>0.0</value>
		</reference>
		<output>
			<prop>/controls/flight/aileron</prop>
		</output>
		<config>
			<Kp>0.015</Kp>
			<beta>1.0</beta>
			<alpha>0.1</alpha>
			<gamma>0.0</gamma>

			<Ti>10.0</Ti>
			<Td>0.00001</Td>
			<u_min>-1.0</u_min>
			<u_max>1.0</u_max>
		</config>
	</pid-controller>

        <!-- =============================================================== -->
        <!-- Roll Axis Modes -->
	<!-- =============================================================== -->


        <!-- =============================================================== -->
	<!-- Heading Bug Hold.  2 stage cascade controller. -->
        <!-- =============================================================== -->


        <!-- =============================================================== -->
        <!-- Heading Bug Hold.  -->
        <!-- =============================================================== -->
	
	<pid-controller>
		<name>Heading Bug Hold (DG based) Etape1</name>
		<debug>false</debug>
		<enable>
			<prop>/autopilot/locks/heading</prop>
			<value>dg-heading-hold</value>
		</enable>
		<input>
			<prop>/autopilot/internal/heading-bug-error-deg</prop>
		</input>
		<reference>
			<value>0.0</value>
		</reference>
		<output>
			<prop>/autopilot/internal/target-roll-deg</prop>
		</output>
		<config>
			<Kp>-1.2</Kp>
			<beta>1.0</beta>
			<alpha>0.1</alpha>
			<gamma>0.0</gamma>
			<Ti>30.0</Ti> 
			<!--plus augmente plus ralenti la progression vers l'objectif et réduis l'osscillation-->
			<Td>0.0000001</Td>
			<u_min>-10.0</u_min>
			<u_max>10.0</u_max>
		</config>
	</pid-controller>


	<pid-controller>
		<name>Heading Bug Hold (DG based) Etape2</name>
		<debug>false</debug>
		<enable>
			<prop>/autopilot/locks/heading</prop>
			<value>dg-heading-hold</value>
		</enable>
		<input>
			<prop>/orientation/roll-deg</prop>
		</input>
		<reference>
			<prop>/autopilot/internal/target-roll-deg</prop>
		</reference>
		<output>
			<prop>/controls/flight/aileron</prop>
		</output>
		<config>
			<Kp>0.02</Kp>
			<beta>0.80</beta>
			<alpha>0.01</alpha>
			<gamma>0.0</gamma>

			<Ti>0.80</Ti>
			<Td>0.0000001</Td>
			<u_min>-1.50</u_min>
			<u_max>1.50</u_max>
		</config>
	</pid-controller>

        <!-- =============================================================== -->
	<!-- True Heading hold.  2 stage cascade controller. -->
        <!-- =============================================================== -->

	<pid-controller>
		<name>True Heading Hold (DG based) Etape1</name>
		<debug>false</debug>
		<enable>
			<prop>/autopilot/locks/heading</prop>
			<value>true-heading-hold</value>
		</enable>
		<input>
			<prop>/autopilot/internal/true-heading-error-deg</prop>
		</input>
		<reference>
			<value>0.0</value>
		</reference>
		<output>
			<prop>/autopilot/internal/target-roll-deg</prop>
		</output>
		<config>
			<Kp>-1.0</Kp>
			<beta>1.0</beta>
			<alpha>0.1</alpha>
			<gamma>0.0</gamma>

			<Ti>50.0</Ti>         <!--plus augmente plus ralenti la progression vers l'objectif et réduis l'osscillation-->
			<Td>0.01</Td>
			<u_min>-30.0</u_min>
			<u_max>30.0</u_max>
		</config>
	</pid-controller>


	<pid-controller>
		<name>True Heading Hold (DG based) Etape2</name>
		<debug>false</debug>
		<enable>
			<prop>/autopilot/locks/heading</prop>
			<value>true-heading-hold</value>
		</enable>
		<input>
			<prop>/orientation/roll-deg</prop>
		</input>
		<reference>
			<prop>/autopilot/internal/target-roll-deg</prop>
		</reference>
		<output>
			<prop>/controls/flight/aileron</prop>
		</output>
		<config>
			<Kp>0.015</Kp>
			<beta>1.0</beta>
			<alpha>0.1</alpha>
			<gamma>0.0</gamma>

			<Ti>10.0</Ti>
			<Td>0.01</Td>
			<u_min>-1.0</u_min>
			<u_max>1.0</u_max>
		</config>
	</pid-controller>
        <!-- =============================================================== -->
        <!-- True Heading hold.. -->
        <!-- =============================================================== -->


        <!-- =============================================================== -->
	<!-- Nav1 hold.  2 stage cascade controller. -->
        <!-- =============================================================== -->

	<pid-controller>
		<name>Nav1 Hold Etape1</name>
		<debug>false</debug>
		<enable>
			<prop>/autopilot/locks/heading</prop>
			<value>nav1-hold</value>
		</enable>
		<input>
			<prop>/autopilot/internal/nav1-heading-error-deg</prop>
		</input>
		<reference>
			<value>0.0</value>
		</reference>
		<output>
			<prop>/autopilot/internal/target-roll-deg</prop>
		</output>
		<config>
			<Kp>-1.0</Kp>
			<beta>1.0</beta>
			<alpha>0.1</alpha>
			<gamma>0.0</gamma>
                        <Ti>50.0</Ti>         <!--plus augmente plus ralenti la progression vers l'objectif et réduis l'osscillation-->
			<Td>0.01</Td>
			<u_min>-20.0</u_min>
			<u_max>20.0</u_max>
		</config>
	</pid-controller>


	<pid-controller>
		<name>Nav1 Hold Etape2</name>
		<debug>false</debug>
		<enable>
			<prop>/autopilot/locks/heading</prop>
			<value>nav1-hold</value>
		</enable>
		<input>
			<prop>/orientation/roll-deg</prop>
		</input>
		<reference>
			<prop>/autopilot/internal/target-roll-deg</prop>
		</reference>
		<output>
			<prop>/controls/flight/aileron</prop>
		</output>
		<config>
			<Kp>0.1</Kp>
			<beta>1.0</beta>
			<alpha>0.1</alpha>
			<gamma>0.0</gamma>

			<Ti>10.0</Ti>
			<Td>0.00001</Td>
			<u_min>-1.0</u_min>
			<u_max>1.0</u_max>
		</config>
	</pid-controller>
        <!-- =============================================================== -->
        <!-- Nav1 hold.. -->
        <!-- =============================================================== -->


	<!-- =============================================================== -->
	<!-- Pitch Axis Modes                                                -->
	<!-- =============================================================== -->

	<!-- Simple pitch hold -->
	<pid-controller>
		<name>Pitch hold</name>
		<debug>false</debug>
		<enable>
			<prop>/autopilot/locks/altitude</prop>
			<value>pitch-hold</value>
		</enable>
		<input>
			<prop>/orientation/pitch-deg</prop>
		</input>
		<reference>
			<prop>/autopilot/settings/target-pitch-deg</prop>
		</reference>
		<output>
			<prop>/controls/flight/elevator-trim</prop>
		</output>
		<config>
			<Kp>-0.05</Kp>
			<beta>1.0</beta>
			<alpha>0.1</alpha>
			<gamma>0.0</gamma>

			<Ti>1.0</Ti>
			<Td>0.00001</Td>
			<u_min>-1.0</u_min>
			<u_max>1.0</u_max>
		</config>
	</pid-controller>
        <!-- =============================================================== -->
        <!-- Pitch Axis Modes                                                -->
	<!-- =============================================================== -->

        <!-- =============================================================== -->
	<!-- Simple angle of attack hold -->
        <!-- =============================================================== -->
	<pid-controller>
		<name>AOA hold</name>
		<debug>false</debug>
		<enable>
			<prop>/autopilot/locks/altitude</prop>
			<value>aoa-hold</value>
		</enable>
		<input>
			<prop>/orientation/alpha-deg</prop>
		</input>
		<reference>
			<prop>/autopilot/settings/target-aoa-deg</prop>
		</reference>
		<output>
			<prop>/controls/flight/elevator-trim</prop>
		</output>
		<config>
			<Kp>-0.05</Kp>
			<beta>1.0</beta>
			<alpha>0.1</alpha>
			<gamma>0.0</gamma>

			<Ti>0.5</Ti>
			<Td>0.00001</Td>
			<u_min>-1.0</u_min>
			<u_max>1.0</u_max>
		</config>
	</pid-controller>
        <!-- =============================================================== -->
        <!-- Simple angle of attack hold -->
        <!-- =============================================================== -->

        <!-- =============================================================== -->
	<!-- Altitude hold.  2 stage cascade controller. -->
        <!-- =============================================================== -->

	<pi-simple-controller>
		<name>Altitude Hold (Altimeter based) Etape1</name>
		<debug>false</debug>
		<enable>
			<prop>/autopilot/locks/altitude</prop>
			<value>altitude-hold</value>
		</enable>
		<input>
			<prop>/position/altitude-ft</prop>
		</input>
		<reference>
			<prop>/autopilot/settings/target-altitude-ft</prop>
		</reference>
		<output>
			<prop>/autopilot/internal/target-climb-rate-fps</prop>
		</output>
		<config>
			<Kp>0.3</Kp>
			<Ki>0.01</Ki>
			<u_min>-33.34</u_min>
			<u_max>33.34</u_max>
		</config>
	</pi-simple-controller>


	<pid-controller>
		<name>Altitude Hold (Altimeter based) Etape2</name>
		<debug>false</debug>
		<enable>
			<prop>/autopilot/locks/altitude</prop>
			<value>altitude-hold</value>
		</enable>
		<input>
			<prop>/velocities/vertical-speed-fps</prop>
		</input>
		<reference>
			<prop>/autopilot/internal/target-climb-rate-fps</prop>
		</reference>
		<output>
			<prop>/controls/flight/elevator-trim</prop>
		</output>
		<config>
                    <Kp>-0.01</Kp>     <!-- proportional gain   0.001-->
                    <beta>0.50</beta>    <!-- input value weighing factor     0.50 -->
                    <alpha>0.1</alpha>  <!-- low pass filter weighing factor -->
                    <gamma>0.0</gamma>  <!-- input value weighing factor for -->
                   
                    <Ti>38.0</Ti>       <!-- integrator time      38-->
                    <Td>0.000017</Td>    <!-- derivator time   0.000017-->
                    <u_min>-0.30</u_min> <!-- minimum output clamp   -0.10-->
                    <u_max>0.30</u_max>  <!-- maximum output clamp -  0.10-->
                </config>

	</pid-controller>
        <!-- =============================================================== -->
        <!-- Altitude hold.-->
        <!-- =============================================================== -->

        <!-- =============================================================== -->
	<!-- AGL hold.  2 stage cascade controller. -->
        <!-- =============================================================== -->

	<pi-simple-controller>
		<name>AGL Hold (Altimeter based) Etape1</name>
		<debug>false</debug>
		<enable>
			<prop>/autopilot/locks/altitude</prop>
			<value>agl-hold</value>
		</enable>
		<input>
			<prop>/position/altitude-agl-ft</prop>
		</input>
		<reference>
			<prop>/autopilot/settings/target-agl-ft</prop>
		</reference>
		<output>
			<prop>/autopilot/internal/target-climb-rate-fps</prop>
		</output>
		<config>
			<Kp>0.3</Kp>
			<Ki>0.01</Ki>
			<u_min>-16.67</u_min>
			<u_max>8.33</u_max>
		</config>
	</pi-simple-controller>


	<pid-controller>
		<name>Altitude Hold (Altimeter based) Etape2</name>
		<debug>false</debug>
		<enable>
			<prop>/autopilot/locks/altitude</prop>
			<value>agl-hold</value>
		</enable>
		<input>
			<prop>/velocities/vertical-speed-fps</prop>
		</input>
		<reference>
			<prop>/autopilot/internal/target-climb-rate-fps</prop>
		</reference>
		<output>
			<prop>/controls/flight/elevator-trim</prop>
		</output>
		<config>
			<Kp>-0.002</Kp>
			<beta>1.0</beta>
			<alpha>0.1</alpha>
			<gamma>0.0</gamma>

			<Ti>10.0</Ti>
			<Td>0.00001</Td>
			<u_min>-1.0</u_min>
			<u_max>1.0</u_max>
		</config>
	</pid-controller>
        <!-- =============================================================== -->
        <!-- AGL hold. -->
        <!-- =============================================================== -->

        <!-- =============================================================== -->
	<!-- Glideslope hold. -->
        <!-- =============================================================== -->
	<pid-controller>
		<name>Glideslop Hold</name>
		<debug>false</debug>
		<enable>
			<prop>/autopilot/locks/altitude</prop>
			<value>gs1-hold</value>
		</enable>
		<input>
			<prop>/velocities/vertical-speed-fps</prop>
		</input>
		<reference>
			<prop>/radios/nav[0]/gs-rate-of-climb</prop>
		</reference>
		<output>
			<prop>/controls/flight/elevator-trim</prop>
		</output>
		<config>
			<Kp>-0.002</Kp>
			<beta>1.0</beta>
			<alpha>0.1</alpha>
			<gamma>0.0</gamma>

			<Ti>10.0</Ti>
			<Td>0.00001</Td>
			<u_min>-1.0</u_min>
			<u_max>1.0</u_max>
		</config>
	</pid-controller>
        <!-- =============================================================== -->
        <!-- Glideslope hold. -->
        <!-- =============================================================== -->

        <!-- =============================================================== -->
	<!-- vertical speed hold -->
        <!-- =============================================================== -->
	<pid-controller>
		<name>Vertical Speed Hold</name>
		<debug>false</debug>
		<enable>
			<prop>/autopilot/locks/altitude</prop>
			<value>vertical-speed-hold</value>
		</enable>
		<input>
			<prop>/velocities/vertical-speed-fps</prop>
		</input>
		<reference>
			<prop>/autopilot/settings/vertical-speed-fpm</prop>
			<scale>0.01667</scale>
		</reference>
		<output>
			<prop>/controls/flight/elevator-trim</prop>
		</output>
		<config>
			<Kp>-0.002</Kp>
			<beta>1.0</beta>
			<alpha>0.1</alpha>
			<gamma>0.0</gamma>

			<Ti>10.0</Ti>
			<Td>0.00001</Td>
			<u_min>-1.0</u_min>
			<u_max>1.0</u_max>
		</config>
	</pid-controller>
        <!-- =============================================================== -->
        <!-- vertical speed hold -->
        <!-- =============================================================== -->

	<!-- =============================================================== -->
	<!-- Velocity Modes                                                  -->
	<!-- =============================================================== -->

	<!-- Auto throttle -->
	<pid-controller>
		<name>Auto Throttle (5 sec lookahead)</name>
		<debug>false</debug>
		<enable>
			<prop>/autopilot/locks/speed</prop>
			<value>speed-with-throttle</value>
		</enable>
		<input>
			<prop>/velocities/airspeed-kt</prop>
		</input>
		<reference>
			<prop>/autopilot/settings/target-speed-kt</prop>
		</reference>
		<output>
			<prop>/controls/engines/engine[0]/throttle</prop>
			<prop>/controls/engines/engine[1]/throttle</prop>
			<prop>/controls/engines/engine[2]/throttle</prop>
			<prop>/controls/engines/engine[3]/throttle</prop>
			<prop>/controls/engines/engine[4]/throttle</prop>
			<prop>/controls/engines/engine[5]/throttle</prop>
			<prop>/controls/engines/engine[6]/throttle</prop>
			<prop>/controls/engines/engine[7]/throttle</prop>
		</output>
		<config>
			<Kp>0.1</Kp>
			<beta>1.0</beta>
			<alpha>0.1</alpha>
			<gamma>0.0</gamma>

			<Ti>10.0</Ti>
			<Td>0.00001</Td>
			<u_min>0.0</u_min>
			<u_max>1.0</u_max>
		</config>
	</pid-controller>

        <!-- =============================================================== -->
        <!-- Velocity Modes                                                  -->
	<!-- =============================================================== -->


	<!-- Hold speed by varying pitch trim -->
	<pid-controller>
		<name>Speed hold (vary pitch trim) Etape1</name>
		<debug>false</debug>
		<enable>
			<prop>/autopilot/locks/speed</prop>
			<value>speed-with-pitch-trim</value>
		</enable>
		<input>
			<prop>/autopilot/internal/lookahead-5-sec-airspeed-kt</prop>
		</input>
		<reference>
			<prop>/autopilot/settings/target-speed-kt</prop>
		</reference>
		<output>
			<prop>/autopilot/settings/target-pitch-deg</prop>
		</output>
		<config>
			<Kp>-1.0</Kp>
			<beta>1.0</beta>
			<alpha>0.1</alpha>
			<gamma>0.0</gamma>

			<Ti>1.0</Ti>
			<Td>0.00001</Td>
			<u_min>-15.0</u_min>
			<u_max>15.0</u_max>
		</config>
	</pid-controller>

	<pid-controller>
		<name>Speed hold (vary pitch trim) Etape2</name>
		<debug>false</debug>
		<enable>
			<prop>/autopilot/locks/speed</prop>
			<value>speed-with-pitch-trim</value>
		</enable>
		<input>
			<prop>/orientation/pitch-deg</prop>
		</input>
		<reference>
			<prop>/autopilot/settings/target-pitch-deg</prop>
		</reference>
		<output>
			<prop>/controls/flight/elevator-trim</prop>
		</output>
		<config>
			<Kp>-0.002</Kp>
			<beta>1.0</beta>
			<alpha>0.1</alpha>
			<gamma>0.0</gamma>

			<Ti>1.0</Ti>
			<Td>0.00001</Td>
			<u_min>-1.0</u_min>
			<u_max>1.0</u_max>
		</config>
	</pid-controller>

        <!-- =============================================================== -->
        <!-- Velocity Modes                                                  -->
	<!-- =============================================================== -->

</PropertyList>
