Hello guys,
Problem:
If the primary gyro fails the multicopter attitude controller will not fall-back on secondary gyro but instead it stops functioning. If for example, the primary gyro is an external IMU connected over a cable to PX4, this failure can not be excluded.
Cause:
In the main loop in the method MulticopterAttitudeControl::run() line 838 we have the code:
while (!should_exit()) {
poll_fds.fd = _sensor_gyro_sub[_selected_gyro];
/* wait for up to 100ms for data */
int pret = px4_poll(&poll_fds, 1, 100);
/* timed out - periodic check for should_exit() */
if (pret == 0) {
continue;
}
…
If the selected gyro timesout, the main loop will just wait indefinitely for it or for module exit. This can have “severely unpleasant” effects if happens in flight.
Proposed solution:
Since the sensor modules falls-back on the secondary gyro, we can just update the _selected_gyro in case of time-out and then the controller can keep flying. It is enough to change the if statement to:
if (pret == 0) {
sensor_correction_poll();
continue;
}
in order to achieve an automatic switch to the next gyro selected by sensor module.
Question:
Do you see any problem with this mitigation?
Do you consider a good idea to also attempt it after a certain number of consecutive failure of poll function (i.e. the next if statement in the code)?
Thank you,
MTM