gyro_calibration: reset on any sensor timeout

This commit is contained in:
Daniel Agar
2021-11-12 13:47:39 -05:00
parent 29b9e46664
commit 3cb286abc8
2 changed files with 9 additions and 0 deletions
@@ -155,6 +155,7 @@ void GyroCalibration::Run()
if (_gyro_calibration[gyro].device_id() == sensor_gyro.device_id) {
const Vector3f val{Vector3f{sensor_gyro.x, sensor_gyro.y, sensor_gyro.z} - _gyro_calibration[gyro].thermal_offset()};
_gyro_mean[gyro].update(val);
_gyro_last_update[gyro] = sensor_gyro.timestamp;
} else {
// setting device id, reset all
@@ -162,6 +163,13 @@ void GyroCalibration::Run()
Reset();
}
}
if ((_gyro_last_update[gyro] != 0) && (hrt_elapsed_time(&_gyro_last_update[gyro]) > 100_ms)) {
// reset on any timeout
Reset();
_gyro_last_update[gyro] = 0;
return;
}
}
@@ -95,6 +95,7 @@ private:
calibration::Gyroscope _gyro_calibration[MAX_SENSORS] {};
math::WelfordMean<matrix::Vector3f> _gyro_mean[MAX_SENSORS] {};
float _temperature[MAX_SENSORS] {};
hrt_abstime _gyro_last_update[MAX_SENSORS] {};
matrix::Vector3f _acceleration[MAX_SENSORS] {};