mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-11-01 07:21:37 +08:00
DataValidator: fix unexpected failover
Instead of always starting with instance 0 (potentially an internal mag), first take the current sensor as reference to compare the other ones against it. The issue is that otherwise we can end up in a situation where a switch occurs because the currently used sensor isn't much better than a sensor with a lower index: because the selected one isn't much better, we cannot "fail-over" to it and get stuck on another sensor, triggering a fail-over.
This commit is contained in:
@@ -153,14 +153,32 @@ float *DataValidatorGroup::get_best(uint64_t timestamp, int *index)
|
|||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
|
// First find the current selected sensor
|
||||||
|
while (next != nullptr) {
|
||||||
|
if (i == pre_check_best) {
|
||||||
|
const int prio = next->priority();
|
||||||
|
const float confidence = next->confidence(timestamp);
|
||||||
|
|
||||||
|
pre_check_prio = prio;
|
||||||
|
pre_check_confidence = confidence;
|
||||||
|
|
||||||
|
max_index = i;
|
||||||
|
max_confidence = confidence;
|
||||||
|
max_priority = prio;
|
||||||
|
best = next;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
next = next->sibling();
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
next = _first;
|
||||||
|
|
||||||
while (next != nullptr) {
|
while (next != nullptr) {
|
||||||
float confidence = next->confidence(timestamp);
|
float confidence = next->confidence(timestamp);
|
||||||
|
|
||||||
if (i == pre_check_best) {
|
|
||||||
pre_check_prio = next->priority();
|
|
||||||
pre_check_confidence = confidence;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Switch if:
|
* Switch if:
|
||||||
* 1) the confidence is higher and priority is equal or higher
|
* 1) the confidence is higher and priority is equal or higher
|
||||||
|
|||||||
Reference in New Issue
Block a user