Switching between Mag+GPS and VIO indoors
-
Hi Modal,
Cleo is looking into using Magnetometer+GPS combo for outdoor heading and positioning. We're wondering how Modal handles the switch between indoor and outdoor flight, specifically how does the EKF2 know when to stop fusing the magnetometer (definitely don't want to try to keep heading via mag inside)?
Thanks!
Rowan -
Hi there, if you're using GPS+mag+vio then you'll need the following PX4 params changes in addition to our
vio_gps_baro.params
helper file:EKF2_MAG_TYPE = automatic (voxl default)
EKF2_MAG_CHECK = 1 [or 2/3 for more sensitivity] (voxl default is 0)Having mag_check = 1 will activate EKF2's field strength checker such that as you proceed indoors should stop mag fusion completely when the field strength goes outside thresholds (hardcoded within PX4 ~ .4gauss variance). It's similar to GPS's DOP threshold where we expect both (gps and mag) to exceed the thresholds where PX4 will stop fusion of those modalities and eventually use vio solely.
PX4's logic tries to maintain "smooth flight", so expect some delay/drift as it starts turning on/off the above (i.e. it will not be instant). Hence, adjust performance in those transitions, you'll need to modify ekf2's baro, gps, and mag
*_GATE
params accordingly.Note PX4 will adopt whatever heading is being derived from the activated sensors (GPS/Mag/vio) to construction its "global frame", so proceeding indoors you will still be operating under a global frame coordinate system (will still have a north reference based on last good mag/gps check).
-
Hi @Cliff-Wong thank you for the response!
In the version of PX4 that Modal is using (commit: https://github.com/modalai/px4-firmware/blob/b5c45bb232afc6a936b8349f4fa0be1efeb17707/src/modules/ekf2/ekf2_params.c) I see MAG_CHECK as:
/** * Magnetic field strength test selection * * When set, the EKF checks the strength of the magnetic field * to decide whether the magnetometer data is valid. * If GPS data is received, the magnetic field is compared to a World * Magnetic Model (WMM), otherwise an average value is used. * This check is useful to reject occasional hard iron disturbance. * * @group EKF2 * @boolean */ PARAM_DEFINE_INT32(EKF2_MAG_CHECK, 1);
Do you suggest updating the EKF2 code to the more recent version that supports more advanced mag health checks:
EKF2_MAG_CHECK: description: short: Magnetic field strength test selection long: 'Bitmask to set which check is used to decide whether the magnetometer data is valid. If GNSS data is received, the magnetic field is compared to a World Magnetic Model (WMM), otherwise an average value is used. This check is useful to reject occasional hard iron disturbance. Set bits to 1 to enable checks. Checks enabled by the following bit positions 0 : Magnetic field strength. Set tolerance using EKF2_MAG_CHK_STR 1 : Magnetic field inclination. Set tolerance using EKF2_MAG_CHK_INC 2 : Wait for GNSS to find the theoretical strength and inclination using the WMM' type: bitmask bit: 0: Strength (EKF2_MAG_CHK_STR) 1: Inclination (EKF2_MAG_CHK_INC) 2: Wait for WMM default: 1 min: 0 max: 7 EKF2_MAG_CHK_STR: description: short: Magnetic field strength check tolerance long: Maximum allowed deviation from the expected magnetic field strength to pass the check. type: float default: 0.2 min: 0.0 max: 1.0 unit: gauss decimal: 2 EKF2_MAG_CHK_INC: description: short: Magnetic field inclination check tolerance long: Maximum allowed deviation from the expected magnetic field inclination to pass the check. type: float default: 20.0 min: 0.0 max: 90.0 unit: deg decimal: 1
What we are worried about is the mag being used when the measurements are unhealthy.
-
@Rowan-Dempster Mainline PX4 now works on VOXL 2. It hasn't received that much testing yet but you are welcome to try it out.