diff --git a/src/modules/ekf2/EKF/common.h b/src/modules/ekf2/EKF/common.h index 880df1d4fe..aaabe89eaa 100644 --- a/src/modules/ekf2/EKF/common.h +++ b/src/modules/ekf2/EKF/common.h @@ -95,8 +95,7 @@ enum class VelocityFrame : uint8_t { enum GeoDeclinationMask : uint8_t { // Bit locations for mag_declination_source USE_GEO_DECL = (1<<0), ///< set to true to use the declination from the geo library when the GPS position becomes available, set to false to always use the EKF2_MAG_DECL value - SAVE_GEO_DECL = (1<<1), ///< set to true to set the EKF2_MAG_DECL parameter to the value returned by the geo library - FUSE_DECL = (1<<2) ///< set to true if the declination is always fused as an observation to constrain drift when 3-axis fusion is performed + SAVE_GEO_DECL = (1<<1) ///< set to true to set the EKF2_MAG_DECL parameter to the value returned by the geo library }; enum MagFuseType : uint8_t { @@ -361,7 +360,7 @@ struct parameters { float mag_noise{5.0e-2f}; ///< measurement noise used for 3-axis magnetometer fusion (Gauss) float mag_declination_deg{0.0f}; ///< magnetic declination (degrees) float mag_innov_gate{3.0f}; ///< magnetometer fusion innovation consistency gate size (STD) - int32_t mag_declination_source{7}; ///< bitmask used to control the handling of declination data + int32_t mag_declination_source{3}; ///< bitmask used to control the handling of declination data int32_t mag_fusion_type{0}; ///< integer used to specify the type of magnetometer fusion used float mag_acc_gate{0.5f}; ///< when in auto select mode, heading fusion will be used when manoeuvre accel is lower than this (m/sec**2) diff --git a/src/modules/ekf2/EKF/mag_3d_control.cpp b/src/modules/ekf2/EKF/mag_3d_control.cpp index 79ed2b6c9d..41192f2cbf 100644 --- a/src/modules/ekf2/EKF/mag_3d_control.cpp +++ b/src/modules/ekf2/EKF/mag_3d_control.cpp @@ -91,9 +91,8 @@ void Ekf::controlMag3DFusion(const magSample &mag_sample, const bool common_star // if we are using 3-axis magnetometer fusion, but without external NE aiding, // then the declination must be fused as an observation to prevent long term heading drift // fusing declination when gps aiding is available is optional. - const bool mag_decl_user_selected = (_params.mag_declination_source & GeoDeclinationMask::FUSE_DECL); const bool not_using_ne_aiding = !_control_status.flags.gps && !_control_status.flags.aux_gpos; - _control_status.flags.mag_dec = (_control_status.flags.mag && ((not_using_ne_aiding || !_control_status.flags.mag_aligned_in_flight) || mag_decl_user_selected)); + _control_status.flags.mag_dec = (_control_status.flags.mag && (not_using_ne_aiding || !_control_status.flags.mag_aligned_in_flight)); if (_control_status.flags.mag) { aid_src.timestamp_sample = mag_sample.time_us; diff --git a/src/modules/ekf2/ekf2_params.c b/src/modules/ekf2/ekf2_params.c index ebeae0e8e1..b43f30440d 100644 --- a/src/modules/ekf2/ekf2_params.c +++ b/src/modules/ekf2/ekf2_params.c @@ -474,14 +474,12 @@ PARAM_DEFINE_FLOAT(EKF2_MAG_GATE, 3.0f); * Set bits in the following positions to enable functions. * 0 : Set to true to use the declination from the geo_lookup library when the GPS position becomes available, set to false to always use the EKF2_MAG_DECL value. * 1 : Set to true to save the EKF2_MAG_DECL parameter to the value returned by the EKF when the vehicle disarms. - * 2 : Set to true to always use the declination as an observation when 3-axis magnetometer fusion is being used. * * @group EKF2 * @min 0 - * @max 7 + * @max 3 * @bit 0 use geo_lookup declination * @bit 1 save EKF2_MAG_DECL on disarm - * @bit 2 use declination as an observation * @reboot_required true */ PARAM_DEFINE_INT32(EKF2_DECL_TYPE, 3);