<?xml version="1.0" encoding="UTF-8"?>
<!--
**************************************************************************

Beagle Pup Flight Controls (JSBSim)

Copyright (c) 2015 Richard Senior

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 2 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/>.

**************************************************************************
-->

<flight_control>

  <channel name="Pitch">

    <summer name="Pitch Trim Sum">
      <input>fcs/elevator-cmd-norm</input>
      <input>fcs/pitch-trim-cmd-norm</input>
      <clipto>
        <min>-1</min>
        <max> 1</max>
      </clipto>
    </summer>

    <kinematic name="Pitch Trim Kinematic">
      <input>fcs/pitch-trim-sum</input>
      <traverse>
        <setting>
          <position>-1</position>
          <time>0.2</time>
        </setting>
        <setting>
          <position>1</position>
          <time>0.2</time>
        </setting>
      </traverse>
      <output>fcs/pitch-trim-kinematic</output>
    </kinematic>

    <aerosurface_scale name="Elevator Control">
      <input>fcs/pitch-trim-kinematic</input>
      <gain>1.0</gain>
      <range>
        <min>-30</min>
        <max> 20</max>
      </range>
      <output>fcs/elevator-pos-deg</output>
    </aerosurface_scale>

    <aerosurface_scale name="elevator normalization">
      <input>fcs/elevator-pos-deg</input>
      <domain>
        <min>-30</min>
        <max> 20</max>
      </domain>
      <range>
        <min>-1</min>
        <max> 1</max>
      </range>
      <output>fcs/elevator-pos-norm</output>
    </aerosurface_scale>

  </channel>

  <channel name="Roll">

    <summer name="Roll Trim Sum">
      <input>fcs/aileron-cmd-norm</input>
      <input>fcs/roll-trim-cmd-norm</input>
      <clipto>
        <min>-1</min>
        <max> 1</max>
      </clipto>
    </summer>

    <kinematic name="Roll Trim Kinematic">
      <input>fcs/roll-trim-sum</input>
      <traverse>
        <setting>
          <position>-1</position>
          <time>0.2</time>
        </setting>
        <setting>
          <position>1</position>
          <time>0.2</time>
        </setting>
      </traverse>
      <output>fcs/roll-trim-kinematic</output>
    </kinematic>

    <aerosurface_scale name="Left Aileron Control">
      <input>fcs/roll-trim-kinematic</input>
      <range>
        <min>-28</min>
        <max> 12</max>
      </range>
      <output>fcs/left-aileron-pos-deg</output>
    </aerosurface_scale>

    <aerosurface_scale name="Left Aileron Normalization">
      <input>fcs/left-aileron-pos-deg</input>
      <domain>
        <min>-28</min>
        <max> 12</max>
      </domain>
      <range>
        <min>-1</min>
        <max> 1</max>
      </range>
      <output>fcs/left-aileron-pos-norm</output>
    </aerosurface_scale>

    <aerosurface_scale name="Right Aileron Control">
      <input>fcs/roll-trim-kinematic</input>
      <range>
        <min>-28</min>
        <max> 12</max>
      </range>
      <output>fcs/right-aileron-pos-deg</output>
    </aerosurface_scale>

    <aerosurface_scale name="Right Aileron Normalization">
      <input>fcs/right-aileron-pos-deg</input>
      <domain>
        <min>-28</min>
        <max> 12</max>
      </domain>
      <range>
        <min>-1</min>
        <max> 1</max>
      </range>
      <output>fcs/right-aileron-pos-norm</output>
    </aerosurface_scale>

  </channel>

  <channel name="Yaw">

    <summer name="Rudder Command Sum">
      <input>fcs/rudder-cmd-norm</input>
      <input>fcs/yaw-trim-cmd-norm</input>
      <clipto>
        <min>-1</min>
        <max> 1</max>
      </clipto>
    </summer>

    <kinematic name="Rudder Kinematic">
      <input>fcs/rudder-command-sum</input>
      <traverse>
        <setting>
          <position>-1</position>
          <time>0.2</time>
        </setting>
        <setting>
          <position>1</position>
          <time>0.2</time>
        </setting>
      </traverse>
      <output>fcs/rudder-trim-kinematic</output>
    </kinematic>

    <aerosurface_scale name="Rudder Control">
      <input>fcs/rudder-trim-kinematic</input>
      <range>
        <min>-25</min>
        <max> 25</max>
      </range>
      <output>fcs/rudder-pos-deg</output>
    </aerosurface_scale>

    <aerosurface_scale name="Rudder Normalization">
      <input>fcs/rudder-pos-deg</input>
      <domain>
        <min>-25</min>
        <max> 25</max>
      </domain>
      <range>
        <min>-1</min>
        <max> 1</max>
      </range>
      <output>fcs/rudder-pos-norm</output>
    </aerosurface_scale>

  </channel>

  <channel name="Flaps">
    <kinematic name="Flaps Control">
      <input>fcs/flap-cmd-norm</input>
      <traverse>
        <setting>
          <position> 0</position>
          <time>     0 </time>
        </setting>
        <setting>
          <position>15</position>
          <time>     3 </time>
        </setting>
        <setting>
          <position>39.5</position>
          <time>     5</time>
        </setting>
      </traverse>
      <output>fcs/flap-pos-deg</output>
    </kinematic>

    <aerosurface_scale name="Flap Normalization">
      <input>fcs/flap-pos-deg</input>
      <domain>
        <min>0</min>
        <max>39.5</max>
      </domain>
      <range>
        <min>0</min>
        <max>1</max>
      </range>
      <output>fcs/flap-pos-norm</output>
    </aerosurface_scale>

  </channel>

</flight_control>
