mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-06-02 03:49:12 +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:
@@ -141,11 +141,17 @@ void VehicleIMU::Run()
|
|||||||
{
|
{
|
||||||
const hrt_abstime now_us = hrt_absolute_time();
|
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
|
// backup schedule
|
||||||
ScheduleDelayed(_backup_schedule_timeout_us);
|
ScheduleDelayed(_backup_schedule_timeout_us);
|
||||||
|
|
||||||
ParametersUpdate();
|
|
||||||
|
|
||||||
// check vehicle status for changes to armed state
|
// check vehicle status for changes to armed state
|
||||||
if (_vehicle_control_mode_sub.updated()) {
|
if (_vehicle_control_mode_sub.updated()) {
|
||||||
vehicle_control_mode_s vehicle_control_mode;
|
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
|
// reset data gap monitor
|
||||||
_data_gap = false;
|
_data_gap = false;
|
||||||
|
|
||||||
@@ -622,6 +624,7 @@ void VehicleIMU::UpdateIntegratorConfiguration()
|
|||||||
|
|
||||||
if (gyro_integral_samples % n == 0) {
|
if (gyro_integral_samples % n == 0) {
|
||||||
_sensor_gyro_sub.set_required_updates(n);
|
_sensor_gyro_sub.set_required_updates(n);
|
||||||
|
_sensor_gyro_sub.registerCallback();
|
||||||
|
|
||||||
_intervals_configured = true;
|
_intervals_configured = true;
|
||||||
_update_integrator_config = false;
|
_update_integrator_config = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user