Paparazzi UAS  v6.1.0_stable
Paparazzi is a free software Unmanned Aircraft System.
ins_ekf2 module

simple INS and AHRS using EKF2 from PX4

No detailed description...

Example for airframe file

Add to your firmware section: This example contains all possible configuration options, not all of them are mandatory!

<module name="ins_ekf2">
b'<define name="INS_EKF2_SONAR_MIN_RANGE" value="0.05" />\n '
b'<define name="INS_EKF2_SONAR_MAX_RANGE" value="3" />\n '
b'<define name="INS_EKF2_RANGE_MAIN_AGL" value="1" />\n '
b'<define name="INS_EKF2_FLOW_SENSOR_DELAY" value="15" />\n '
b'<define name="INS_EKF2_MIN_FLOW_QUALITY" value="100" />\n '
b'<define name="INS_EKF2_MAX_FLOW_RATE" value="20" />\n '
b'<define name="INS_EKF2_FLOW_OFFSET_X" value="-130" />\n '
b'<define name="INS_EKF2_FLOW_OFFSET_Y" value="-150" />\n '
b'<define name="INS_EKF2_FLOW_OFFSET_Z" value="170" />\n '
b'<define name="INS_EKF2_FLOW_NOISE" value="0.01" />\n '
b'<define name="INS_EKF2_FLOW_NOISE_QMIN" value="0.03" />\n '
b'<define name="INS_EKF2_FLOW_INNOV_GATE" value="3" />\n '
b'<define name="INS_EKF2_FUSION_MODE" value="(MASK_USE_GPS)" />\n '
b'<define name="INS_EKF2_VDIST_SENSOR_TYPE" value="VDIST_SENSOR_BARO" />\n '
b'<define name="INS_EKF2_GPS_CHECK_MASK" value="(MASK_GPS_NSATS | MASK_GPS_HACC | MASK_GPS_SACC)" />\n '
b'<define name="INS_EKF2_AGL_ID" value="ABI_BROADCAST" />\n '
b'<define name="INS_EKF2_BARO_ID" value="ABI_BROADCAST" />\n '
b'<define name="INS_EKF2_GYRO_ID" value="ABI_BROADCAST" />\n '
b'<define name="INS_EKF2_ACCEL_ID" value="ABI_BROADCAST" />\n '
b'<define name="INS_EKF2_MAG_ID" value="ABI_BROADCAST" />\n '
b'<define name="INS_EKF2_GPS_ID" value="ABI_BROADCAST" />\n '
</module>

Module configuration options

Define Options

  • name: INS_EKF2_SONAR_MIN_RANGE value: 0.05
    Description: AGL sensor minimum range [m]
  • name: INS_EKF2_SONAR_MAX_RANGE value: 3
    Description: AGL sensor maximum range [m]
  • name: INS_EKF2_RANGE_MAIN_AGL value: 1
    Description: If enabled uses radar sensor as primary AGL source, if possible
  • name: INS_EKF2_FLOW_SENSOR_DELAY value: 15
    Description: flow/radar message delay [ms]
  • name: INS_EKF2_MIN_FLOW_QUALITY value: 100
    Description: Minimum quality of the optical flow message accepted [0-255]
  • name: INS_EKF2_MAX_FLOW_RATE value: 20
    Description: Maximum flow rate the sensor can perceive [rad/sec]]
  • name: INS_EKF2_FLOW_OFFSET_X value: -130
    Description: Flow sensor X offset from IMU position [mm]
  • name: INS_EKF2_FLOW_OFFSET_Y value: -150
    Description: Flow sensor Y offset from IMU position [mm]
  • name: INS_EKF2_FLOW_OFFSET_Z value: 170
    Description: Flow sensor Z offset from IMU position [mm]
  • name: INS_EKF2_FLOW_NOISE value: 0.01
    Description: Flow sensor noise [rad/sec]
  • name: INS_EKF2_FLOW_NOISE_QMIN value: 0.03
    Description: Flow sensor noise when quality is minimum [rad/sec]
  • name: INS_EKF2_FLOW_INNOV_GATE value: 3
    Description: Flow sensor innovation gate [STD]
  • name: INS_EKF2_FUSION_MODE value: (MASK_USE_GPS)
    Description: The sensor that are used for position fusion
  • name: INS_EKF2_VDIST_SENSOR_TYPE value: VDIST_SENSOR_BARO
    Description: Primary sensor used for vertical distance
  • name: INS_EKF2_GPS_CHECK_MASK value: (MASK_GPS_NSATS | MASK_GPS_HACC | MASK_GPS_SACC)
    Description: GPS checks enabled before initialization of the global positioning
  • name: INS_EKF2_AGL_ID value: ABI_BROADCAST
    Description: ABI sensor ID used as input for AGL measurements
  • name: INS_EKF2_BARO_ID value: ABI_BROADCAST
    Description: ABI sensor ID used ad input for Barometric measurements
  • name: INS_EKF2_GYRO_ID value: ABI_BROADCAST
    Description: ABI sensor ID used as input for gyro measurements
  • name: INS_EKF2_ACCEL_ID value: ABI_BROADCAST
    Description: ABI sensor ID used ad input for acceleration measurements
  • name: INS_EKF2_MAG_ID value: ABI_BROADCAST
    Description: ABI sensor ID used as input for magnetic measurements
  • name: INS_EKF2_GPS_ID value: ABI_BROADCAST
    Description: ABI sensor ID used ad input for GPS measurements

