Skip to content

Commit

Permalink
mag sides: re-add CAL_MAG_SIDES required by QGC
Browse files Browse the repository at this point in the history
  • Loading branch information
bresch committed Jan 10, 2023
1 parent 1fa5413 commit ea706d5
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/modules/sensors/sensor_params_mag.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,15 @@
*/
PARAM_DEFINE_INT32(SENS_MAG_SIDES, 63);

/**
* For legacy QGC support only
*
* Use SENS_MAG_SIDES instead
*
* @group Sensors
*/
PARAM_DEFINE_INT32(CAL_MAG_SIDES, 63);

/**
* Type of magnetometer compensation
*
Expand Down
14 changes: 14 additions & 0 deletions src/modules/sensors/vehicle_magnetometer/VehicleMagnetometer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,26 @@ bool VehicleMagnetometer::ParametersUpdate(bool force)
{
// Check if parameters have changed
if (_parameter_update_sub.updated() || force) {
const int cal_mag_sides_prev = _param_cal_mag_sides.get();

// clear update
parameter_update_s param_update;
_parameter_update_sub.copy(&param_update);

updateParams();

// Legacy QGC support: CAL_MAG_SIDES required to display the correct UI
// Force it to be a copy of the new SENS_MAG_SIDES
if (_param_cal_mag_sides.get() != _param_sens_mag_sides.get()) {
if (_param_cal_mag_sides.get() != cal_mag_sides_prev) {
// The user tried to change the deprecated parameter
mavlink_log_critical(&_mavlink_log_pub, "CAL_MAG_SIDES deprecated, use SENS_MAG_SIDES\t");
}

_param_cal_mag_sides.set(_param_sens_mag_sides.get());
_param_cal_mag_sides.commit();
}

// Mag compensation type
MagCompensationType mag_comp_typ = static_cast<MagCompensationType>(_param_mag_comp_typ.get());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,9 @@ class VehicleMagnetometer : public ModuleParams, public px4::ScheduledWorkItem
(ParamInt<px4::params::CAL_MAG_COMP_TYP>) _param_mag_comp_typ,
(ParamBool<px4::params::SENS_MAG_MODE>) _param_sens_mag_mode,
(ParamFloat<px4::params::SENS_MAG_RATE>) _param_sens_mag_rate,
(ParamBool<px4::params::SENS_MAG_AUTOCAL>) _param_sens_mag_autocal
(ParamBool<px4::params::SENS_MAG_AUTOCAL>) _param_sens_mag_autocal,
(ParamInt<px4::params::CAL_MAG_SIDES>) _param_cal_mag_sides,
(ParamInt<px4::params::SENS_MAG_SIDES>) _param_sens_mag_sides
)
};
}; // namespace sensors

0 comments on commit ea706d5

Please sign in to comment.