mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-16 06:33:34 +08:00
temperature_calibration: make sure to always do an orb_copy() even when already finished
... since we do poll() on the gyro fd.
This commit is contained in:
@@ -78,21 +78,23 @@ void TemperatureCalibrationAccel::reset_calibration()
|
||||
|
||||
int TemperatureCalibrationAccel::update_sensor_instance(PerSensorData &data, int sensor_sub)
|
||||
{
|
||||
if (data.hot_soaked) {
|
||||
// already done
|
||||
return 0;
|
||||
}
|
||||
bool finished = data.hot_soaked;
|
||||
|
||||
bool updated;
|
||||
orb_check(sensor_sub, &updated);
|
||||
|
||||
if (!updated) {
|
||||
return 1;
|
||||
return finished ? 0 : 1;
|
||||
}
|
||||
|
||||
sensor_accel_s accel_data;
|
||||
orb_copy(ORB_ID(sensor_accel), sensor_sub, &accel_data);
|
||||
|
||||
if (finished) {
|
||||
// if we're done, return, but we need to return after orb_copy because of poll()
|
||||
return 0;
|
||||
}
|
||||
|
||||
data.device_id = accel_data.device_id;
|
||||
|
||||
data.sensor_sample_filt[0] = accel_data.x;
|
||||
|
||||
@@ -67,21 +67,23 @@ void TemperatureCalibrationBaro::reset_calibration()
|
||||
|
||||
int TemperatureCalibrationBaro::update_sensor_instance(PerSensorData &data, int sensor_sub)
|
||||
{
|
||||
if (data.hot_soaked) {
|
||||
// already done
|
||||
return 0;
|
||||
}
|
||||
bool finished = data.hot_soaked;
|
||||
|
||||
bool updated;
|
||||
orb_check(sensor_sub, &updated);
|
||||
|
||||
if (!updated) {
|
||||
return 1;
|
||||
return finished ? 0 : 1;
|
||||
}
|
||||
|
||||
sensor_baro_s baro_data;
|
||||
orb_copy(ORB_ID(sensor_baro), sensor_sub, &baro_data);
|
||||
|
||||
if (finished) {
|
||||
// if we're done, return, but we need to return after orb_copy because of poll()
|
||||
return 0;
|
||||
}
|
||||
|
||||
data.device_id = baro_data.device_id;
|
||||
|
||||
data.sensor_sample_filt[0] = 100.0f * baro_data.pressure; // convert from hPA to Pa
|
||||
|
||||
@@ -67,21 +67,23 @@ void TemperatureCalibrationGyro::reset_calibration()
|
||||
|
||||
int TemperatureCalibrationGyro::update_sensor_instance(PerSensorData &data, int sensor_sub)
|
||||
{
|
||||
if (data.hot_soaked) {
|
||||
// already done
|
||||
return 0;
|
||||
}
|
||||
bool finished = data.hot_soaked;
|
||||
|
||||
bool updated;
|
||||
orb_check(sensor_sub, &updated);
|
||||
|
||||
if (!updated) {
|
||||
return 1;
|
||||
return finished ? 0 : 1;
|
||||
}
|
||||
|
||||
sensor_gyro_s gyro_data;
|
||||
orb_copy(ORB_ID(sensor_gyro), sensor_sub, &gyro_data);
|
||||
|
||||
if (finished) {
|
||||
// if we're done, return, but we need to return after orb_copy because of poll()
|
||||
return 0;
|
||||
}
|
||||
|
||||
data.device_id = gyro_data.device_id;
|
||||
|
||||
data.sensor_sample_filt[0] = gyro_data.x;
|
||||
|
||||
Reference in New Issue
Block a user