You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: common/source/docs/common-ek3-affinity-lane-switching.rst
+29-17Lines changed: 29 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,30 +6,41 @@ EKF3 Affinity and Lane Switching
6
6
================================
7
7
8
8
The :ref:`EKF <dev:extended-kalman-filter>` instantiates multiple instances of the filter called 'lanes'.
9
-
The primary lane is the one that provides state estimates, rest are updated in the background and available for switching to.
10
-
The number of possible lanes is exactly equal to the number of IMUs enabled for use.
11
-
Conventionally, each lane uses the primary instance of the Airspeed, Barometer, GPS and Magnetometer sensors.
12
-
The primary sensor can be set as a user-modifiable parameter, but can be later changed by the system, even in-flight, in case of a driver-level fault.
13
-
However, modern-day vehicles are known to have multiple sensors installed of good quality.
14
-
Affinity is a way for the EKF lanes to use non-primary sensors within any running lane.
15
-
This provides a statistically consistent way to make use of multiple high quality sensors and use lane-switching to select the lane which has best performing combination of sensors.
16
-
The lane error score takes into account innovations from all sensors used by a lane.
17
-
This way, the vehicle can be saved from mishaps using noisy non-IMU sensors as well.
9
+
The "primary" lane is the one currently providing state estimates, other lanes are updated in the background and available for switching to.
18
10
11
+
.. note::
12
+
13
+
This page describes an advanced configuration topic. The source code is the truth. This page hopefully provides conceptual clarity, but it *is not perfect* on the details.
14
+
15
+
The number of possible lanes is the number of IMUs enabled for use (see :ref:`EK3_IMU_MASK <EK3_IMU_MASK>`).
16
+
Furthermore, the lanes are 1-1 bound to the (used) IMUs: lane 1 for IMU 1, lane 2 for IMU 2, etc.
17
+
18
+
For each of the other sensor-types {Airspeed, Barometer, GPS, and Magnetometer (aka Compass)}:
19
+
If affinity for that sensor-type is disabled, each lane uses the system's "primary" instance of the sensor.
20
+
(Affinity being disabled for every sensor-type is the conventional/default choice.)
21
+
The initial primary sensor instance is selected by a user-modifiable parameter.
22
+
The system may change which sensor instance is its primary, even in-flight, for example in case of a sensor fault.
23
+
24
+
Because modern-day vehicles may have redundant good quality sensors installed, "affinity" provides a way to have some EKF lanes prefer sensor instances which are not the system-wide primary.
25
+
For sensors with affinity enabled, lane-switching should be thought of as sensor-switching.
26
+
The lane error score (used to make a switching decision) takes into account innovations from all sensors used by a lane.
27
+
Thus in the case of noisy-but-not-broken non-IMU sensors, affinity might avoid a mishap by simply EKF lane-switching to a less-noisy IMU+sensor combination.
19
28
20
-
**A simple example of an affinity configuration for a vehicle which has 2 Barometers, 2 GPS, 2 Airspeeds, 3 Magnetometers and 3 IMUs -**
*Numbers indicate the lane's initial primary sensor instance.*
33
44
34
45
Configuration Parameters
35
46
------------------------
@@ -39,7 +50,8 @@ Configuration Parameters
39
50
Affinity is only available with EKF3, so make sure you are using it by ensuring :ref:`EK3_ENABLE <EK3_ENABLE>` is set to "1" and :ref:`AHRS_EKF_TYPE <AHRS_EKF_TYPE>` is set to "3"
40
51
41
52
The :ref:`EK3_AFFINITY <EK3_AFFINITY>` parameter is a bitmask which gives you the option to choose the sensors you want to enable affinity for.
42
-
Non-enabled will follow the default primary sensor allotment.
53
+
In every EKF lane, sensors for which affinity is not enabled will follow the system's "primary" selection logic.
54
+
For a sensor-type with affinity enabled, lane 1's primary sensor is 1, lane 2's primary sensor is 2, etc.
43
55
44
56
The :ref:`EK3_ERR_THRESH <EK3_ERR_THRESH>` parameter controls the sensitivity of lane switching. Lane errors are accumulated over time relative to the active primary lane. This threshold controls how much of an error difference between a non-primary and primary lane is required to consider the former performing better. Lowering this parameter makes lane switching more responsive to smaller 'relative' errors, and in practical you will see a more aggressive lane switching, and, vice-versa.
0 commit comments