Repository navigation
Scripted Bendy Ruler based Object Avoidance for Plane - #33955
timtuxworth wants to merge 10 commits into
Conversation
720feb8 to
6bdc295
Compare
6bdc295 to
874bb0f
Compare
Previous review (2026-08-10)Automated review note — AI-generated (Claude), cross-checked by an independent second model against the live diff. Please sanity-check before acting. Reviewed at head Verdict: REQUEST CHANGES
Full report: https://uav.tridgell.net/DevCallReviews/2026_08_11/devcall_pr_reviews.html |
I've now verified every finding against the actual code (the report itself carries no rationale beyond the locations, so my trace is the authority). Here's the triage — 4 are real, 1 is a real-but-known approximation, 1 is not a bug. Confirmed bugs (clear fix)
Real but not a crash
Not a bug
Recommendation: fix #1, #2, #4 now (unambiguous, low-risk), confirm the intended state for #3, and defer #5 as a follow-up. I'd do them on scripted-oa (granular commits), bump to v048, rerun the DAA |
Previous review (2026-10-20)Automated review note — AI-generated (Claude+Codex), validated against the live diff. Please sanity-check before acting. Reviewed at head This review covers 9e9a687. That is the head your 20 Oct reply describes, rebased onto dc78bc5, and it was still the PR head at 15:45 UTC on 20 Oct. The last note here covered 68cbd95. All three review passes completed. Only the first pass and this note ran SITL; the other two used offline harnesses. CI was still queued at this head (79 of 80 check runs queued at 15:45 UTC on 20 Oct), so it is unconfirmed. Thanks for the fixes. Last round's blocker is closed. With the live-mode guards (planedaa.lua:1435, planedaa.lua:1796), PlaneDAALoiterRespectsPilotTakeover and PlaneDAATrapRespectsPilotTakeover pass at head and fail with their guard removed. PlaneDAAAircraftModifiedTau fails with the tau decision disabled and still passes with only the first-fix fallback disabled, so it covers the right branch. The cold-cache terrain and populated-cache wind tests pass, all 46 PlaneDAA tests passed in one session, and header-check rebuilds pass at every commit in the new order. The wording fixes match the code. Needs fixing before merge:
Not blocking:
Not run: a real RC switch, GCS or failsafe timing for the guards and for item 1, hardware, a real carried or thrown launch, QuadPlane, AUTOLAND, go-arounds, a landing with a contact present, real ADS-B timing, other vehicles and the non-DAA Plane tests. Each SITL scenario here was run once or twice, so the runs show the behaviour exists, not how often it happens. |
Addressed the blocking loiter-handback issue in 061e825. Added two SITL regression tests covering zero-cooldown release and forced cleanup with cooldown pending. Both pass with the fix and fail with it removed. Updated Rebased onto master at 9c412ba and rebuilt with header checks enabled. The full DAA run had 47 passes and one post-test reboot timeout waiting for RC_CHANNELS; that test and both neighbours passed on retry without code changes. The nonblocking findings remain outstanding, including the residual non-atomic mode-check/command window. These changes and tests were AI-assisted. |
Previous review (2026-10-20)Automated review note — AI-generated (Claude+Codex), validated against the live diff. Please sanity-check before acting. Reviewed at head This review covers 061e825, which was still the PR head at 20:40 UTC on 20 Oct. CI was still queued (78 of 79 check runs), so it is unconfirmed. All three review passes completed. Thanks for the fix: the loiter handback blocker is closed. PlaneDAALoiterHandbackRespectsPilotTakeover, PlaneDAALoiterForcedStopRespectsPilotTakeover and last round's review-only probe pass in SITL at this head and fail with the new check at daaltr.lua:272 removed. Should fix
Low
Minor (5)
Not run: SITL for the trap/dropout and retarget items, real RC, GCS or failsafe timing, the full PlaneDAA suite at this head, hardware, QuadPlane, AUTOLAND, go-arounds, landing with traffic, real ADS-B timing and other vehicles. |
|
Added a home-to-fence pre-arm check in 202d00f. It uses auxiliary arming authorization, like
The check compares home’s clearance from enabled horizontal fences against the DAA buffer, including the current estimated wind allowance. It clears when clearance improves or DAA avoidance is disabled. Documented the limitations: pre-arm wind estimates, fences enabled only after arming/takeoff, shared authorization slots, and the fact that static home clearance does not guarantee a safe RTL approach or VTOL transition. The full 49-test DAA suite passed after rebasing onto master at 95e2ddb. Subsequent documentation and test-only changes added inclusion-circle and inclusion-polygon coverage; the expanded pre-arm test passed on the final submission tree. No flight logic changed in that follow-up. Implementation, documentation and tests were AI-assisted. |
Previous review (2026-10-22)Automated review note — AI-generated (Claude+Codex), validated against the live diff. Please sanity-check before acting. Reviewed at head Nothing blocks this at 202d00f, and CI is green (111 of 111 checks). Since the last review you added the home-to-fence pre-arm check. It behaves as described in our probes and its SITL test passes, but none of the earlier open items changed. Should fix
Low
Minor (6)
Not run: SITL for the trap/dropout, retarget and dropout-order items, the full PlaneDAA suite at this head, real RC/GCS/failsafe timing, hardware, QuadPlane, AUTOLAND and real ADS-B timing. |
|
When demoing at the conference, the Avoid vehicle avoided an unarmed, not-flying multirptor that was sitting on the ground waiting to launch. It should have ignored it as "parked". This was due to the difference between the GPS altitude of the multi rotor vs the avoid vehicle.
Existing saved parameter values are not overwritten by the default change. Validation: Plane SITL build succeeded, and all 49 DAA regression tests passed in one uninterrupted run after the rebase. AI-assisted implementation and validation. |
Previous review (2026-11-03)Automated review note — AI-generated (Claude+Codex), validated against the live diff. Please sanity-check before acting. Reviewed at head Nothing blocks this at 049b902; CI was still queued when this head was captured, so it is unconfirmed. Since the last review the only change is the AVD_GND_ALT default (3 to 10 m) and its test, so nothing from the last round is fixed yet, and the new default brings one new issue. Should fix
Low
Minor (9)
Not run: SITL for the trap/dropout, retarget, dropout-order and smoothing items, the full PlaneDAA suite at this head, real RC/GCS/failsafe timing, hardware, QuadPlane, AUTOLAND and real ADS-B timing. |
|
@IamPete1 I don't think we should move it up to AP_Vehicle for this PR just to avoid the scope creep and testing, but we may well move it up in future. No params (I think?) so it shouldn't be a hard move |
|
Applied @peterbarker ’s suggestion: renamed the Plane Rebased onto current master. Plane SITL build succeeded, and all 49 DAA regression tests passed in one uninterrupted run. We just need your blessing @IamPete1 ! |
|
I asked Codex about the mutable semaphore (originally added by Claude) - this is the assessment: The semaphore already exists upstream. This PR adds mutable and makes its accessor
I would keep it. It adds no additional semaphore allocation. The important constraint is that the low-level distance helpers rely on their caller holding the lock; tbefore DAA reads the fence data, it locks that data so another thread cannot replace or delete it mid-read. It unlocks the data when finished. |
Previous review (2026-11-10)Automated review note — AI-generated (Claude+Codex), validated against the live diff. Please sanity-check before acting. Reviewed at head Nothing blocks this at 5597c9a; CI was still queued when this head was captured, so it is unconfirmed. Since the last review the head was rebased and the Plane member renamed to Should fix
Low
Minor (10)
Not run: SITL for the trap/dropout, dropout-order, retarget and smoothing items (offline Lua probes only), CI, hardware, QuadPlane, AUTOLAND and real RC/GCS/failsafe and ADS-B timing. |
Previous review (2026-11-11)Automated review note — AI-generated (Claude+Codex), validated against the live diff. Please sanity-check before acting. Reviewed at head Nothing blocks this at 23dd211. CI is still mostly queued; the one red job, check-merge-commits, is a markdownlint install failure that every PR is hitting today. Since the last review the PR was rebased onto master's scripting-guard rename and gained the PlaneDAABindingGuards test. The applet and library code is unchanged, so the earlier items are not fixed yet. All 50 PlaneDAA tests pass at this head, and the new guard test also passes with AP_OASCRIPTING disabled. One new minor item is below. Should fix
Low
Minor (11)
Not run: SITL for the dropout, trap, retarget, smoothing and loiter-radius items (offline Lua probes only), finished CI, hardware, QuadPlane, AUTOLAND and real RC/GCS/failsafe and ADS-B timing. |
|
Rebased onto master and updated scripted DAA for the Lua/external-binding split introduced by #35078:
Validation passed: all 50 DAA regressions, plus the binding test with OAScripting disabled. Plane builds successfully with Lua both with and without OAScripting. The additional Lua-disabled build exposed an existing native custom-controller dependency problem. That fix is submitted separately in #35118. The current check-merge-commits CI failure occurred while installing markdownlint-cli2, before the branch checks ran; it needs a rerun. |
|
As at 2026-11-12 Global Size Summary (Total Flash delta in bytes)Built from 23dd211 rebased onto aea9a1b
|
IamPete1
left a comment
There was a problem hiding this comment.
There are still some outstanding AI review comments.
| FENCE_CIRCLE_EXCLUSION = 5, | ||
| FENCE_POLYGON_INCLUSION = 6, | ||
| FENCE_POLYGON_EXCLUSION = 7, | ||
| FENCE_LUA = 8, |
There was a problem hiding this comment.
What does this mean? Its not clear to me that its used anywhere.
There was a problem hiding this comment.
It's not currently used. It's a placeholder for future integration with @tridge 's Lua fences.
AI-assisted development, review fixes and automated validation under human direction.
AI-assisted development, review fixes and automated validation under human direction.
AI-assisted development, review fixes and automated validation under human direction.
|
Thanks for your reviews @IamPete1 and @rmackay9 . Updated at
Plane SITL builds successfully. All 50 DAA regressions passed in one uninterrupted run. Regarding the three outstanding “Should fix” findings, my intention remains to defer these from the current revision, rather than claim they are resolved:
The latter two need targeted fault-injection coverage and a reviewed recovery change. Passing the existing regression suite does not demonstrate that these cases are handled correctly. I would prefer to address these in a follow-up rather than expand this naming/compatibility revision. They should remain recorded as open findings, not marked fixed. Implementation and validation were AI-assisted. |
AI-assisted development, review fixes and automated validation under human direction.
AI-assisted development, review fixes and automated validation under human direction.
AI-assisted development, review fixes and automated validation under human direction.
AI-assisted development, review fixes and automated validation under human direction.
AI-assisted development, review fixes and automated validation under human direction.
AI-assisted development, review fixes and automated validation under human direction.
AI-assisted development, review fixes and automated validation under human direction.
See above, but specifically: my intention remains to defer these from the current revision, rather than claim they are resolved:
The latter two need targeted fault-injection coverage and a reviewed recovery change. Passing the existing regression suite does not demonstrate that these cases are handled correctly. I would prefer to address these in a follow-up rather than expand this naming/compatibility revision. They should remain recorded as open findings, not marked fixed. |
|
Automated review note — AI-generated (Claude+Codex), validated against the live diff. Please sanity-check before acting. Reviewed at head Nothing blocks this at e273088. CI is still running: 91 of 112 checks have passed and none has failed so far. Since the last review, Should fix
Low
Minor (12)
Not run: SITL reproductions of the dropout, trap, retarget, smoothing and loiter-radius items (offline Lua and extracted C++ probes only), finished CI, hardware, QuadPlane, AUTOLAND and real RC/GCS/failsafe and ADS-B timing. |
Summary
Add planedaa, a scripted Detect-Alert-Avoid (DAA) capability for Plane that avoids geofences and ADS-B traffic, together with the supporting library plumbing (
AP_OAScripting, ADS-B/avoidance queries) and a SITL autotest suite. The feature is compiled out by default.Here's a video of pDAA running in PteroSim at Munich's OlympiaPark - avoiding geofenced no-fly zones and a hovering multi-rotor. https://youtu.be/dV6-yDYsGgs?si=Ku1J4ftYeOpPi8Vl
Classification & Testing (check all that apply and add your own)
Testing
Plane.PlaneDAA*SITL tests, all passing. They cover fence avoidance and breach-escape, fence-label scoping, ADS-B drone and GA-aircraft avoidance, the conservative CPA gate (a converging contact engages, a diverging one is suppressed), the loiter-to-altitude descend commit, altitude-fence clamping, wind-scaled margins, trapped-failsafe no-false-fire, and disable-reverts-target. Traffic is injected asADSB_VEHICLEmessages.Where a test asserts new behaviour it was validated fail-on-neutralized (e.g. the descend test fails when
DAA_AVD_ALTis set to cruise so no descent is possible).Copter.DataFlashErasepasses — confirming the shared-library changes do not alter non-Plane log volume, and that the FENC dev diagnostic stays disabled.APM_BUILD_TYPE(ArduPlane)), verified absent from the Copter binary.luacheckandlua-language-serverclean on the applet.On exercising "the interesting cases" (comment from @tridge auto review on 2026-08-11): these are correctness/robustness fixes without a clean behavioural hook to assert in SITL. The obstacle-type classification doesn't change the avoidance the vehicle actually flies (that keys off the ADS-B emitter type), so it isn't independently observable in a flight test; and the vertical-separation fix only changes detection inside the internally-built look-ahead segment, so isolating it would be geometry- and timing-dependent and flaky. Rather than commit fragile tests, Claude has verified these by inspection — as with the loop-rate and _rsem fixes, which aren't SITL-observable either. The DAA suite stays green.
Description
What.
planedaais a Lua applet that gives Plane a Detect-Alert-Avoid capability for both static (geofence) and dynamic (ADS-B) hazards, without new C++ flight logic.This code is based extensively on the prior work by @tridge Andrew Tridgell and others as part of Canberra UAV and the Outback Challenge in 2018. This work had also been progressed by @NDevDrone Nate Mailhot and @TeteJK Theresa de Jesus Krings in 2024/5 on #28903.
The code implements ASTM3442M-23 for "Well Clear" and "Near Miss" boundaries for crewed aircraft and different boundaries for UAV well clear and near miss based on ACAS sXu and real world testing. These values are all parameterized.
By default the code is only included in SITL and boards with > 2M flash like the CubeRed and Linux boards. It can be built for any 2M board using --enable-AP_OASCRIPTING
This code:
DAA_WIND_MARG) and default to the turn radius (WP_LOITER_RAD) so the standoff is one loiter circle;DAA_AVD_ALT) for GA aircraft to open a vertical gap;FENCE_ALT_MIN/MAX) with proactive level-off; andDAA_TRAP_ACT) that fires on a sustained fence breach or aircraft near-miss.How the code is layered (one subsystem per commit):
AP_Avoidance— the DAA standoff params and thedistance_to_aircraft/obstacle+ emitter-classifier queries used by scripting.AC_Fence— signeddistance_line_to_*fence queries for scripted avoidance.AC_Avoidance—AP_OAScripting, the singleton that exposes fence and ADS-B avoidance to Lua.Plane— QuadPlane holds theAP_OAScriptingmember.AP_Scripting— theplanedaaapplet, its bindings, andplanedaa.md.waf— whitelistAP_OAScripting.hfor theAPM_BUILD_TYPE-in-header check.autotest— thePlaneDAA*test suite.Why. ADS-B and geofence avoidance policy is easier to iterate and tune per-vehicle in Lua than in C++, and keeping it scripted lets operators adjust standoffs, actions and margins without a firmware rebuild. The C++ additions are minimal, generic library queries; all avoidance policy lives in the applet.
Using mostly Lua also allows the easier implementation of different mechanisms for avoidance and failsafes, and limits the flash space impact.
Parameters / migration.
APM_BUILD_TYPE(ArduPlane)— not present on other vehicles):AVD_WCLR_XY,AVD_WCLR_Z,AVD_NMAC_XY,AVD_NMAC_Z,AVD_UAV_XY,AVD_UAV_Z(well-clear / near-miss / UAV standoffs).DAA_*scripting parameters at load; these are documented inlibraries/AP_Scripting/applets/planedaa.md.Scope note. The DAA standoff params and scripted-avoidance methods are gated so they compile only into ArduPlane, and only when --enable-AP_OASCRIPTING is used when compiling. The c++ code and bindings not compiled in by default. ArduCopter/Rover/etc. binaries and parameter tables are unaffected (verified by
Copter.DataFlashErase).This costs a few bytes of flash even when compiled out due to virtual methods required in AP_Vehicle. Trying to compile these out breaks a lot of other because they aren't well behaved consumers of AP_Vehicle, I don't think I can fix this here without extending the scope to a lot of other unrelated vehicles.
Depends on #34032 which has been split out. (Merged)
This contribution was AI-assisted: the applet, C++ library plumbing, and autotests were developed using ChatGPT and DeepSeek and iterated with Claude (Claude Code) under human direction and review, and validated in SITL and extensive field testing on real vehicles.