Skip to content
Snippets Groups Projects
Commit d99b72ea authored by Beat Küng's avatar Beat Küng Committed by Lorenz Meier
Browse files

attitude_estimator_q: set mag weight to 0 if SYS_HAS_MAG is not set

parent f2516bbf
No related branches found
No related tags found
No related merge requests found
......@@ -123,6 +123,7 @@ private:
param_t acc_comp;
param_t bias_max;
param_t ext_hdg_mode;
param_t has_mag;
} _params_handles{}; /**< handles for interesting parameters */
float _w_accel = 0.0f;
......@@ -179,6 +180,7 @@ AttitudeEstimatorQ::AttitudeEstimatorQ()
_params_handles.acc_comp = param_find("ATT_ACC_COMP");
_params_handles.bias_max = param_find("ATT_BIAS_MAX");
_params_handles.ext_hdg_mode = param_find("ATT_EXT_HDG_M");
_params_handles.has_mag = param_find("SYS_HAS_MAG");
_vel_prev.zero();
_pos_acc.zero();
......@@ -471,6 +473,15 @@ void AttitudeEstimatorQ::update_parameters(bool force)
param_get(_params_handles.w_acc, &_w_accel);
param_get(_params_handles.w_mag, &_w_mag);
// disable mag fusion if the system does not have a mag
if (_params_handles.has_mag != PARAM_INVALID) {
int32_t has_mag;
if (param_get(_params_handles.has_mag, &has_mag) == 0 && has_mag == 0) {
_w_mag = 0.f;
}
}
if (_w_mag < FLT_EPSILON) { // if the weight is zero (=mag disabled), make sure the estimator initializes
_mag(0) = 1.f;
_mag(1) = 0.f;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment