mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-11-22 14:19:57 +08:00
* fix(navigator): keep RTL using the checked mission after a Home update Since25a903f403(#27804), RTL uses the mission only while the mission check result carries the current Home update counter. Mission reruns the check only for a new mission or fence, or when Mission mode activates, but Commander also updates Home at arming, at takeoff outside a mission, when the disarmed vehicle is moved, on the GNSS altitude correction in the first 120 s after takeoff and on DO_SET_HOME. After any of these, and until the check ran again, RTL_TYPE 2 and 4 returned directly instead of along the mission, types 1 and 3 ignored the mission landing and the remaining time estimate used the direct path. Type 1 is the FW and VTOL default, so every FW or VTOL that armed outside Mission ignored its mission landing. Match only the mission and fence IDs, so a Home update leaves the verdict in place as it did before25a903f403. Rechecking on every Home update instead would recheck in flight: the RTL mission modes inherit MissionBase::on_inactive() and run every cycle, so even the inactive Return mode would rerun the check, and a check that now fails makes Commander fail over out of Mission. Assisted-by: Claude:claude-opus-5-5 * fix(navigator): let Return's mission modes keep Mission's verdict RTL creates a new mission-based Return mode whenever the return type changes, for example when RTL_TYPE 4 switches from the reverse to the forward mission. The new mode starts with its mission check unchecked, so its first cycle reruns the check if Home was updated since Mission checked the mission. Before the previous commit RTL used the mission only while the result carried the current Home counter; now it also creates these modes after a Home update, in flight too. There a recheck with the new Home can reject the mission being flown: an absolute takeoff altitude now below Home, GF_MAX_HOR_DIST or GF_MAX_VER_DIST measured from the new Home over items already flown, or a landing relative to Home now above its absolute approach. The result is shared, so Commander would fail over out of Mission, and a Return that creates the mode at activation would loiter instead of following the mission. RTL creates these modes only for a mission and fence that Mission has already checked, so start them with the check complete. A new mission or fence still triggers a check through the existing path, and in flight a Home update keeps the verdict, as it does for Mission. A mode created at Return activation, or in the last inactive cycle before it, also no longer reloads its items in its first active cycle. On the ground that reload started the mission that on_activation() had just declined because the vehicle is landed (for RtlDirectMissionLand, its landing). Assisted-by: Claude:claude-opus-5-5 * fix(navigator): recheck the mission when armed on the ground Mission checks the mission when the mission or fence changes and when Mission mode starts, not when Home is updated, and RTL now keeps that verdict after a Home update. Home follows the disarmed vehicle and is set again at arming and on DO_SET_HOME, so a verdict from an older Home can be wrong for the Home the vehicle takes off from. For example a fixed-wing landing relative to Home ends up above its absolute approach when Home moves up, which FeasibilityChecker::checkFixedWingLandApproach() rejects, yet Return with RTL_TYPE 1 (the fixed-wing and VTOL default) would fly it. Mission, which owns the check, now asks for a recheck when it is armed on the ground before takeoff and the verdict was computed with an older Home. The existing path reruns the check and, if Mission is active, reloads its items. While disarmed the verdict is kept, so moving the vehicle around does not recheck on every Home update. No state is needed: Commander clears takeoff_time only at disarm, and the land detector reports the takeoff before Commander sets Home for it, so a Home update in flight or after a landing keeps the verdict. So on the ground the check reruns once armed; in flight a Home update keeps the verdict, and relative altitudes (also Return's mission landing) follow the current Home, as for an active Mission. Assisted-by: Claude:claude-opus-5-5 * docs(navigator): correct why RTL does not compare Home The comment said a Home update never re-runs the mission check, but since the previous commit Mission rechecks once armed on the ground. Assisted-by: Claude:claude-opus-5-5 * refactor(navigator): clarify intent behind check --------- Co-authored-by: jonas <jonas.perolini@rigi.tech>