EKF Source Selection and Switching

The EKF position and velocity sources used for its internal updates can be set using the EKx_SRCn_y parameters. For EKF3’s primary sources, these are:

The options for these are generally self-explanatory however a couple of items are explained in more detail below

The EK3_SRC1_POSZ source options are:

  • Option 1: Baro is the default and works well for most vehicles and situations. If a GPS is also present the EKF may be configured to slowly correct the altitude to match the GPS by setting EK3_OGN_HGT_MASK to 5 (e.g. 1:Correct when using Baro height + 4:Apply corrections to local position).

  • Option 2: RangeFinder should almost never be used. This is only appropriate for indoor use where the floor is flat with no ground clutter (e.g. no chairs, boxes, etc). Please note that Surface Tracking and Terrain Following do not require the EKF to use the rangefinder at all

  • Option 3: GPS is only recommended if the vehicle will fly long duration flights where the air pressure may change significantly and the vehicle has a high quality GPS (e.g. UBlox F9P dual band). In case of GPS failure the EKF will fallback to using the barometer (if present)

  • Option 4: Beacon may be useful when beacons are used in place of a GPS

  • Option 6: ExternalNav may be used when a companion device provides a position estimate

The EK3_SRC1_YAW source options are:

  • Option 1: Compass is the normal default.

  • Option 2: GPS is used with GPS that can supply yaw (see GPS for Yaw (aka Moving Baseline))

  • Option 3: GPS with compass fallback is the same as GPS option, but while it has GPS yaw available it learns compass offsets to make the compass yaw match the GPS yaw. This means that if you lose GPS yaw while flying then the compass is ready to takeover immediately, with a smooth change from GPS yaw to compass yaw.

  • Option 6: ExternalNav is used when a companion device is providing yaw information

  • Option 8: GSF (Gaussian Sum Filter) provides yaw information based on GPS velocity and position changes and Plane will automatically use this in compass-less configurations,even if not selected. Copter requires this to be set explicitly in these configurations.

Source Switching

Three sets of EKF position and velocity source parameters are provided and by default the 1st set is used (e.g. the _SRC1 set).

The active set can be selected via an RC auxiliary switch (e.g. set RCx_OPTION to “90” / “EKF Source Set”).

Ground stations or companion computers may set the source by sending a MAV_CMD_SET_EKF_SOURCE_SET mavlink command but no GCSs are currently known to implement this.

This feature is especially helpful when using GPS / Non-GPS Transitions.

Velocity Source Fusing

There is an option to fuse all sources of velocity into the EKF. This will take velocity information from the XY and Z sources defined by :EK3_SRCx_VELXY and EK3_SRCx_VELZ, where ‘x’ is the source number (1-3). To enable this option set the first bit in the EK3_SRC_OPTIONS bitmask.

Warning

When using this option, users should ensure that the velocity measurements being provided to the EKF are both in the same reference frame/co-ordinate system.

ExternalNAV/Optical Flow Transitions

When switching between Optical Flow XY velocity and/or positioning as sources for EKF3 to an ExternalNAV source, such as 3D Camera, you can set EK3_SRC_OPTIONS bit 1 to keep the ExternalNAV aligned with the OpticalFlow to avoid position/velocity bumps upon switching.

For example, you could setup a 3D camera as an external position and velocity source:

and OpticalFLow as the second source:

and use an auxiliary RC switch to switch between the two.