1
0
Fork 0
mirror of https://github.com/iNavFlight/inav.git synced 2025-07-24 00:35:34 +03:00

Add a 3rd state for nav_rth_allow_landing

New state FS_ONLY allows landing only when RTH is enabled at the
same time as the failsafe mode. This allows the aircraft to land
itself when there's no way to regain control.

Fixes #2344
This commit is contained in:
Alberto García Hierro 2017-10-16 11:42:22 +01:00
parent 1ec2993750
commit 26938321d9
5 changed files with 27 additions and 6 deletions

View file

@ -81,7 +81,7 @@ PG_RESET_TEMPLATE(navConfig_t, navConfig,
.rth_climb_ignore_emerg = 0, // Ignore GPS loss on initial climb
.rth_tail_first = 0,
.disarm_on_landing = 0,
.rth_allow_landing = 1,
.rth_allow_landing = NAV_RTH_ALLOW_LANDING_ALWAYS,
},
// General navigation parameters
@ -993,7 +993,7 @@ static navigationFSMEvent_t navOnEnteringState_NAV_STATE_RTH_LANDING(navigationF
return NAV_FSM_EVENT_SWITCH_TO_EMERGENCY_LANDING;
}
if (navConfig()->general.flags.rth_allow_landing) {
if (navigationRTHAllowsLanding()) {
float descentVelLimited = 0;
// A safeguard - if surface altitude sensors is available and it is reading < 50cm altitude - drop to low descend speed
@ -2705,6 +2705,13 @@ bool navigationIsFlyingAutonomousMode(void)
return (stateFlags & (NAV_AUTO_RTH | NAV_AUTO_WP));
}
bool navigationRTHAllowsLanding(void)
{
navRTHAllowLanding_e allow = navConfig()->general.flags.rth_allow_landing;
return allow == NAV_RTH_ALLOW_LANDING_ALWAYS ||
(allow == NAV_RTH_ALLOW_LANDING_FS_ONLY && FLIGHT_MODE(FAILSAFE_MODE));
}
#else // NAV
#ifdef GPS