Repository navigation
Conversation
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 The EKF3 change does what it says for Copter, but the new autotest fails at this head, and Replay of non-Copter logs now diverges from the flight. Blocking
Should fix
|
285e3a8 to
06f1cf3
Compare
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 The EKF3 change still works for Copter, and the new autotest now passes; one non-blocking Replay issue remains. Should fix
|
Global Size Summary (Total Flash delta in bytes)Built from d094779 rebased onto 97a060c
|
|
Tested in SITL on the landing test from the #35077 thread, renamed for FLOW_ALT_MIN: 3 runs on #35077 plus this PR against 2 on #35077 alone. The LOITER failsafe at +4.4 s after LAND_COMPLETE is gone, aiding holds until DISARM_DELAY in all four legs, and the ALT_HOLD legs with bad flow on the ground walk 0.05 m. EK3YawAlignEachTakeoff passes. One case it does not cover, and three points for the description:
|
06f1cf3 to
3993abc
Compare
Previous review (2026-11-12)Automated review note — AI-generated (Claude+Codex), validated against the live diff. Please sanity-check before acting. Reviewed at head The landed-flag change works for Copter and the new test passes at this head; one non-blocking THROW-mode regression remains. Should fix
Minor (2)
Withdrawn: CompassLearnDisabledDoesNotSave does not need to reach the held copy, because it tests the COMPASS_LEARN guard by design. |
|
One more case beside THROW: a mid-air disarm followed by a re-arm. Disarm forces land_complete, and once re-armed only throttle above the non-takeoff level clears it, so vehicle_landed stays set while the copter falls. On master onGround goes false on the first EKF cycle after arming. In SITL on #32972, re-arms in Stabilize at zero throttle and in ALT_HOLD with the stick at 1450, 1500 and 1550 all stayed landed and fell at 15-17 m/s, one of them for about 9 s. From the source, through that window the compass is fused without its innovation check, and the in-flight yaw and field reset is held off with its flags cleared each cycle. #32768 handles the same case for its arm-time height datum reset, which zeroes the vertical velocity. There ap.disarmed_in_air is set by a disarm with land_complete clear, or by a watchdog reset while armed, and only the disarmed land detector clears it, once the airframe has stopped accelerating and descending. The reset is skipped while it is set. If #32768 goes in, reporting landed only while disarmed_in_air is clear would cover this. set_land_complete() returns early when nothing changes, so the flag would also need setting where the land detector clears disarmed_in_air. |
|
See this comment in the method you're modifying: ... and discussion on #28389 (comment) ... and #2074 (comment) |
3993abc to
ebdff68
Compare
|
@AP-Review, thanks for the review. RE the "Should fix" item for THROW mode - I disagree with the suggestion to add ahrs.set_vehicle_landed(false) to Throw mode because it bypasses Copter's land_complete flag and thus means the vehicle code land_complete and EKF state could become inconsistent. The behaviour change is that the EKF's in-flight yaw alignment cannot happen until after the throw is detected but I think this could actually be preferable because the pilot might have a metal watch on (or similar). I've added a comment about this behaviour change to the PR description I've also updated the rangefinder bullet point |
Previous review (2026-11-16)Automated review note — AI-generated (Claude+Codex), validated against the live diff. Please sanity-check before acting. Reviewed at head The landed-flag change still works for Copter, and both new tests pass at this head. Two non-blocking points remain, one of them an unanswered reviewer case. Should fix
Note
Withdrawn: the new AP_Arming "until the next arm" wording is accurate as a lower bound (Copter keeps the field until takeoff). |
|
Thanks @AP-Review for the review. Re the "Should fix" item, I've slightly updated the PR description to specify the change in behaviour after an in-air re-arm. This whole line of thinking is a bit ridiculous though, Copter has never guaranteed that in-air re-arms are possible and beyond that, worry about the minor impacts on XY accel biases is the least of the worries in that situation. |
| } | ||
|
|
||
| bool get_vehicle_landed(void) const { | ||
| return vehicle_landed; |
There was a problem hiding this comment.
Could the AHRS call through to vehicle and get the likely flying flag?
There was a problem hiding this comment.
Hi @IamPete1,
Txs for the review and comments. I think that's technically possible but I think that's the wrong direction for data/state to flow. I think the AHRS is lower on the stack than the vehicle code.
There was a problem hiding this comment.
That works too it just seems odd to see copter setting the same information into both vehicle and ahrs.
Vehicles can use it to tell the estimators they have landed even though they are still armed. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
It is the first bit of a new Flags2 byte, appended to RFRN so that logs without it replay as not landed. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
An armed Copter that has landed now gets the same on-ground behaviour as when disarmed. This includes the GPS checks, zero velocity fusion when not moving, compass heading fused regardless of innovations This leads to the EKF3 fusing all-zero optical flow values on a Copter flying with optical flow that has just landed but has not yet disarmed. Copter/Heli tells the AHRS when it has landed using AP_AHRS::set_vehicle_landed which reaches the EKF through the DAL. With this change, EKF3 uses this to set onGround and clear inFlight flags. Other vehicles do not set it so they are unaffected, and Replay of their logs is unchanged. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
EKF3 clears its in-flight yaw and magnetic field initialisation when the vehicle is on the ground so that it is redone on each takeoff. Take off, land without disarming and take off again, and check the in-flight yaw alignment is reported after both takeoffs. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
ebdff68 to
d094779
Compare
|
Automated review note — AI-generated (Claude+Codex), validated against the live diff. Please sanity-check before acting. Reviewed at head The landed-flag change still works at this head, which is a clean rebase of the code reviewed before. The new test passes and still fails with the EKF3 change reverted. Minor (2)
CI was still running at review time, with no failures so far. |
|
Thanks @AP-Review for the ACCEPT. I've fixed up the PR description typos. |
Summary
This EKF3 change causes a Copter that has just landed to get the same on-ground behaviour as when disarmed. This includes the GPS checks, zero velocity fusion when not moving, compass heading fused regardless of innovations and fusing of all-zero optical flow values.
While a separate change, this will have the side effect of resolving the "landing in loiter" issue from PR #35077. This issue involves the EKF failsafe triggering during a land.
How it works
Behaviour Changes
Before this change, an armed Copter that landed stayed onGround=false and inFlight=true until disarmed, since inFlight is only cleared on disarm. Before takeoff it was onGround=false, inFlight=false. Here's a table showing the change:
In master,
inFlightis only cleared on disarm. With this PR a landed Copter gets the same on-ground behaviour as when disarmed, which means:With this PR after the Copter has landed both states are onGround=true, inFlight=false which means:
Plane/QuadPlane is not affected by this change. Rover, Sub, Tracker and Blimp never set the flag so they are not affected either, including in Replay.
EKF3 now depends on Copter's land detector being correct. If it reports "landed" while flying, the EKF would use its on-ground behaviour in the air (for example zero velocity fusion and wind estimation off). Heli uses the same flag and has not been tested.
This existing issue was discovered: #35197 but it is beyond the scope of this PR to resolve.
Testing
An auto test, EK3YawAlignEachTakeoff, has been added that checks that the yaw reset happens twice (in total) if a vehicle takes off, then lands and takes off again.
I've also tested this manually and attached screen shots below. The test in SITL was:
Before we see only a single yaw reset

After we see a second yaw reset when the vehicle takes off again

Classification & Testing (check all that apply and add your own)
Claude helped me greatly in the creation and testing of this PR