<?xml version="1.0" encoding="ISO-8859-1"?>

<!-- Piaggio P166   : 2016 - BARANGER Emmanuel

          Sources   : https://en.wikipedia.org/wiki/Piaggio_P.166

     Wingspan       :   16.4 m   ( 48 ft 2 in )
     Length         :   11.8 m   ( 39 ft 0 in )
     Height         :    5.0 m   ( 16 ft 5 in )
     Moteurs        : 2 x Lycoming LTP 101-700 turboprops (1200 hp each)
     Empty weight   :   5926 lb  ( 2688  kg   )
     Max speed      : 215,98 kts ( 400 km/h   ) at sea level
-->
<airplane mass="4635" version="YASIM_VERSION_CURRENT">

  <approach speed="50" aoa="4">
    <control-setting axis="/controls/engines/engine[0]/throttle" value="0.4"/>
    <control-setting axis="/controls/engines/engine[0]/mixture" value="1"/>
    <control-setting axis="/controls/engines/engine[0]/propeller-pitch" value="0.5"/>
    <control-setting axis="/controls/engines/engine[1]/throttle" value="0.4"/>
    <control-setting axis="/controls/engines/engine[1]/mixture" value="1"/>
    <control-setting axis="/controls/engines/engine[1]/propeller-pitch" value="0.5"/>
    <!-- <control-setting axis="/controls/flight/flaps" value="1"/> -->
    <control-setting axis="/controls/gear/gear-down" value="1"/>
  </approach>

  <cruise speed="195" alt="9000">
    <control-setting axis="/controls/engines/engine[0]/throttle" value="0.7"/>
    <control-setting axis="/controls/engines/engine[0]/mixture" value="0.7"/>
    <control-setting axis="/controls/engines/engine[0]/propeller-pitch" value="1"/>
    <control-setting axis="/controls/engines/engine[1]/throttle" value="0.7"/>
    <control-setting axis="/controls/engines/engine[1]/mixture" value="0.7"/>
    <control-setting axis="/controls/engines/engine[1]/propeller-pitch" value="1"/>
    <control-setting axis="/controls/flight/flaps" value="0"/>
    <control-setting axis="/controls/gear/gear-down" value="0"/>
  </cruise>

  <cockpit x="2.930622" y="0.3" z="-0.57762"/>

  <!-- Fuselage -->
  <fuselage ax=" 5.860" ay=" 0.000" az="-1.348" bx=" 4.429" by=" 0.000" bz="-1.332" width="1.179" taper="0.20" midpoint="1.0"/>
  <fuselage ax=" 4.429" ay=" 0.000" az="-1.332" bx=" 2.741" by=" 0.000" bz="-1.227" width="1.584" taper="0.75" midpoint="1.0"/>
  <fuselage ax=" 2.741" ay=" 0.000" az="-1.227" bx="-0.155" by=" 0.000" bz="-1.227" width="1.584" taper="1.00" midpoint="1.0"/>
  <fuselage ax="-0.155" ay=" 0.000" az="-1.227" bx="-5.764" by=" 0.000" bz="-0.553" width="1.584" taper="0.05" midpoint="0.0"/>
  
  <!-- Up part -->
  <fuselage ax=" 4.314" ay=" 0.000" az="-1.305" bx=" 2.691" by=" 0.000" bz="-0.828" width="1.584" taper="0.75" midpoint="1.0"/>
  <fuselage ax=" 2.921" ay=" 0.000" az="-0.833" bx="-0.155" by=" 0.000" bz="-0.833" width="1.584" taper="1.00" midpoint="1.0"/>
  <fuselage ax="-0.121" ay=" 0.000" az="-0.823" bx="-5.760" by=" 0.000" bz="-0.487" width="1.584" taper="0.05" midpoint="0.0"/>

  <!-- Engine -->
  <fuselage ax=" 0.925" ay=" 1.908" az="-0.152" bx="-1.081" by=" 1.908" bz="-0.152" width="0.826" taper="0.80" midpoint="0.5"/>
  <fuselage ax=" 0.925" ay="-1.908" az="-0.152" bx="-1.081" by="-1.908" bz="-0.152" width="0.826" taper="0.80" midpoint="0.5"/>
  
  <mstab x="0.551" y="0" z="-0.927"
         chord="2.552"
         length="2.01"
         dihedral="19"
         taper="0.83"
         sweep="5"
         camber="0.005">
         <stall aoa="20" width="1" peak="1.5"/>
         <flap0 start="0.4" end="0.78" lift="1.3" drag="1.4"/>

         <control-input axis="/controls/flight/flaps" control="FLAP0"/>

         <control-output control="FLAP0" prop="/surface-positions/flap-pos-norm"/>

         <control-speed control="FLAP0" transition-time="5"/>
  </mstab>

  <wing x="0.374" y="1.894" z="-0.258"
        chord="2.099"
        length="4.942"
        dihedral="1"
        taper="0.6"
        sweep="4"
        camber="0.005">
        <stall aoa="20" width="1" peak="1.5"/>
        <flap0 start="0.10" end="0.48" lift="1.3" drag="1.4"/>
        <flap1 start="0.48" end="0.95" lift="1.2" drag="1.1"/>

        <control-input axis="/controls/flight/flaps" control="FLAP0"/>
        <control-input axis="/controls/flight/aileron" control="FLAP1" split="true"/>
        <control-input axis="/controls/flight/aileron-trim" control="FLAP1" split="true"/>

        <control-output control="FLAP0" prop="/surface-positions/flap-pos-norm"/>
        <control-output control="FLAP1" side="left" prop="/surface-positions/left-aileron-pos-norm"/>
        <control-output control="FLAP1" side="right" prop="/surface-positions/right-aileron-pos-norm"/>

        <control-speed control="FLAP0" transition-time="5"/>
  </wing>

  <hstab x="-4.772" y="0" z="0.144"
         chord="1.530"
         length="2.54" 
         taper="0.6"
         sweep="2">
         <stall aoa="20" width="1" peak="1.5"/>
         <flap0 start="0.1" end="1" lift="1.2" drag="1.1"/>

         <control-input axis="/controls/flight/elevator" control="FLAP0" />
         <control-input axis="/controls/flight/elevator-trim" control="FLAP0"/>

         <control-output control="FLAP0" prop="/surface-positions/elevator-pos-norm"/>
  </hstab>

  <vstab x="-4.714" y="0" z="-0.348"
         chord="2.052"
         length="2.8" 
         taper="0.44"
         sweep="15">
         <stall aoa="16" width="1" peak="1.5"/>
         <flap0 start="0" end="1" lift="1.2" drag="1.1"/>

         <control-input axis="/controls/flight/rudder" control="FLAP0" invert="true"/>
         <control-input axis="/controls/flight/rudder-trim" control="FLAP0" invert="true"/>

         <control-output control="FLAP0" prop="/surface-positions/rudder-pos-norm"/>
  </vstab>

  <!-- Moteurs       : Lycoming LTS101
  
        Source       : https://en.wikipedia.org/wiki/Lycoming_LTS101
  
        type         : Turboshaft
        weight       : 241 lb (109 kg)
        Compression  : 8.4:1
  -->
  <propeller x="-0.354" y="1.917" z="-0.125"
             mass="241" 
             moment="2.5" 
             radius="1.25" 
             cruise-speed="195" 
             cruise-rpm="2500" 
             cruise-power="950" 
             cruise-alt="6000"
             takeoff-power="1200"
             takeoff-rpm="2700"> 
             <actionpt x="-1.320" y="1.901" z="-0.134"/>
             <control-input control="ADVANCE" axis="/controls/engines/engine[0]/propeller-pitch"/>
             <piston-engine eng-power="1200" 
                            eng-rpm="2700"
                            compression="8.4"> 
                            <control-input control="THROTTLE" axis="/controls/engines/engine[0]/throttle"/>
                            <control-input control="STARTER"  axis="/controls/engines/engine[0]/starter"/>
                            <control-input control="MAGNETOS" axis="/controls/engines/engine[0]/magnetos"/>
                            <control-input control="MIXTURE"  axis="/controls/engines/engine[0]/mixture"/>
             </piston-engine>
  </propeller>

  <propeller x="-0.354" y="-1.917" z="-0.125"
             mass="241" 
             moment="2.5" 
             radius="1.25" 
             cruise-speed="195" 
             cruise-rpm="2500" 
             cruise-power="950" 
             cruise-alt="6000"
             takeoff-power="1200"
             takeoff-rpm="2700"> 
             <actionpt x="-1.320" y="-1.901" z="-0.134"/>
             <control-input control="ADVANCE" axis="/controls/engines/engine[1]/propeller-pitch"/>
             <piston-engine eng-power="1200" 
                            eng-rpm="2700"
                            compression="8.4">
                            <control-input control="THROTTLE" axis="/controls/engines/engine[1]/throttle"/>
                            <control-input control="STARTER"  axis="/controls/engines/engine[1]/starter"/>
                            <control-input control="MAGNETOS" axis="/controls/engines/engine[1]/magnetos"/>
                            <control-input control="MIXTURE"  axis="/controls/engines/engine[1]/mixture"/>
             </piston-engine>
  </propeller>

  <!-- Noze wheel -->
  <gear x="4.81994" y="0" z="-2.48515" 
        compression="0.1" 
        retract-time="7" 
        on-water="0" 
        on-solid="1"
        spring="1" 
        damp="2">
        <control-input axis="/controls/flight/rudder" control="STEER" src0="-1.0" src1="1.0" dst0="-0.2" dst1="0.2"/>
        <control-input axis="/controls/gear/gear-down" control="EXTEND"/>
        <control-speed control="EXTEND" transition-time="5"/>
        <control-output control="EXTEND" prop="/gear/gear[0]/position-norm"/>
  </gear>

  <!-- Left wheel -->
  <gear x="0.24709" y="1.36840" z="-2.42512"
        compression="0.2" 
        retract-time="7"
        on-water="0" 
        on-solid="1" 
        spring="1" 
        damp="2">
        <control-input axis="/controls/gear/brake-left" control="BRAKE"/>
        <control-input axis="/controls/gear/brake-parking" control="BRAKE"/>
        <control-input axis="/controls/gear/gear-down" control="EXTEND"/>
        <control-speed control="EXTEND" transition-time="5"/>
        <control-output control="EXTEND" prop="/gear/gear[1]/position-norm"/>
  </gear>

  <!-- Right wheel -->
  <gear x="0.24709" y="-1.36840" z="-2.42512"
        compression="0.2" 
        retract-time="7" 
        on-water="0" 
        on-solid="1"
        spring="1" 
        damp="2">
        <control-input axis="/controls/gear/brake-right" control="BRAKE"/>
        <control-input axis="/controls/gear/brake-parking" control="BRAKE"/>
        <control-input axis="/controls/gear/gear-down" control="EXTEND"/>
        <control-speed control="EXTEND" transition-time="3.5"/>
        <control-output control="EXTEND" prop="/gear/gear[2]/position-norm"/>
  </gear>

  <!-- 809.865 lbs = 135 gals -->
  <tank x="1.03" y=" 2.5" z="-0.2" capacity="809.865"/>
  <tank x="1.03" y="-2.5" z="-0.2" capacity="809.865"/>

  <!-- Mass displacment -->
  <ballast x="4" y="0" z="-2" mass="980"/>

</airplane>