Module functions

Init Functions

These initialization functions are called once on startup.

Periodic Functions

These functions are called periodically at the specified frequency from the module periodic loop.

  • ins_ekf2_update()
    • Running at maximum module frequency.
    • Autorun: TRUE
      Periodic function automatically starts after init.

Files

Header Files

The following headers are automatically included in modules.h

Source Files

  • modules/ins/ins.c
  • modules/ins/ins_ekf2.cpp
  • ecl/mathlib/mathlib.cpp
  • ecl/geo/geo.cpp
  • ecl/geo_lookup/geo_mag_declination.cpp
  • ecl/EKF/airspeed_fusion.cpp
  • ecl/EKF/control.cpp
  • ecl/EKF/covariance.cpp
  • ecl/EKF/drag_fusion.cpp
  • ecl/EKF/ekf.cpp
  • ecl/EKF/ekf_helper.cpp
  • ecl/EKF/estimator_interface.cpp
  • ecl/EKF/gps_checks.cpp
  • ecl/EKF/mag_fusion.cpp
  • ecl/EKF/optflow_fusion.cpp
  • ecl/EKF/sideslip_fusion.cpp
  • ecl/EKF/terrain_estimator.cpp
  • ecl/EKF/vel_pos_fusion.cpp
  • ecl/EKF/gps_yaw_fusion.cpp

Raw ins_ekf2.xml file:

