sensors/vehicle_imu: improve disabled sensor handling

- remove regular callback scheduling when sensor is disabled, register if re-enabled
This commit is contained in:
Daniel Agar 2021-11-22 21:10:35 -05:00 committed by GitHub
parent 3140bf167c
commit 7ff72304b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -141,11 +141,17 @@ void VehicleIMU::Run()
{
const hrt_abstime now_us = hrt_absolute_time();
ParametersUpdate();
if (!_accel_calibration.enabled() || !_gyro_calibration.enabled()) {
_sensor_gyro_sub.unregisterCallback();
ScheduleDelayed(1_s);
return;
}
// backup schedule
ScheduleDelayed(_backup_schedule_timeout_us);
ParametersUpdate();
// check vehicle status for changes to armed state
if (_vehicle_control_mode_sub.updated()) {
vehicle_control_mode_s vehicle_control_mode;
@ -155,10 +161,6 @@ void VehicleIMU::Run()
}
}
if (!_accel_calibration.enabled() || !_gyro_calibration.enabled()) {
return;
}
// reset data gap monitor
_data_gap = false;
@ -622,6 +624,7 @@ void VehicleIMU::UpdateIntegratorConfiguration()
if (gyro_integral_samples % n == 0) {
_sensor_gyro_sub.set_required_updates(n);
_sensor_gyro_sub.registerCallback();
_intervals_configured = true;
_update_integrator_config = false;