AHRS using DCM filter.
No direct gyro bias estimation, but also compensates for attitude drift. Uses GPS speed for heading. Compensation of centrifugal force via GPS speed (to fly in circles with a fixedwing). Careful, it doesn't handle all BODY_TO_IMU rotations (mounting positions) correctly!
The algorithm was developed by William Premerlani and Paul Bizard. The algorithm is also used in the AHRS systems of the AdruIMU. The name DCM for the algorithm is really a misnomer, as that just means that the orientation is represented as a DirectionCosineMatrix (rotation matrix). But since people already know it under that name, we kept it.
Example for airframe file
Add to your firmware section: This example contains all possible configuration options, not all of them are mandatory!
<module name="ahrs_float_dcm">
b'<define name="USE_MAGNETOMETER_ONGROUND" />\n '
b'<define name="USE_AHRS_GPS_ACCELERATIONS" />\n '
b'<define name="ACCEL_WEIGHT_FILTER" value="8" />\n '
b'<define name="ACCEL_WEIGHT_BAND" value="1." />\n '
b'<configure name="AHRS_DCM_TYPE" value="AHRS_PRIMARY|AHRS_SECONDARY" />\n '
b'<configure name="USE_MAGNETOMETER" value="FALSE" />\n '
</module>
Module configuration options
Configure Options
- name:
AHRS_DCM_TYPE
value: AHRS_PRIMARY|AHRS_SECONDARY
Description: set if the AHRS is the primary source (default) or one of the secondary sources
- name:
USE_MAGNETOMETER
value: FALSE
Description: set to FALSE to disable magnetometer
Define Options
- name:
USE_MAGNETOMETER_ONGROUND
value: None
Description: use magnetic compensation before takeoff only while GPS course not good
- name:
USE_AHRS_GPS_ACCELERATIONS
value: None
Description: enable forward acceleration compensation from GPS speed
- name:
ACCEL_WEIGHT_FILTER
value: 8
Description: adjust accel drift heuristic filter (default 8, 0 to disable filter)
- name:
ACCEL_WEIGHT_BAND
value: 1.
Description: band size of accel filter: 1. means that there is no correction when accel magnitude exceeds +/- 0.5G around 1G (normal flight)
Module functions
Init Functions
These initialization functions are called once on startup.
Files
Header Files
The following headers are automatically included in modules.h
Source Files
Raw ahrs_float_dcm.xml file:
<!DOCTYPE module SYSTEM "module.dtd">
<module name="ahrs_float_dcm" dir="ahrs" task="estimation">
<doc>
<description>
AHRS using DCM filter.
No direct gyro bias estimation, but also compensates for attitude drift.
Uses GPS speed for heading.
Compensation of centrifugal force via GPS speed (to fly in circles with a fixedwing).
Careful, it doesn't handle all BODY_TO_IMU rotations (mounting positions) correctly!
The algorithm was developed by William Premerlani and Paul Bizard.
The algorithm is also used in the AHRS systems of the AdruIMU.
The name DCM for the algorithm is really a misnomer, as that just means that the orientation is represented as a DirectionCosineMatrix (rotation matrix).
But since people already know it under that name, we kept it.
</description>
<configure name="AHRS_DCM_TYPE" value="AHRS_PRIMARY|AHRS_SECONDARY" description="set if the AHRS is the primary source (default) or one of the secondary sources"/>
<configure name="USE_MAGNETOMETER" value="FALSE" description="set to FALSE to disable magnetometer"/>
<define name="USE_MAGNETOMETER_ONGROUND" description="use magnetic compensation before takeoff only while GPS course not good"/>
<define name="USE_AHRS_GPS_ACCELERATIONS" description="enable forward acceleration compensation from GPS speed"/>
<define name="ACCEL_WEIGHT_FILTER" value="8" description="adjust accel drift heuristic filter (default 8, 0 to disable filter)"/>
<define name="ACCEL_WEIGHT_BAND" value="1." description="band size of accel filter: 1. means that there is no correction when accel magnitude exceeds +/- 0.5G around 1G (normal flight)"/>
</doc>
<settings>
<dl_settings>
<dl_settings NAME="AHRS DCM">
<dl_setting var="ahrs_dcm_enable" min="0" step="1" max="1" module="modules/ahrs/ahrs_float_dcm_wrapper" values="DISABLE|ENABLE" handler="enable"/>
<dl_setting MAX="100" MIN="0" STEP="1" VAR="imu_health" shortname="health" module="modules/ahrs/ahrs_float_dcm" />
<dl_setting MAX="100" MIN="0" STEP="1" VAR="renorm_sqrt_count" shortname="err_norm" module="modules/ahrs/ahrs_float_dcm" />
</dl_settings>
</dl_settings>
</settings>
<dep>
<depends>ahrs_common,@imu,@gps</depends>
<provides>ahrs</provides>
</dep>
<header>
<file name="ahrs_float_dcm_wrapper.h"/>
</header>
<init fun="ahrs_dcm_wrapper_init()"/>
<makefile target="!sim|fbw">
<configure name="AHRS_DCM_TYPE" default="AHRS_PRIMARY"/>
<define name="AHRS_DCM_TYPE" value="$(AHRS_DCM_TYPE)"/>
<configure name="USE_MAGNETOMETER" default="0"/>
<define name="USE_MAGNETOMETER" cond="ifeq (,$(findstring $(USE_MAGNETOMETER),0 FALSE))"/>
<file name="ahrs_float_dcm.c"/>
<file name="ahrs_float_dcm_wrapper.c"/>
<test firmware="fixedwing">
<define name="AHRS_DCM_TYPE" value="AHRS_PRIMARY"/>
</test>
</makefile>
</module>