<?xml version="1.0"?>
<PropertyList>

<!-- ======  Lateral Modes  ====== -->

    <pid-controller>
        <name>ROLL hold</name>
        <debug>false</debug>
        <enable>
            <property>autopilot/locks/heading</property>
            <value>ROL</value>
        </enable>
        <input>
            <property>orientation/roll-deg</property>
        </input>
        <reference>
            <property>autopilot/settings/target-roll-deg</property>
        </reference>
        <output>
            <prop>autopilot/internal/roll-filter</prop>
        </output>
        <config>
            <Kp>0.5</Kp>
            <beta>1.0</beta>
            <alpha>0.1</alpha>
            <gamma>0.0</gamma>
            <Ti>1.0</Ti>
            <Td>0.00001</Td>
            <min>-27</min>
            <max>27</max>
        </config>
    </pid-controller>

    <pi-simple-controller>
        <name>Heading Bug Hold</name>
        <debug>false</debug>
        <enable>
            <condition>
                <equals>
                    <property>autopilot/locks/heading</property>
                    <value>HDG</value>
                </equals>
            </condition>
        </enable>
        <input>
            <prop>autopilot/internal/heading-bug-error-deg</prop>
        </input>
        <reference>
            <value>0.0</value>
        </reference>
        <output>
            <prop>autopilot/internal/roll-filter</prop>
        </output>
        <config>
            <Kp>-1.5</Kp>
            <Ki>0.0</Ki>
            <min>
                <property>autopilot/settings/bank-limit</property>
                <scale>-1</scale>
            </min>
            <max>
                <property>autopilot/settings/bank-limit</property>
            </max>
        </config>
    </pi-simple-controller>

    <pid-controller>
        <name>Nav1</name>
        <debug>false</debug>
        <enable>
            <prop>autopilot/locks/heading</prop>
            <value>VOR</value>
        </enable>
        <input>
            <prop>autopilot/internal/ap_crs</prop>
        </input>
        <reference>
            <value>0.0</value>
        </reference>
        <output>
            <prop>autopilot/internal/roll-filter</prop>
        </output>
        <config>
            <Kp>-1.5</Kp>
            <beta>1.0</beta>
            <alpha>0.1</alpha>
            <gamma>0.0</gamma>
            <Ti>10</Ti>
            <Td>0.0</Td>
            <min>
                <value>-27</value>
            </min>
            <max>
                <value>27</value>
            </max>
        </config>
    </pid-controller>

    <pi-simple-controller>
        <name>Loc</name>
        <debug>false</debug>
        <enable>
            <prop>autopilot/locks/heading</prop>
            <value>LOC</value>
        </enable>
        <input>
            <prop>autopilot/internal/course-offset</prop>
        </input>
        <reference>
            <value>0.0</value>
        </reference>
        <output>
            <prop>autopilot/internal/roll-filter</prop>
        </output>
        <config>
            <Kp>-1.5</Kp>
            <Ki>0.0</Ki>
            <min>-30</min>
            <max>30</max>
        </config>
    </pi-simple-controller>

    <pi-simple-controller>
        <name>Lnav</name>
        <debug>false</debug>
        <enable>
            <prop>autopilot/locks/heading</prop>
            <value>LNAV</value>
        </enable>
        <input>
            <prop>autopilot/internal/ap_crs</prop>
        </input>
        <reference>
            <value>0.0</value>
        </reference>
        <output>
            <prop>autopilot/internal/roll-filter</prop>
        </output>
        <config>
            <Kp>-2.0</Kp>
            <Ki>0.0</Ki>
            <min>-30</min>
            <max>30</max>
        </config>
    </pi-simple-controller>


    <filter>
        <name>roll command</name>
        <debug>false</debug>
        <feedback-if-disabled>true</feedback-if-disabled>
        <initialize-to>output</initialize-to>
        <enable>
            <condition>
                <property>autopilot/locks/FD-status</property>
            </condition>
        </enable>
        <input>
            <property>autopilot/internal/roll-filter</property>
        </input>
        <output>autopilot/internal/roll-bars</output>
        <type>noise-spike</type>
        <max-rate-of-change>7</max-rate-of-change>
    </filter>

    <pid-controller>
        <name>Aileron Control</name>
        <debug>false</debug>
        <enable>
            <prop>autopilot/locks/AP-status</prop>
            <value>AP ENG</value>
        </enable>
        <input>
            <prop>/orientation/roll-deg</prop>
        </input>
        <reference>
            <prop>autopilot/internal/roll-bars</prop>
        </reference>
        <output>
            <prop>/controls/flight/aileron</prop>
        </output>
        <config>
            <Kp>0.15</Kp>
            <beta>1.0</beta>
            <alpha>0.1</alpha>
            <gamma>0.0</gamma>
            <Ti>10.0</Ti>
            <Td>0.00001</Td>
            <min>-1</min>
            <max>1</max>
        </config>
    </pid-controller>