<!DOCTYPE module SYSTEM "module.dtd">
<module name="ins_ekf2" dir="ins" task="estimation">
<doc>
<description>
simple INS and AHRS using EKF2 from PX4
</description>
<define name="INS_EKF2_SONAR_MIN_RANGE" value="0.05" description="AGL sensor minimum range [m]"/>
<define name="INS_EKF2_SONAR_MAX_RANGE" value="3" description="AGL sensor maximum range [m]"/>
<define name="INS_EKF2_RANGE_MAIN_AGL" value="1" description="If enabled uses radar sensor as primary AGL source, if possible"/>
<define name="INS_EKF2_FLOW_SENSOR_DELAY" value="15" description="flow/radar message delay [ms]"/>
<define name="INS_EKF2_MIN_FLOW_QUALITY" value="100" description="Minimum quality of the optical flow message accepted [0-255]"/>
<define name="INS_EKF2_MAX_FLOW_RATE" value="20" description="Maximum flow rate the sensor can perceive [rad/sec]]"/>
<define name="INS_EKF2_FLOW_OFFSET_X" value="-130" description="Flow sensor X offset from IMU position [mm]"/>
<define name="INS_EKF2_FLOW_OFFSET_Y" value="-150" description="Flow sensor Y offset from IMU position [mm]"/>
<define name="INS_EKF2_FLOW_OFFSET_Z" value="170" description="Flow sensor Z offset from IMU position [mm]"/>
<define name="INS_EKF2_FLOW_NOISE" value="0.01" description="Flow sensor noise [rad/sec]"/>
<define name="INS_EKF2_FLOW_NOISE_QMIN" value="0.03" description="Flow sensor noise when quality is minimum [rad/sec]"/>
<define name="INS_EKF2_FLOW_INNOV_GATE" value="3" description="Flow sensor innovation gate [STD]"/>
<define name="INS_EKF2_FUSION_MODE" value="(MASK_USE_GPS)" description="The sensor that are used for position fusion"/>
<define name="INS_EKF2_VDIST_SENSOR_TYPE" value="VDIST_SENSOR_BARO" description="Primary sensor used for vertical distance"/>
<define name="INS_EKF2_GPS_CHECK_MASK" value="(MASK_GPS_NSATS | MASK_GPS_HACC | MASK_GPS_SACC)" description="GPS checks enabled before initialization of the global positioning"/>
<define name="INS_EKF2_AGL_ID" value="ABI_BROADCAST" description="ABI sensor ID used as input for AGL measurements"/>
<define name="INS_EKF2_BARO_ID" value="ABI_BROADCAST" description="ABI sensor ID used ad input for Barometric measurements"/>
<define name="INS_EKF2_GYRO_ID" value="ABI_BROADCAST" description="ABI sensor ID used as input for gyro measurements"/>
<define name="INS_EKF2_ACCEL_ID" value="ABI_BROADCAST" description="ABI sensor ID used ad input for acceleration measurements"/>
<define name="INS_EKF2_MAG_ID" value="ABI_BROADCAST" description="ABI sensor ID used as input for magnetic measurements"/>
<define name="INS_EKF2_GPS_ID" value="ABI_BROADCAST" description="ABI sensor ID used ad input for GPS measurements"/>
</doc>
<settings>
<dl_settings NAME="INS">
<!-- EKF2 Configuration parameters -->
<dl_settings name="ekf2">
<dl_setting var="ekf2_params.mag_fusion_type" min="0" step="1" max="5" shortname="mag_fusion" values="AUTO|HEADING|3D|AUTOFW|INDOOR|NONE" module="modules/ins/ins_ekf2" handler="change_param"/>
<dl_setting var="ekf2_params.fusion_mode" min="0" max="1" step="1" shortname="remove_gps" values="FALSE|TRUE" module="modules/ins/ins_ekf2" handler="remove_gps" type="bool" persistent="true"/>
</dl_settings>
</dl_settings>
</settings>
<dep>
<depends>@gps,@mag,@imu</depends>
<provides>ins,ahrs</provides>
</dep>
<header>
<file name="ins_ekf2.h"/>
</header>
<init fun="ins_ekf2_init()"/>
<periodic fun="ins_ekf2_update()" autorun="TRUE"/>
<makefile target="ap|nps">
<configure name="CXXSTANDARD" value="-std=c++11"/>
<!-- EKF2 files -->
<define name="INS_TYPE_H" value="modules/ins/ins_ekf2.h" type="string"/>
<file name="ins.c"/>
<file name="ins_ekf2.cpp"/>
<!-- Include the ecl and matrix libraries from ext -->
<include name="$(PAPARAZZI_SRC)/sw/ext/ecl/"/>
<include name="$(PAPARAZZI_SRC)/sw/ext/matrix/"/>
<define name="__PAPARAZZI" value="TRUE"/>
<define name="ECL_STANDALONE" value="TRUE"/>
<define name="USE_MAGNETOMETER" value="TRUE"/> <!-- Needed for IMU to get scaled version -->
<!-- Compile needed ecl files -->
<file name="mathlib.cpp" dir="ecl/mathlib"/>
<file name="geo.cpp" dir="ecl/geo"/>
<file name="geo_mag_declination.cpp" dir="ecl/geo_lookup"/>
<file name="airspeed_fusion.cpp" dir="ecl/EKF"/>
<file name="control.cpp" dir="ecl/EKF"/>
<file name="covariance.cpp" dir="ecl/EKF"/>
<file name="drag_fusion.cpp" dir="ecl/EKF"/>
<file name="ekf.cpp" dir="ecl/EKF"/>
<file name="ekf_helper.cpp" dir="ecl/EKF"/>
<file name="estimator_interface.cpp" dir="ecl/EKF"/>
<file name="gps_checks.cpp" dir="ecl/EKF"/>
<file name="mag_fusion.cpp" dir="ecl/EKF"/>
<file name="optflow_fusion.cpp" dir="ecl/EKF"/>
<file name="sideslip_fusion.cpp" dir="ecl/EKF"/>
<file name="terrain_estimator.cpp" dir="ecl/EKF"/>
<file name="vel_pos_fusion.cpp" dir="ecl/EKF"/>
<file name="gps_yaw_fusion.cpp" dir="ecl/EKF"/>
</makefile>
</module>