<!DOCTYPE airframe SYSTEM "airframe.dtd">

<airframe name="ardrone2_sdk">

  <firmware name="rotorcraft">
    <target name="ap" board="ardrone2_sdk">
      <define name="USE_INS_NAV_INIT" />
      <define name="ROTORCRAFT_COMMANDS_YAW_ALWAYS_ENABLED"/>
      <!-- <define name="ARDRONE2_DEBUG" /> -->
      <!-- <define name="USE_GPS_HEIGHT" /> -->
      <!-- <define name="ARDRONE_FLIGHT_INDOOR" /> -->
      <!-- <define name="ARDRONE_WITHOUT_SHELL" /> -->
      <!-- <define name="ARDRONE_OWNER_MAC" value="00:24:d7:47:f0:f4" /> -->
    </target>

    <subsystem name="radio_control" type="datalink" />
    <subsystem name="telemetry" type="transparent_udp" />
    <subsystem name="gps" type="ardrone2" />
    <subsystem name="ahrs" type="ardrone2" />
    <subsystem name="ins" type="ardrone2" />
    <subsystem name="actuators" type="ardrone2" />
    <subsystem name="stabilization" type="passthrough"/>
    <subsystem name="imu" type="ardrone2" />
  </firmware>

  <modules main_freq="512">
    <load name="sys_mon.xml" />
  </modules>

  <commands>
    <axis name="PITCH" failsafe_value="0" />
    <axis name="ROLL" failsafe_value="0" />
    <axis name="YAW" failsafe_value="0" />
    <axis name="THRUST" failsafe_value="0" />
  </commands>

  <servos driver="Default" />

  <section name="STABILIZATION_RATE" prefix="STABILIZATION_RATE_">
    <define name="SP_MAX_P" value="10000" />
    <define name="SP_MAX_Q" value="10000" />
    <define name="SP_MAX_R" value="10000" />
    <define name="DEADBAND_P" value="20" />
    <define name="DEADBAND_Q" value="20" />
    <define name="DEADBAND_R" value="200" />
    <define name="REF_TAU" value="4" />

    <!-- feedback -->
    <define name="GAIN_P" value="400" />
    <define name="GAIN_Q" value="400" />
    <define name="GAIN_R" value="350" />

    <define name="IGAIN_P" value="75" />
    <define name="IGAIN_Q" value="75" />
    <define name="IGAIN_R" value="50" />

    <!-- feedforward -->
    <define name="DDGAIN_P" value="300" />
    <define name="DDGAIN_Q" value="300" />
    <define name="DDGAIN_R" value="300" />
  </section>


  <section name="STABILIZATION_ATTITUDE" prefix="STABILIZATION_ATTITUDE_">
    <!-- setpoints -->
    <define name="SP_MAX_PHI" value="30." unit="deg" />
    <define name="SP_MAX_THETA" value="30." unit="deg" />
    <define name="SP_MAX_R" value="90." unit="deg/s" />
    <define name="DEADBAND_A" value="0" />
    <define name="DEADBAND_E" value="0" />
    <define name="DEADBAND_R" value="250" />
  </section>

  <section name="GUIDANCE_V" prefix="GUIDANCE_V_">
    <define name="HOVER_KP" value="425" />
    <define name="HOVER_KD" value="200" />
    <define name="HOVER_KI" value="125" />
    <define name="NOMINAL_HOVER_THROTTLE" value="0.5"/>
    <define name="ADAPT_THROTTLE_ENABLED" value="FALSE"/>
  </section>

  <section name="GUIDANCE_H" prefix="GUIDANCE_H_">
    <define name="MAX_BANK" value="30." unit="deg" />
    <define name="PGAIN" value="7" />
    <define name="DGAIN" value="2" />
    <define name="IGAIN" value="0" />
  </section>

  <section name="AUTOPILOT">
    <define name="MODE_STARTUP" value="AP_MODE_NAV" />
    <define name="MODE_MANUAL" value="AP_MODE_RC_DIRECT" />
    <define name="MODE_AUTO1" value="AP_MODE_HOVER_Z_HOLD" />
    <define name="MODE_AUTO2" value="AP_MODE_NAV" />
  </section>

  <section name="BAT">
    <define name="CATASTROPHIC_BAT_LEVEL" value=".2" unit="V" />
    <define name="CRITIC_BAT_LEVEL" value="1.9" unit="V" />
    <define name="LOW_BAT_LEVEL" value="2.5" unit="V" />
    <define name="MAX_BAT_LEVEL" value="10.0" unit="V" />
  </section>

  <section name="IMU" prefix="IMU_">
    <define name="ACCEL_X_NEUTRAL" value="2072" />
    <define name="ACCEL_Y_NEUTRAL" value="2040" />
    <define name="ACCEL_Z_NEUTRAL" value="2047" />
    <define name="ACCEL_X_SENS" value="19.1079036954" integer="16" />
    <define name="ACCEL_Y_SENS" value="19.5393623518" integer="16" />
    <define name="ACCEL_Z_SENS" value="19.6539180847" integer="16" />

    <define name="ACCEL_X_SIGN" value="1" />
    <define name="ACCEL_Y_SIGN" value="-1" />
    <define name="ACCEL_Z_SIGN" value="-1" />

    <define name="GYRO_P_SENS_NUM" value="4359" />
    <define name="GYRO_P_SENS_DEN" value="1000" />
    <define name="GYRO_Q_SENS_NUM" value="4359" />
    <define name="GYRO_Q_SENS_DEN" value="1000" />
    <define name="GYRO_R_SENS_NUM" value="4359" />
    <define name="GYRO_R_SENS_DEN" value="1000" />

    <define name="GYRO_P_SIGN" value="1" />
    <define name="GYRO_Q_SIGN" value="-1" />
    <define name="GYRO_R_SIGN" value="-1" />

    <define name="MAG_X_NEUTRAL" value="118" />
    <define name="MAG_Y_NEUTRAL" value="-65" />
    <define name="MAG_Z_NEUTRAL" value="110" />
    <define name="MAG_X_SENS" value="14.6416865144" integer="16" />
    <define name="MAG_Y_SENS" value="14.5167340835" integer="16" />
    <define name="MAG_Z_SENS" value="15.1670335124" integer="16" />

    <define name="MAG_X_SIGN" value="-1" />
    <define name="MAG_Y_SIGN" value="1" />
    <define name="MAG_Z_SIGN" value="-1" />

    <!-- roll -->
    <define name="BODY_TO_IMU_PHI" value="0." unit="deg" />
    <!-- pitch -->
    <define name="BODY_TO_IMU_THETA" value="0." unit="deg" />
    <!-- yaw -->
    <define name="BODY_TO_IMU_PSI" value="0." unit="deg" />
  </section>

</airframe>
