<!DOCTYPE module SYSTEM "module.dtd">

<module name="gvf" dir="guidance/gvf">
  <doc>
    <description>Guidance algorithm for tracking smooth trajectories. The algorithm is based on the idea of stearing the vehicle to a vector field that smoothly converges to the desired trajectory.
For more details we refer to https://wiki.paparazziuav.org/wiki/Module/guidance_vector_field .
    </description>
    <section name="Ellipse" prefix="GVF_ELLIPSE_">
      <define name="KE" value="1" description="Gain for the aggresivity of the gvf"/>
      <define name="KN" value="1" description="Gain for the alignment of the vehicle with the gvf"/>
      <define name="A" value="80" description="Horizontal axis length of the ellipse" unit="m"/>
      <define name="B" value="80" description="Vertical axis length of the ellipse" unit="m"/>
      <define name="ALPHA" value="0" description="Rotation of the horizontal axis" unit="deg"/>
    </section>
    <section name="Line" prefix="GVF_LINE_">
      <define name="KE" value="1" description="Gain for the aggresivity of the gvf"/>
      <define name="KN" value="1" description="Gain for the alignment of the vehicle with the gvf"/>
      <define name="HEADING" value="0" description="Desired heading for the line (0 is North, 90 is East)" unit="deg"/>
      <define name="D1" value="0" description="Extra distance (w.r.t. the 1st point) to be travelled before turning around for the segment_loop" unit="m"/>
      <define name="D2" value="0" description="Extra distance (w.r.t. the 2nd point) to be travelled before turning around for the segment_loop" unit="m"/>
    </section>
    <section name="Sinusoidal" prefix="GVF_SIN_">
      <define name="KE" value="1" description="Gain for the aggresivity of the gvf"/>
      <define name="KN" value="1" description="Gain for the alignment of the vehicle with the gvf"/>
      <define name="ALPHA" value="0" description="Desired heading for the line (0 is East, 90 is North)" unit="deg"/>
      <define name="W" value="0" description="Frequency for the sinusoidal y=Asin(Wx + OFF)" unit="rad/m"/>
      <define name="OFF" value="0" description="Offset for the sinusoidal y=Asin(Wx + OFF)" unit="rad"/>
      <define name="A" value="0" description="Amplitude for the sinusoidal y=Asin(Wx + OFF)" unit="m"/>
    </section>
  </doc>

  <settings name="GVF">
    <dl_settings>
      <dl_settings NAME="GVF">
        <dl_settings NAME="Control">
          <dl_setting MAX="1" MIN="-1" STEP="2" VAR="gvf_control.s" shortname = "direction"/>
        </dl_settings>
        <dl_settings NAME="Ellipse">
          <dl_setting MAX="5" MIN="0.0" STEP="0.01" VAR="gvf_ellipse_par.ke" shortname="ell_ke" param="GVF_ELLIPSE_KE"/>
          <dl_setting MAX="5" MIN="0.0" STEP="0.01" VAR="gvf_ellipse_par.kn" shortname="ell_kn" param="GVF_ELLIPSE_KN"/>
          <dl_setting MAX="150" MIN="0.0" STEP="10" VAR="gvf_ellipse_par.a" shortname="ell_a" param="GVF_ELLIPSE_A"/>
          <dl_setting MAX="150" MIN="0.0" STEP="10" VAR="gvf_ellipse_par.b" shortname="ell_b" param="GVF_ELLIPSE_B"/>
          <dl_setting MAX="90" MIN="-90" STEP="1" VAR="gvf_ellipse_par.alpha" shortname="ell_alpha" param="GVF_ELLIPSE_ALPHA"/>
        </dl_settings>
          <dl_settings NAME="Line">
        <dl_setting MAX="5" MIN="0.0" STEP="0.01" VAR="gvf_line_par.ke" shortname="line_ke" param="GVF_LINE_KE"/>
          <dl_setting MAX="5" MIN="0.0" STEP="0.01" VAR="gvf_line_par.kn" shortname="line_kn" param="GVF_LINE_KN"/>
          <dl_setting MAX="180" MIN="-180" STEP="1" VAR="gvf_line_par.heading" shortname="line_heading" param="GVF_LINE_HEADING"/>
          <dl_setting MAX="100" MIN="0" STEP="1" VAR="gvf_segment_par.d1" shortname="d1_seg" param="GVF_SEGMENT_D1"/>
          <dl_setting MAX="100" MIN="0" STEP="1" VAR="gvf_segment_par.d2" shortname="d2_seg" param="GVF_SEGMENT_D2"/>
        </dl_settings>
        <dl_settings NAME="Sine">
          <dl_setting MAX="5" MIN="0.0" STEP="0.01" VAR="gvf_sin_par.ke" shortname="sin_ke" param="GVF_SIN_KE"/>
          <dl_setting MAX="5" MIN="0.0" STEP="0.01" VAR="gvf_sin_par.kn" shortname="sin_kn" param="GVF_SIN_KN"/>
          <dl_setting MAX="180" MIN="-180" STEP="1" VAR="gvf_sin_par.alpha" shortname="sin_alpha" param="GVF_SIN_ALPHA"/>
          <dl_setting MAX="0.01" MIN="0" STEP="0.0001" VAR="gvf_sin_par.w" shortname="sin_w" param="GVF_SIN_W"/>
          <dl_setting MAX="6.2" MIN="0" STEP="0.002" VAR="gvf_sin_par.off" shortname="sin_off" param="GVF_SIN_OFF"/>
          <dl_setting MAX="100" MIN="0" STEP="1" VAR="gvf_sin_par.A" shortname="sin_amplitude" param="GVF_SIN_A"/>
        </dl_settings>
      </dl_settings>
    </dl_settings>
  </settings>

   <header>
     <file name="gvf.h"/>
     <file name="trajectories/gvf_line.h"/>
     <file name="trajectories/gvf_sin.h"/>
     <file name="trajectories/gvf_ellipse.h"/>
     <file name="nav/nav_survey_polygon_gvf.h"/>
   </header>

   <init fun = "gvf_init()"/>

   <makefile firmware="fixedwing">
     <file name="gvf.c"/>
     <file name="trajectories/gvf_line.c"/>
     <file name="trajectories/gvf_sin.c"/>
     <file name="trajectories/gvf_ellipse.c"/>
     <file name="nav/nav_survey_polygon_gvf.c"/>
   </makefile>

</module>

