Repository navigation
test(geofence): cover emergency breaches and recovery - #30037
Open
JonasPerolini wants to merge 6 commits into
Open
JonasPerolini wants to merge 6 commits into
JonasPerolini wants to merge 6 commits into
Conversation
Navigator and Commander unit tests cover the breach geometry and the action policy of both geofences. SIH flights cover real breaches, the flight mode each action leads to, the Go-to recovery and the next breach. Assisted-by: Codex Assisted-by: Claude:claude-opus-5-5 Signed-off-by: jonas <jonspero@me.com>
Each row is now its own named test: a failing row no longer stops the other rows, the output names the row, and the contingency geofence Terminate exception is a row of its own instead of a ternary. The deferral test now runs Hold, Return and Land on each fence, instead of Land on both. Assisted-by: Claude:claude-opus-5-5 Signed-off-by: jonas <jonspero@me.com>
A name function returns the name of each shape directly. The stream operator only existed to print it. Assisted-by: Claude:claude-opus-5-5 Signed-off-by: jonas <jonspero@me.com>
…ight The refusal flight repeated unit tests: the mission leg check and the target check are covered in the Navigator tests. Only the Go-to handling inside Navigator::run() needs a flight, so the Hold flight now sends a Go-to outside the fence and checks that its Hold does not move. Assisted-by: Claude:claude-opus-5-5 Signed-off-by: jonas <jonspero@me.com>
…d tests Each trigger and each fence is now its own named test, and each action rule is a test of its own. The loop version traced the action as a raw uint8_t byte, so a failure did not say which action failed. Assisted-by: Claude:claude-opus-5-5 Signed-off-by: jonas <jonspero@me.com>
Assisted-by Codex
JonasPerolini
force-pushed
the
JonasPerolini/emergency-geofence-tests
branch
from
November 26, 2026 08:17
332a1e1 to
8dc686c
Compare
julianoes
approved these changes
Nov 26, 2026
| return int(self._system.get_system_id()) | ||
|
|
||
| @contextmanager | ||
| def observe_event(self, *texts: str, name: Optional[str] = None) -> Iterator[threading.Event]: |
Contributor
There was a problem hiding this comment.
We're depending on event strings with this which isn't super pretty, but it's the best we have. And I guess that's ok since the test will break if any of these strings change and we'll adapt it.
JonasPerolini
marked this pull request as ready for review
November 26, 2026 08:29
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.
Summary
Flight and unit tests for the emergency geofence (
GF_ACTION).Problem
No flight tests what an emergency geofence breach does: the flight mode it leads to, how the vehicle is brought back, and which commands are refused. The contingency geofence flights only cover the margin.
Solution
SIH flights, multicopter unless noted:
GF_MAX_HOR_DISTwith Return lands at Home.GF_MAX_VER_DISTwith Hold holds at the limit.GF_SOURCEset to GNSS.Unit tests cover both fences in Commander (action mapping, Go-to takeover, re-entry, the next breach, no deferral) and in Navigator (breach flags for each fence shape, the position source, Go-to targets above
GF_MAX_VER_DIST).Terminate is not flown: in SIH the lockstep stalls once control allocation stops.
Testing
All geofence flights pass in SIH at speed factor 10, the new ones at least three times, and the Warning, altitude and Land flights also at speed factor 1. The recovery flights fail when PX4 refuses a Go-to sent outside the fence, the Hold flight when PX4 accepts a target outside it, and the Land flight when the breach no longer denies arming or is reported as something else.
Assisted-by: Codex, Claude:claude-opus-5-5