mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-04-14 10:07:39 +08:00
sensors/vehicle_imu: improve disabled sensor handling
- remove regular callback scheduling when sensor is disabled, register if re-enabled
This commit is contained in:
parent
3140bf167c
commit
7ff72304b4
@ -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;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user