sensors: prefix mag config param SENS instead of CAL (#20723)

* sensors: prefix mag config param SENS instead of CAL
* mag sides: keep CAL_MAG_SIDES required by QGC
This commit is contained in:
Mathieu Bresciani 2023-01-12 15:42:36 +01:00 committed by GitHub
parent 635daeed8a
commit 767fcb2774
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 33 additions and 8 deletions

View File

@ -106,7 +106,7 @@ int do_mag_calibration(orb_advert_t *mavlink_log_pub)
// Collect: As defined by configuration
// start with a full mask, all six bits set
int32_t cal_mask = (1 << 6) - 1;
param_get(param_find("CAL_MAG_SIDES"), &cal_mask);
param_get(param_find("SENS_MAG_SIDES"), &cal_mask);
// Calibrate all mags at the same time
if (result == PX4_OK) {
@ -696,10 +696,10 @@ calibrate_return mag_calibrate_all(orb_advert_t *mavlink_log_pub, int32_t cal_ma
// Attempt to automatically determine external mag rotations
if (result == calibrate_return_ok) {
int32_t param_cal_mag_rot_auto = 0;
param_get(param_find("CAL_MAG_ROT_AUTO"), &param_cal_mag_rot_auto);
int32_t param_sens_mag_autorot = 0;
param_get(param_find("SENS_MAG_AUTOROT"), &param_sens_mag_autorot);
if ((worker_data.calibration_sides >= 3) && (param_cal_mag_rot_auto == 1)) {
if ((worker_data.calibration_sides >= 3) && (param_sens_mag_autorot == 1)) {
// find first internal mag to use as reference
int internal_index = -1;

View File

@ -53,6 +53,15 @@
* @value 63 Six side calibration
* @group Sensors
*/
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);
/**
@ -76,7 +85,7 @@ PARAM_DEFINE_INT32(CAL_MAG_COMP_TYP, 0);
* @boolean
* @group Sensors
*/
PARAM_DEFINE_INT32(CAL_MAG_ROT_AUTO, 1);
PARAM_DEFINE_INT32(SENS_MAG_AUTOROT, 1);
/**
* Magnetometer max rate.

View File

@ -49,8 +49,8 @@ VehicleMagnetometer::VehicleMagnetometer() :
ModuleParams(nullptr),
ScheduledWorkItem(MODULE_NAME, px4::wq_configurations::nav_and_controllers)
{
param_find("CAL_MAG_SIDES");
param_find("CAL_MAG_ROT_AUTO");
param_find("SENS_MAG_SIDES");
param_find("SENS_MAG_AUTOROT");
_voter.set_timeout(SENSOR_TIMEOUT);
_voter.set_equal_value_threshold(1000);
@ -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());

View File

@ -177,7 +177,9 @@ private:
(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