<!-- ======= Vertical Modes ======= -->

    <filter>
        <name>pitch control</name>
        <debug>false</debug>
        <feedback-if-disabled>true</feedback-if-disabled>
        <initialize-to>output</initialize-to>
        <enable>
            <condition>
                <equals>
                    <property>autopilot/locks/altitude</property>
                    <value>PIT</value>
                </equals>
            </condition>
        </enable>
        <input>
            <property>autopilot/settings/target-pitch-deg</property>
        </input>
        <output>autopilot/internal/pitch-filter</output>
        <type>noise-spike</type>
        <max-rate-of-change>10.0</max-rate-of-change>
    </filter>

    <pi-simple-controller>
        <name>Altitude Hold 1</name>
        <debug>false</debug>
        <enable>
            <prop>/autopilot/locks/altitude</prop>
            <value>ALT</value>
        </enable>
        <input>
            <prop>instrumentation/altimeter/indicated-altitude-ft</prop>
        </input>
        <reference>
            <prop>/autopilot/settings/asel</prop>
            <scale>100</scale>
        </reference>
        <output>
            <prop>/autopilot/internal/target-climb-rate-fps</prop>
        </output>
        <config>
            <Kp>0.1</Kp>
            <Ki>0.0</Ki>
            <min>-15.0</min>
            <max>66.0</max>
        </config>
    </pi-simple-controller>

    <pid-controller>
        <name>Altitude 2</name>
        <debug>false</debug>
        <enable>
            <prop>/autopilot/locks/altitude</prop>
            <value>ALT</value>
        </enable>
        <input>
            <prop>velocities/vertical-speed-fps</prop>
        </input>
        <reference>
            <prop>autopilot/internal/target-climb-rate-fps</prop>
        </reference>
        <output>
            <prop>/autopilot/internal/pitch-filter</prop>
        </output>
        <config>
            <Kp>0.3</Kp>
            <beta>1.0</beta>
            <alpha>0.1</alpha>
            <gamma>0.0</gamma>
            <Ti>10.0</Ti>
            <Td>0.00001</Td>
            <min>-10</min>
            <max>20</max>
        </config>
    </pid-controller>

    <pi-simple-controller>
        <name>GS</name>
        <debug>false</debug>
        <enable>
            <condition>
                <equals>
                    <property>/autopilot/locks/altitude</property>
                    <value>GS</value>
                </equals>
            </condition>
        </enable>
        <input>
            <prop>velocities/vertical-speed-fps</prop>
        </input>
        <reference>
            <prop>autopilot/internal/gs-rate-fps</prop>
        </reference>
        <output>
            <prop>autopilot/internal/pitch-filter</prop>
        </output>
        <config>
            <Kp>1</Kp>
            <Ki>0.0</Ki>
            <min>-10.0</min>
            <max>15.0</max>
        </config>
    </pi-simple-controller>

    <pid-controller>
        <name>Vertical Speed Hold</name>
        <debug>false</debug>
        <enable>
            <prop>/autopilot/locks/altitude</prop>
            <value>VS</value>
        </enable>
        <input>
            <prop>/autopilot/internal/vert-speed-fpm</prop>
        </input>
        <reference>
            <prop>/autopilot/settings/target-vs</prop>
            </reference>
        <output>
            <prop>autopilot/internal/pitch-filter</prop>
        </output>
        <config>
            <Kp>0.005</Kp>
            <beta>1.0</beta>
            <alpha>0.1</alpha>
            <gamma>0.0</gamma>
            <Ti>10.0</Ti>
            <Td>0.000001</Td>
            <min>-10</min>
            <max>20</max>
        </config>
    </pid-controller>

    <pid-controller>
        <name>Vnav Hold 1</name>
        <debug>false</debug>
        <enable>
            <prop>/autopilot/locks/altitude</prop>
            <value>VALT</value>
        </enable>
        <input>
            <prop>instrumentation/altimeter/indicated-altitude-ft</prop>
        </input>
        <reference>
            <prop>instrumentation/gps/wp/wp[1]/altitude-ft</prop>
        </reference>
        <output>
            <prop>/autopilot/internal/target-climb-rate-fps</prop>
        </output>
        <config>
            <Kp>0.25</Kp>
            <beta>1.0</beta>
            <alpha>0.1</alpha>
            <gamma>0.0</gamma>
            <Ti>10.0</Ti>
            <Td>0.000001</Td>
            <min>-30</min>
            <max>66</max>
        </config>
    </pid-controller>

    <pi-simple-controller>
        <name>Vnav 2</name>
        <debug>false</debug>
        <enable>
            <prop>/autopilot/locks/altitude</prop>
            <value>VALT</value>
        </enable>
        <input>
            <prop>velocities/vertical-speed-fps</prop>
        </input>
        <reference>
            <prop>autopilot/internal/target-climb-rate-fps</prop>
        </reference>
        <output>
            <prop>autopilot/internal/pitch-filter</prop>
        </output>
        <config>
            <Kp>0.15</Kp>
            <Ki>0.0</Ki>
            <min>-20</min>
            <max>20</max>
        </config>
    </pi-simple-controller>

    <pi-simple-controller>
        <name>ias</name>
        <debug>false</debug>
        <enable>
            <condition>
                <equals>
                    <property>/autopilot/locks/altitude</property>
                    <value>IAS</value>
                </equals>
            </condition>
        </enable>
        <input>
            <prop>instrumentation/airspeed-indicator/indicated-speed-kt</prop>
        </input>
        <reference>
            <prop>autopilot/settings/target-speed-kt</prop>
        </reference>
        <output>
            <prop>autopilot/internal/pitch-filter</prop>
        </output>
        <config>
            <Kp>-0.25</Kp>
            <Ki>0.0</Ki>
            <min>-10</min>
            <max>20</max>
        </config>
    </pi-simple-controller>

    <pi-simple-controller>
        <name>mach hold</name>
        <debug>false</debug>
        <enable>
            <condition>
                <equals>
                    <property>/autopilot/locks/altitude</property>
                    <value>MACH</value>
                </equals>
            </condition>
        </enable>
        <input>
            <prop>instrumentation/airspeed-indicator/indicated-mach</prop>
        </input>
        <reference>
            <prop>autopilot/settings/target-speed-mach</prop>
        </reference>
        <output>
            <prop>autopilot/internal/pitch-filter</prop>
        </output>
        <config>
            <Kp>-5.0</Kp>
            <Ki>0.0</Ki>
            <min>-10</min>
            <max>20</max>
        </config>
    </pi-simple-controller>

    <filter>
        <name>pitch command</name>
        <debug>false</debug>
        <feedback-if-disabled>true</feedback-if-disabled>
        <initialize-to>output</initialize-to>
        <enable>
            <condition>
                <property>autopilot/locks/FD-status</property>
            </condition>
        </enable>
        <input>
            <property>autopilot/internal/pitch-filter</property>
        </input>
        <output>autopilot/internal/pitch-bars</output>
        <type>noise-spike</type>
        <max-rate-of-change>2.0</max-rate-of-change>
    </filter>

    <pid-controller>
        <name>Elevator Trim Output</name>
        <debug>false</debug>
        <enable>
            <prop>autopilot/locks/AP-status</prop>
            <value>AP ENG</value>
        </enable>
        <input>
            <prop>instrumentation/attitude-indicator/indicated-pitch-deg</prop>
        </input>
        <reference>
            <prop>autopilot/internal/pitch-bars</prop>
        </reference>
        <output>
            <prop>controls/flight/elevator-trim</prop>
        </output>
        <config>
            <Kp>-0.010</Kp>
            <beta>1.0</beta>
            <alpha>0.1</alpha>
            <gamma>0.0</gamma>
            <Ti>10.0</Ti>
            <Td>0.01</Td>
            <min>-1</min>
            <max>1</max>
        </config>
    </pid-controller>

</PropertyList>

