<!DOCTYPE module SYSTEM "module.dtd">

<module name="stabilization_attitude" dir="stabilization">
  <doc>
    <description>
      Legacy attitude and lateral (heading) control for fixedwing aircraft
    </description>
    <section name="HORIZONTAL CONTROL" prefix="H_CTL_">
      <define name="COURSE_PGAIN" value="1.0" description="feedback heading P gain"/>
      <define name="COURSE_DGAIN" value="0.3" description="feedback heading D gain"/>
      <define name="ROLL_MAX_SETPOINT" value="45." description="max roll setpoint" unit="deg"/>
      <define name="PITCH_MAX_SETPOINT" value="30." description="max pitch up setpoint" unit="deg"/>
      <define name="PITCH_MIN_SETPOINT" value="-30." description="max pitch down setpoint" unit="deg"/>
      <define name="PITCH_PGAIN" value="12000." description="feedback pitch P gain"/>
      <define name="PITCH_DGAIN" value="1.5" description="feedback pitch D gain"/>
      <define name="ELEVATOR_OF_ROLL" value="1250" description="feedforward pitch to roll coupling"/>
      <define name="ROLL_SLEW" value="0.1" description="roll slew rate limiter"/>
      <define name="ROLL_ATTITUDE_GAIN" value="7500" description="feedback roll P gain"/>
      <define name="ROLL_RATE_GAIN" value="1500" description="feedback roll rate P gain (roll D gain)"/>
    </section>
  </doc>
  <settings>
    <dl_settings>
      <dl_settings NAME="control horiz">
        <dl_settings NAME="trim">
          <dl_setting MAX="960" MIN="-960" STEP="1" VAR="ap_state->command_roll_trim" shortname="roll_trim" module="inter_mcu" param="COMMAND_ROLL_TRIM"/>
          <dl_setting MAX="960" MIN="-960" STEP="1" VAR="ap_state->command_pitch_trim" shortname="pitch_trim" param="COMMAND_PITCH_TRIM"/>
          <dl_setting MAX="9000" MIN="-9000" STEP="1" VAR="ap_state->command_yaw_trim" shortname="yaw_trim" param="COMMAND_YAW_TRIM"/>
        </dl_settings>
        <dl_settings NAME="attitude">
          <dl_setting MAX="25000" MIN="000" STEP="250" VAR="h_ctl_roll_pgain" shortname="roll_pgain" module="stabilization/stabilization_attitude"/>
          <dl_setting MAX="60" MIN="0" STEP="1." VAR="h_ctl_roll_max_setpoint" shortname="max_roll" param="H_CTL_ROLL_MAX_SETPOINT" unit="rad" alt_unit="deg"/>
          <dl_setting MAX="25000" MIN="0" STEP="250" VAR="h_ctl_pitch_pgain" shortname="pitch_pgain" param="H_CTL_PITCH_PGAIN"/>
          <dl_setting MAX="50000" MIN="0" STEP="10" VAR="h_ctl_pitch_dgain" shortname="pitch_dgain" param="H_CTL_PITCH_DGAIN"/>
          <dl_setting MAX="5000" MIN="0" STEP="100" VAR="h_ctl_elevator_of_roll" shortname="elevator_of_roll" param="H_CTL_ELEVATOR_OF_ROLL"/>
          <dl_setting MAX="5000" MIN="0" STEP="100" VAR="h_ctl_aileron_of_throttle" shortname="aileron_of_throttle"/>
          <dl_setting MAX="15000" MIN="0" STEP="250" VAR="h_ctl_roll_attitude_gain" shortname="roll attitude pgain" param="H_CTL_ROLL_ATTITUDE_GAIN"/>
          <dl_setting MAX="15000" MIN="0" STEP="250" VAR="h_ctl_roll_rate_gain" shortname="roll rate gain" param="H_CTL_ROLL_RATE_GAIN"/>
        </dl_settings>
        <dl_settings name="course">
          <dl_setting MAX="3" MIN="0.1" STEP="0.05" VAR="h_ctl_course_pgain" shortname="course pgain" param="H_CTL_COURSE_PGAIN"/>
          <dl_setting MAX="2" MIN="0" STEP="0.1" VAR="h_ctl_course_dgain" shortname="course dgain" param="H_CTL_COURSE_DGAIN"/>
          <dl_setting MAX="2" MIN="0.1" STEP="0.05" VAR="h_ctl_course_pre_bank_correction" shortname="pre bank cor" param="H_CTL_COURSE_PRE_BANK_CORRECTION"/>
          <dl_setting MAX="1" MIN="0.02" STEP="0.01" VAR="h_ctl_roll_slew" shortname="roll slew"/>
        </dl_settings>
      </dl_settings>
    </dl_settings>
  </settings>
  <header>
    <file name="stabilization_attitude.h"/>
  </header>
  <init fun="h_ctl_init()"/>
  <makefile target="ap|sim|nps|hitl" firmware="fixedwing">
    <file name="stabilization_attitude.c" dir="$(SRC_FIRMWARE)/stabilization"/>
  </makefile>
</module>
