mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-07-05 02:30:36 +08:00
calibration params: avoid using NaN as default
- NaN is not supported by JSON, and leads to parsing failure in QGC. - fixes https://github.com/PX4/PX4-Autopilot/issues/18095
This commit is contained in:
@@ -195,7 +195,14 @@ void Magnetometer::ParametersUpdate()
|
||||
}
|
||||
|
||||
// CAL_MAGx_TEMP
|
||||
set_temperature(GetCalibrationParamFloat(SensorString(), "TEMP", _calibration_index));
|
||||
float cal_temp = GetCalibrationParamFloat(SensorString(), "TEMP", _calibration_index);
|
||||
|
||||
if (cal_temp > TEMPERATURE_INVALID) {
|
||||
set_temperature(cal_temp);
|
||||
|
||||
} else {
|
||||
set_temperature(NAN);
|
||||
}
|
||||
|
||||
// CAL_MAGx_OFF{X,Y,Z}
|
||||
set_offset(GetCalibrationParamsVector3f(SensorString(), "OFF", _calibration_index));
|
||||
@@ -263,7 +270,12 @@ bool Magnetometer::ParametersSave()
|
||||
success &= SetCalibrationParam(SensorString(), "ROT", _calibration_index, -1);
|
||||
}
|
||||
|
||||
success &= SetCalibrationParam(SensorString(), "TEMP", _calibration_index, _temperature);
|
||||
if (PX4_ISFINITE(_temperature)) {
|
||||
success &= SetCalibrationParam(SensorString(), "TEMP", _calibration_index, _temperature);
|
||||
|
||||
} else {
|
||||
success &= SetCalibrationParam(SensorString(), "TEMP", _calibration_index, TEMPERATURE_INVALID);
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user