forked from Archive/PX4-Autopilot
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:
parent
507cce78d5
commit
c4b91c8558
|
@ -210,7 +210,14 @@ void Accelerometer::ParametersUpdate()
|
|||
}
|
||||
|
||||
// CAL_ACCx_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_ACCx_OFF{X,Y,Z}
|
||||
set_offset(GetCalibrationParamsVector3f(SensorString(), "OFF", _calibration_index));
|
||||
|
@ -263,7 +270,12 @@ bool Accelerometer::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;
|
||||
}
|
||||
|
|
|
@ -92,6 +92,8 @@ public:
|
|||
void SensorCorrectionsUpdate(bool force = false);
|
||||
|
||||
private:
|
||||
static constexpr float TEMPERATURE_INVALID = -1000.f;
|
||||
|
||||
uORB::Subscription _sensor_correction_sub{ORB_ID(sensor_correction)};
|
||||
|
||||
Rotation _rotation_enum{ROTATION_NONE};
|
||||
|
|
|
@ -195,7 +195,14 @@ void Gyroscope::ParametersUpdate()
|
|||
}
|
||||
|
||||
// CAL_GYROx_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_GYROx_OFF{X,Y,Z}
|
||||
set_offset(GetCalibrationParamsVector3f(SensorString(), "OFF", _calibration_index));
|
||||
|
@ -243,7 +250,12 @@ bool Gyroscope::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;
|
||||
}
|
||||
|
|
|
@ -96,6 +96,8 @@ public:
|
|||
void SensorCorrectionsUpdate(bool force = false);
|
||||
|
||||
private:
|
||||
static constexpr float TEMPERATURE_INVALID = -1000.f;
|
||||
|
||||
uORB::Subscription _sensor_correction_sub{ORB_ID(sensor_correction)};
|
||||
|
||||
Rotation _rotation_enum{ROTATION_NONE};
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -100,6 +100,8 @@ public:
|
|||
void UpdatePower(float power) { _power = power; }
|
||||
|
||||
private:
|
||||
static constexpr float TEMPERATURE_INVALID = -1000.f;
|
||||
|
||||
Rotation _rotation_enum{ROTATION_NONE};
|
||||
|
||||
matrix::Dcmf _rotation;
|
||||
|
|
|
@ -172,8 +172,9 @@ PARAM_DEFINE_FLOAT(CAL_ACC0_ZSCALE, 1.0f);
|
|||
*
|
||||
* Temperature during last calibration.
|
||||
*
|
||||
* @unit celcius
|
||||
* @category system
|
||||
* @group Sensor Calibration
|
||||
* @volatile
|
||||
*/
|
||||
PARAM_DEFINE_FLOAT(CAL_ACC0_TEMP, NAN);
|
||||
PARAM_DEFINE_FLOAT(CAL_ACC0_TEMP, -1000.f);
|
||||
|
|
|
@ -172,8 +172,9 @@ PARAM_DEFINE_FLOAT(CAL_ACC1_ZSCALE, 1.0f);
|
|||
*
|
||||
* Temperature during last calibration.
|
||||
*
|
||||
* @unit celcius
|
||||
* @category system
|
||||
* @group Sensor Calibration
|
||||
* @volatile
|
||||
*/
|
||||
PARAM_DEFINE_FLOAT(CAL_ACC1_TEMP, NAN);
|
||||
PARAM_DEFINE_FLOAT(CAL_ACC1_TEMP, -1000.f);
|
||||
|
|
|
@ -172,8 +172,9 @@ PARAM_DEFINE_FLOAT(CAL_ACC2_ZSCALE, 1.0f);
|
|||
*
|
||||
* Temperature during last calibration.
|
||||
*
|
||||
* @unit celcius
|
||||
* @category system
|
||||
* @group Sensor Calibration
|
||||
* @volatile
|
||||
*/
|
||||
PARAM_DEFINE_FLOAT(CAL_ACC2_TEMP, NAN);
|
||||
PARAM_DEFINE_FLOAT(CAL_ACC2_TEMP, -1000.f);
|
||||
|
|
|
@ -172,8 +172,9 @@ PARAM_DEFINE_FLOAT(CAL_ACC3_ZSCALE, 1.0f);
|
|||
*
|
||||
* Temperature during last calibration.
|
||||
*
|
||||
* @unit celcius
|
||||
* @category system
|
||||
* @group Sensor Calibration
|
||||
* @volatile
|
||||
*/
|
||||
PARAM_DEFINE_FLOAT(CAL_ACC3_TEMP, NAN);
|
||||
PARAM_DEFINE_FLOAT(CAL_ACC3_TEMP, -1000.f);
|
||||
|
|
|
@ -145,8 +145,9 @@ PARAM_DEFINE_FLOAT(CAL_GYRO0_ZOFF, 0.0f);
|
|||
*
|
||||
* Temperature during last calibration.
|
||||
*
|
||||
* @unit celcius
|
||||
* @category system
|
||||
* @group Sensor Calibration
|
||||
* @volatile
|
||||
*/
|
||||
PARAM_DEFINE_FLOAT(CAL_GYRO0_TEMP, NAN);
|
||||
PARAM_DEFINE_FLOAT(CAL_GYRO0_TEMP, -1000.f);
|
||||
|
|
|
@ -145,8 +145,9 @@ PARAM_DEFINE_FLOAT(CAL_GYRO1_ZOFF, 0.0f);
|
|||
*
|
||||
* Temperature during last calibration.
|
||||
*
|
||||
* @unit celcius
|
||||
* @category system
|
||||
* @group Sensor Calibration
|
||||
* @volatile
|
||||
*/
|
||||
PARAM_DEFINE_FLOAT(CAL_GYRO1_TEMP, NAN);
|
||||
PARAM_DEFINE_FLOAT(CAL_GYRO1_TEMP, -1000.f);
|
||||
|
|
|
@ -145,8 +145,9 @@ PARAM_DEFINE_FLOAT(CAL_GYRO2_ZOFF, 0.0f);
|
|||
*
|
||||
* Temperature during last calibration.
|
||||
*
|
||||
* @unit celcius
|
||||
* @category system
|
||||
* @group Sensor Calibration
|
||||
* @volatile
|
||||
*/
|
||||
PARAM_DEFINE_FLOAT(CAL_GYRO2_TEMP, NAN);
|
||||
PARAM_DEFINE_FLOAT(CAL_GYRO2_TEMP, -1000.f);
|
||||
|
|
|
@ -145,8 +145,9 @@ PARAM_DEFINE_FLOAT(CAL_GYRO3_ZOFF, 0.0f);
|
|||
*
|
||||
* Temperature during last calibration.
|
||||
*
|
||||
* @unit celcius
|
||||
* @category system
|
||||
* @group Sensor Calibration
|
||||
* @volatile
|
||||
*/
|
||||
PARAM_DEFINE_FLOAT(CAL_GYRO3_TEMP, NAN);
|
||||
PARAM_DEFINE_FLOAT(CAL_GYRO3_TEMP, -1000.f);
|
||||
|
|
|
@ -241,8 +241,9 @@ PARAM_DEFINE_FLOAT(CAL_MAG0_ZCOMP, 0.0f);
|
|||
*
|
||||
* Temperature during last calibration.
|
||||
*
|
||||
* @unit celcius
|
||||
* @category system
|
||||
* @group Sensor Calibration
|
||||
* @volatile
|
||||
*/
|
||||
PARAM_DEFINE_FLOAT(CAL_MAG0_TEMP, NAN);
|
||||
PARAM_DEFINE_FLOAT(CAL_MAG0_TEMP, -1000.f);
|
||||
|
|
|
@ -241,8 +241,9 @@ PARAM_DEFINE_FLOAT(CAL_MAG1_ZCOMP, 0.0f);
|
|||
*
|
||||
* Temperature during last calibration.
|
||||
*
|
||||
* @unit celcius
|
||||
* @category system
|
||||
* @group Sensor Calibration
|
||||
* @volatile
|
||||
*/
|
||||
PARAM_DEFINE_FLOAT(CAL_MAG1_TEMP, NAN);
|
||||
PARAM_DEFINE_FLOAT(CAL_MAG1_TEMP, -1000.f);
|
||||
|
|
|
@ -241,8 +241,9 @@ PARAM_DEFINE_FLOAT(CAL_MAG2_ZCOMP, 0.0f);
|
|||
*
|
||||
* Temperature during last calibration.
|
||||
*
|
||||
* @unit celcius
|
||||
* @category system
|
||||
* @group Sensor Calibration
|
||||
* @volatile
|
||||
*/
|
||||
PARAM_DEFINE_FLOAT(CAL_MAG2_TEMP, NAN);
|
||||
PARAM_DEFINE_FLOAT(CAL_MAG2_TEMP, -1000.f);
|
||||
|
|
|
@ -241,8 +241,9 @@ PARAM_DEFINE_FLOAT(CAL_MAG3_ZCOMP, 0.0f);
|
|||
*
|
||||
* Temperature during last calibration.
|
||||
*
|
||||
* @unit celcius
|
||||
* @category system
|
||||
* @group Sensor Calibration
|
||||
* @volatile
|
||||
*/
|
||||
PARAM_DEFINE_FLOAT(CAL_MAG3_TEMP, NAN);
|
||||
PARAM_DEFINE_FLOAT(CAL_MAG3_TEMP, -1000.f);
|
||||
|
|
Loading…
Reference in New Issue