Repository navigation
Conversation
The test gave the selector a fixed 2.5 s to switch away from the warned primary. When a fresh selector first picks instance 1 and settleBaseline() moves it back to 0, instance 1 was just selected and the selector blocks switching back to it for 10 s, so the test failed on CI: https://github.com/PX4/PX4-Autopilot/actions/runs/45669361735/job/139400126257 Use degradeUntilSwitched() like the other switch-away tests, which publishes the same data until the switch happens, within 15 s.
The selection logic read the clock about a dozen times per cycle, so it could only be tested in real time. Run() now reads it once and passes it to Update(now), which the selection logic, the sensor_selection and the selector status use. Tests can call Update() with a simulated time.
The test ran the selector on its work queue in real time. Which instance a fresh selector picked first depended on thread scheduling, and when it picked instance 1 the selector's 10 s lockout made timedOutPrimaryFallsBackImmediately fail: https://github.com/PX4/PX4-Autopilot/actions/runs/45669361735/job/139400126257 The test now steps Update() on a simulated clock without starting the work queue. The selector always starts on instance 0, every run behaves the same, and the suite takes milliseconds instead of about 26 s.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Solved Problem
EKF2SelectorTest fails intermittently, e.g. this run. The test ran the selector on its work queue in real time. Which instance a fresh selector picked first depended on thread scheduling, and when it picked instance 1, the selector's 10 s lockout on recently selected instances made the test time out.
Solution
EKF2Selector::Run()reads the clock once per cycle and passes it toUpdate(now). The selection logic,sensor_selectionand the selector status all use that time.nowminus the sample timestamp wrap around and drop them as stale.Update()directly on a simulated clock without starting the work queue. The selector always starts on instance 0, every run behaves the same, and the suite takes milliseconds instead of about 26 s.Changelog Entry
No change in flight behaviour.
Test coverage
timedOutPrimaryFallsBackImmediatelyfails. With sustained warnings ignored, i.e. the fix for [Bug] v1.17.0 - Altitude spikes in fixed wing mode #27013 reverted,noFallbackToSustainedWarnedInstancefails.