<!DOCTYPE flight_plan SYSTEM "../flight_plan.dtd">

<flight_plan alt="240" ground_alt="170" lat0="27.0936" lon0="77.9145" max_dist_from_home="650" name="MAV08" security_height="25">
  <header>
#include "datalink.h"
</header>
  <waypoints>
    <waypoint name="HOME" x="237.4" y="393.5"/>
    <waypoint name="STDBY" x="238.3" y="13.9"/>
    <waypoint name="1" x="438.4" y="574.7"/>
    <waypoint name="2" x="443.0" y="420.6"/>
    <waypoint name="MOB" x="504.2" y="-66.0"/>
    <waypoint name="S1" x="532.2" y="333.2"/>
    <waypoint name="S2" x="628.2" y="418.5"/>
    <waypoint alt="195.0" name="AF" x="359.6" y="-76.6"/>
    <waypoint name="_BASELEG" x="502.4" y="-21.4"/>
    <waypoint name="CLIMB" x="504.7" y="56.4"/>
    <waypoint name="A" x="177.5" y="49.5"/>
    <waypoint name="B" x="17.0" y="122.4"/>
    <waypoint name="C" x="-86.3" y="297.4"/>
    <waypoint name="D" x="-25.4" y="489.8"/>
    <waypoint name="E" x="33.9" y="677.3"/>
    <waypoint name="F1" x="89.3" y="856.0"/>
    <waypoint name="F2" x="139.2" y="846.1"/>
    <waypoint name="RT" x="116.3" y="978.7"/>
    <waypoint alt="165.0" name="TD" x="239.9" y="-72.1"/>
    <waypoint name="N" x="159.0" y="847.0"/>
    <waypoint name="WAIT" x="91.9" y="494.7"/>
  </waypoints>
  <sectors>
    <kml file="MAV08_no_fly_boundaries.kml"/>
    <kml file="MAV08_legs.kml"/>
  </sectors>
  <exceptions>
      <exception cond="datalink_time > 30" deroute="Standby"/>
      <exception cond="9.7 > PowerVoltage()" deroute="Standby"/>
  </exceptions>
  <blocks>
    <block name="Holding point">
      <set value="1" var="autopilot.kill_throttle"/>
      <attitude roll="0" throttle="0" vmode="throttle"/>
    </block>
    <block name="Takeoff" strip_button="Takeoff (wp CLIMB)" strip_icon="takeoff.png">
      <exception cond="GetPosAlt() > GetAltRef()+25" deroute="Standby"/>
      <set value="0" var="autopilot.kill_throttle"/>
      <set value="0" var="autopilot_flight_time"/>
      <go from="HOME" pitch="15" throttle="1.0" vmode="throttle" wp="CLIMB"/>
    </block>
    <block name="Standby" strip_button="Standby" strip_icon="home.png">
      <circle radius="nav_radius" wp="STDBY"/>
    </block>
    <block name="Wait" strip_button="W">
      <circle radius="nav_radius" wp="WAIT"/>
    </block>
    <block name="Go to North" strip_button="N">
      <go from="A" hmode="route" wp="B"/>
      <go from="B" hmode="route" wp="C"/>
      <go from="C" hmode="route" wp="D"/>
      <go from="D" hmode="route" wp="E"/>
      <go from="E" hmode="route" wp="F1"/>
      <circle radius="nav_radius" wp="N"/>
    </block>
    <block name="Go to South" strip_button="S">
      <go from="F2" hmode="route" wp="E"/>
      <go from="E" hmode="route" wp="D"/>
      <go from="D" hmode="route" wp="C"/>
      <go from="C" hmode="route" wp="B"/>
      <go from="B" hmode="route" wp="A"/>
      <circle radius="nav_radius" wp="A"/>
    </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)"/>
      <set value="DEFAULT_CIRCLE_RADIUS" var="nav_radius"/>
      <circle radius="nav_radius" wp="MOB"/>
    </block>
    <block name="Line 1-2" strip_button="Line (wp 1-2)" strip_icon="line.png">
      <call fun="nav_line_setup()"/>
      <call fun="nav_line_run(WP_1, WP_2, nav_radius)"/>
    </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"/>
      <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>
  </blocks>
</flight_plan>
