<!DOCTYPE module SYSTEM "module.dtd">

<module name="ahrs_int_cmpl_euler" dir="ahrs">
  <doc>
    <description>
      AHRS using complementary filter in fixed point.
      Propagation is done in euler angles representation.
      Not recommended for fixedwings, as this filter doesn't compensate for centrifugal force when flying turns.
      Magnetometer is always only used for heading (yaw).
      Does not handle the accel and mag updates correctly if BODY_TO_IMU is used for more than just adjustment by a few degrees.
      In general, rather use int_cmpl_quat
    </description>
    <configure name="USE_MAGNETOMETER" value="TRUE" description="set to FALSE to disable magnetometer"/>
    <configure name="AHRS_ALIGNER_LED" value="1" description="LED number to indicate AHRS alignment, none to disable (default is board dependent)"/>
    <define name="AHRS_MAG_OFFSET" value="0.0" description="offset in radians to subtract from the heading calculated by the magnetometer"/>
     <define name="USE_NOISE_FILTER" description="apply a simple filter on the rate and accel inputs"/>
     <define name="USE_NOISE_CUT" description="cut rate input at 1 rad/s and accel input at 20m/s2"/>
     <define name="AHRS_ICE_IMU_ID" value="ABI_BROADCAST" description="ABI sender id of IMU to use"/>
     <define name="AHRS_ICE_MAG_ID" value="ABI_BROADCAST" description="ABI sender id of magnetometer to use"/>
  </doc>

  <settings>
    <dl_settings>
      <dl_settings NAME="Filter">
        <dl_setting var="ahrs_ice.reinj_1" min="512" step="512" max="262144" module="subsystems/ahrs/ahrs_int_cmpl_euler" shortname="reinj_1" type="int32" persistent="true"/>
      </dl_settings>
    </dl_settings>
  </settings>

  <autoload name="ahrs_sim"/>
  <header>
    <file name="ahrs.h" dir="subsystems"/>
  </header>

  <makefile target="!sim|fbw">
    <configure name="USE_MAGNETOMETER" default="1"/>

    <define name="USE_MAGNETOMETER" cond="ifeq (,$(findstring $(USE_MAGNETOMETER),0 FALSE))"/>
    <define name="AHRS_ALIGNER_LED" value="$(AHRS_ALIGNER_LED)" cond="ifneq ($(AHRS_ALIGNER_LED),none)"/>
    <define name="USE_AHRS"/>
    <define name="USE_AHRS_ALIGNER"/>

    <file name="ahrs.c" dir="subsystems"/>
    <file name="ahrs_aligner.c" dir="subsystems/ahrs"/>
    <file name="ahrs_int_cmpl_euler.c" dir="subsystems/ahrs"/>
    <file name="ahrs_int_cmpl_euler_wrapper.c" dir="subsystems/ahrs"/>
    <raw>
ifdef SECONDARY_AHRS
ifneq (,$(findstring $(SECONDARY_AHRS), ice int_cmpl_euler))
# this is the secondary AHRS
$(TARGET).CFLAGS += -DAHRS_SECONDARY_TYPE_H=\"subsystems/ahrs/ahrs_int_cmpl_euler_wrapper.h\"
$(TARGET).CFLAGS += -DSECONDARY_AHRS=ahrs_ice
else
# this is the primary AHRS
$(TARGET).CFLAGS += -DAHRS_TYPE_H=\"subsystems/ahrs/ahrs_int_cmpl_euler_wrapper.h\"
$(TARGET).CFLAGS += -DPRIMARY_AHRS=ahrs_ice
endif
else
# plain old single AHRS usage
$(TARGET).CFLAGS += -DAHRS_TYPE_H=\"subsystems/ahrs/ahrs_int_cmpl_euler_wrapper.h\"
endif
    </raw>
  </makefile>
</module>
