sensors: fix IMU init race condition

- IMU init requires valid published data (device ids, etc)
 - orb_group_count will include advertised instances before data is published, so this can't be used to throttle IMU init attempts
This commit is contained in:
Daniel Agar 2021-06-17 10:38:33 -04:00 committed by GitHub
parent b2742658b7
commit 76a8617529
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 3 deletions

View File

@ -665,7 +665,7 @@ void Sensors::Run()
// keep adding sensors as long as we are not armed,
// when not adding sensors poll for param updates
if (!_armed && hrt_elapsed_time(&_last_config_update) > 500_ms) {
if (!_armed && hrt_elapsed_time(&_last_config_update) > 1000_ms) {
const int n_accel = orb_group_count(ORB_ID(sensor_accel));
const int n_baro = orb_group_count(ORB_ID(sensor_baro));
@ -679,15 +679,18 @@ void Sensors::Run()
_n_gps = n_gps;
_n_gyro = n_gyro;
_n_mag = n_mag;
parameters_update();
_voted_sensors_update.initializeSensors();
InitializeVehicleAirData();
InitializeVehicleIMU();
InitializeVehicleGPSPosition();
InitializeVehicleMagnetometer();
}
// sensor device id (not just orb_group_count) must be populated before IMU init can succeed
_voted_sensors_update.initializeSensors();
InitializeVehicleIMU();
_last_config_update = hrt_absolute_time();
} else {