<!DOCTYPE flight_plan SYSTEM "flight_plan.dtd">

<flight_plan alt="75" ground_alt="0" lat0="43.4622" lon0="1.2729" max_dist_from_home="1500" name="Versatile" qfu="270" security_height="25">
  <header>
#include "subsystems/datalink/datalink.h"
</header>
  <waypoints>
    <waypoint name="HOME" x="0" y="0"/>
    <waypoint name="STDBY" x="20" y="80"/>
    <waypoint name="1" x="44.8" y="102.2"/>
    <waypoint name="2" x="-63.5" y="122.9"/>
    <waypoint name="MOB" x="-11.5" y="-21.2"/>
    <waypoint name="S1" x="-151.6" y="80.4"/>
    <waypoint name="S2" x="180.1" y="214.9"/>
    <waypoint alt="30" name="AF" x="200" y="-10"/>
    <waypoint alt="0" name="TD" x="80.0" y="20.0"/>
    <waypoint name="BASELEG" x="26.9" y="-23.0"/>
    <waypoint name="_1" x="-100" y="0"/>
    <waypoint name="_2" x="-100" y="200"/>
    <waypoint name="_3" x="100" y="200"/>
    <waypoint name="_4" x="100" y="0"/>
    <waypoint name="CLIMB" x="-122.5" y="35.4"/>
  </waypoints>
  <sectors>
    <sector name="Square">
      <corner name="_1"/>
      <corner name="_2"/>
      <corner name="_3"/>
      <corner name="_4"/>
    </sector>
  </sectors>
  <exceptions/>
  <blocks>
    <block name="Wait GPS">
      <set value="1" var="kill_throttle"/>
      <while cond="!GpsFixValid()"/>
    </block>
    <block name="Geo init">
      <while cond="LessThan(NavBlockTime(), 10)"/>
      <call fun="NavSetGroundReferenceHere()"/>
    </block>
    <block name="Holding point">
      <set value="1" var="kill_throttle"/>
      <attitude roll="0" throttle="0" vmode="throttle"/>
    </block>
    <block name="Takeoff" strip_icon="takeoff.png" strip_button="Takeoff (wp CLIMB)">
      <exception cond="GetPosAlt() > GetAltRef()+25" deroute="Standby"/>
      <set value="0" var="kill_throttle"/>
      <go wp="CLIMB"/>
    </block>
    <block name="Standby" strip_button="Standby" strip_icon="home.png">
      <circle radius="nav_radius" wp="STDBY"/>
    </block>
    <block name="Figure 8 around wp 1" strip_button="Figure 8 (wp 1-2)" strip_icon="eight.png">
      <eight center="1" radius="nav_radius" turn_around="2"/>
    </block>
    <block name="Oval 1-2" strip_button="Oval (wp 1-2)" strip_icon="oval.png">
      <oval p1="1" p2="2" radius="nav_radius"/>
    </block>
    <block name="MOB" strip_button="Circle around here" strip_icon="mob.png">
      <call fun="NavSetWaypointHere(WP_MOB)"/>
      <circle radius="100" wp="MOB"/>
    </block>
    <block name="Auto pitch (circle wp 1)">
      <circle pitch="auto" radius="75" throttle="0.7" wp="1"/>
    </block>
    <block name="Climb 75% throttle">
      <circle pitch="10" radius="50+(GetPosAlt()-GetAltRef())/2" throttle="0.75" until="(10 > PowerVoltage()) || (GetPosAlt() > GetAltRef()+ 1350)" vmode="throttle" wp="1"/>
    </block>
    <block name="Climb 0m/s">
      <circle climb="0" radius="nav_radius" until="10 > PowerVoltage()" vmode="climb" wp="1"/>
    </block>
    <block name="Climb 1m/s">
      <circle climb="1" radius="50+(GetPosAlt()-GetAltRef())/2" until="10 > PowerVoltage()" vmode="climb" wp="1"/>
    </block>
    <block name="Climb nav_climb m/s">
      <circle climb="nav_climb" radius="nav_radius" until="(10 > PowerVoltage()) || (GetPosAlt() > GetAltRef()+ 1350)" vmode="climb" wp="1"/>
    </block>
    <block name="Descent 0% throttle">
      <circle pitch="-5" radius="50+(GetPosAlt()-GetAltRef())/2" throttle="0.0" until="GetAltRef()+50 > GetPosAlt()" vmode="throttle" wp="1"/>
      <deroute block="Standby"/>
    </block>
    <block name="Route 1-2">
      <go approaching_time="0" from="1" hmode="route" wp="2"/>
    </block>
    <block name="Stack wp 2">
      <circle radius="75" wp="2"/>
    </block>
    <block name="Route 2-1">
      <go approaching_time="0" from="2" hmode="route" wp="1"/>
    </block>
    <block name="Stack wp 1">
      <circle radius="75" wp="1"/>
    </block>
    <block name="Glide 1-2">
      <go from="1" hmode="route" vmode="glide" wp="2"/>
      <deroute block="Standby"/>
    </block>
    <block name="Survey S1-S2" strip_button="Survey (wp S1-S2)" strip_icon="survey.png">
      <survey_rectangle grid="150" wp1="S1" wp2="S2"/>
    </block>
    <block name="Land Right AF-TD" strip_button="Land right (wp AF-TD)" strip_icon="land-right.png">
      <set value="DEFAULT_CIRCLE_RADIUS" var="nav_radius"/>
      <deroute block="land"/>
    </block>
    <block name="Land Left AF-TD" strip_button="Land left (wp AF-TD)" strip_icon="land-left.png">
      <set value="-DEFAULT_CIRCLE_RADIUS" var="nav_radius"/>
      <deroute block="land"/>
    </block>
    <block name="land">
      <call fun="nav_compute_baseleg(WP_AF, WP_TD, WP_BASELEG, nav_radius)"/>
      <circle radius="nav_radius" until="NavCircleCount() > 0.5" wp="BASELEG"/>
      <set value="V_CTL_AUTO_THROTTLE_MIN_CRUISE_THROTTLE" var="v_ctl_auto_throttle_cruise_throttle"/>
      <circle radius="nav_radius" until="NavQdrCloseTo(DegOfRad(baseleg_out_qdr)-(nav_radius/fabs(nav_radius))*10) && 10 > fabs(GetPosAlt() - WaypointAlt(WP_BASELEG))" wp="BASELEG"/>
    </block>
    <block name="final">
      <exception cond="GetAltRef() + 10 > GetPosAlt()" deroute="flare"/>
      <go from="AF" hmode="route" vmode="glide" wp="TD"/>
    </block>
    <block name="flare">
      <go approaching_time="0" from="AF" hmode="route" throttle="0.0" vmode="throttle" wp="TD"/>
      <attitude roll="0.0" throttle="0.0" until="FALSE" vmode="throttle"/>
    </block>
    <block name="Steps roll -10, +10">
      <while cond="TRUE">
        <attitude alt="250" roll="10.0" until=" stage_time > 6" vmode="alt"/>
        <attitude alt="250" roll="-10.0" until="stage_time > 6" vmode="alt"/>
      </while>
    </block>
    <block name="Steps roll -20, +20">
      <while cond="TRUE">
        <attitude alt="250" roll="20.0" until=" stage_time > 3" vmode="alt"/>
        <attitude alt="250" roll="-20.0" until="stage_time > 3" vmode="alt"/>
      </while>
    </block>
    <block name="Steps pitch -10, +10">
      <while cond="TRUE">
        <attitude alt="250" pitch="10" roll="0.0" until=" stage_time > 2" vmode="alt"/>
        <attitude alt="250" pitch="-10" roll="0.0" until=" stage_time > 2" vmode="alt"/>
      </while>
    </block>
    <block name="Heading 30">
      <heading alt="GetAltRef()+50" course="30" until="FALSE"/>
    </block>
  </blocks>
</flight_plan>
