diff --git a/src/modules/ekf2/EKF2.cpp b/src/modules/ekf2/EKF2.cpp index e3fd2c7f03..05f017d210 100644 --- a/src/modules/ekf2/EKF2.cpp +++ b/src/modules/ekf2/EKF2.cpp @@ -159,6 +159,7 @@ EKF2::EKF2(bool multi_mode, const px4::wq_config_t &config, bool replay_mode): _param_ekf2_pcoef_z(_params->static_pressure_coef_z), _param_ekf2_move_test(_params->is_moving_scaler), _param_ekf2_mag_check(_params->check_mag_strength), + _param_ekf2_synthetic_mag_z(_params->synthesize_mag_z), _param_ekf2_gsf_tas_default(_params->EKFGSF_tas_default) { } diff --git a/src/modules/ekf2/EKF2.hpp b/src/modules/ekf2/EKF2.hpp index d1a4b82cfd..49b1cf5d35 100644 --- a/src/modules/ekf2/EKF2.hpp +++ b/src/modules/ekf2/EKF2.hpp @@ -495,6 +495,8 @@ private: (ParamFloat) _param_ekf2_req_gps_h, ///< Required GPS health time (ParamExtInt) _param_ekf2_mag_check, ///< Mag field strength check + (ParamExtInt) + _param_ekf2_synthetic_mag_z, ///< Enables the use of a synthetic value for the Z axis of the magnetometer calculated from the 3D magnetic field vector at the location of the drone. // Used by EKF-GSF experimental yaw estimator (ParamExtFloat) diff --git a/src/modules/ekf2/ekf2_params.c b/src/modules/ekf2/ekf2_params.c index eb7a7266bc..9b5ba6ac32 100644 --- a/src/modules/ekf2/ekf2_params.c +++ b/src/modules/ekf2/ekf2_params.c @@ -1326,6 +1326,20 @@ PARAM_DEFINE_FLOAT(EKF2_REQ_GPS_H, 10.0f); */ PARAM_DEFINE_INT32(EKF2_MAG_CHECK, 0); +/** + * Enable synthetic magnetometer Z component measurement. + * + * Use for vehicles where the measured body Z magnetic field is subject to strong magnetic interference. + * For magnetic heading fusion the magnetometer Z measurement will be replaced by a synthetic value calculated + * using the knowledge of the 3D magnetic field vector at the location of the drone. Therefore, this parameter + * will only have an effect if the global position of the drone is known. + * For 3D mag fusion the magnetometer Z measurement will simply be ingored instead of fusing the synthetic value. + * + * @group EKF2 + * @boolean +*/ +PARAM_DEFINE_INT32(EKF2_SYNT_MAG_Z, 0); + /** * Default value of true airspeed used in EKF-GSF AHRS calculation. * If no airspeed measurements are avalable, the EKF-GSF AHRS calculation will assume this value of true airspeed when compensating for centripetal acceleration during turns. Set to zero to disable centripetal acceleration compensation during fixed wing flight modes.