mirror of
https://github.com/iNavFlight/inav.git
synced 2025-07-23 16:25:26 +03:00
Merge pull request #9558 from breadoven/abo_wp_inhibit_7-1
WP mission mode RTH and Manual mode lockout improvements 7.1.0
This commit is contained in:
commit
e09bae2bcc
1 changed files with 30 additions and 29 deletions
|
@ -3840,7 +3840,6 @@ void checkManualEmergencyLandingControl(bool forcedActivation)
|
|||
|
||||
static navigationFSMEvent_t selectNavEventFromBoxModeInput(void)
|
||||
{
|
||||
static bool canActivateWaypoint = false;
|
||||
static bool canActivateLaunchMode = false;
|
||||
|
||||
//We can switch modes only when ARMED
|
||||
|
@ -3888,10 +3887,20 @@ static navigationFSMEvent_t selectNavEventFromBoxModeInput(void)
|
|||
}
|
||||
posControl.rthSanityChecker.rthSanityOK = true;
|
||||
|
||||
// Keep canActivateWaypoint flag at FALSE if there is no mission loaded
|
||||
// Also block WP mission if we are executing RTH
|
||||
if (!isWaypointMissionValid() || isExecutingRTH) {
|
||||
/* WP mission activation control:
|
||||
* canActivateWaypoint & waypointWasActivated are used to prevent WP mission
|
||||
* auto restarting after interruption by Manual or RTH modes.
|
||||
* WP mode must be deselected before it can be reactivated again. */
|
||||
static bool waypointWasActivated = false;
|
||||
const bool isWpMissionLoaded = isWaypointMissionValid();
|
||||
bool canActivateWaypoint = isWpMissionLoaded && !posControl.flags.wpMissionPlannerActive; // Block activation if using WP Mission Planner
|
||||
|
||||
if (waypointWasActivated && !FLIGHT_MODE(NAV_WP_MODE)) {
|
||||
canActivateWaypoint = false;
|
||||
if (!IS_RC_MODE_ACTIVE(BOXNAVWP)) {
|
||||
canActivateWaypoint = true;
|
||||
waypointWasActivated = false;
|
||||
}
|
||||
}
|
||||
|
||||
/* Airplane specific modes */
|
||||
|
@ -3927,22 +3936,20 @@ static navigationFSMEvent_t selectNavEventFromBoxModeInput(void)
|
|||
}
|
||||
}
|
||||
|
||||
// Failsafe_RTH (can override MANUAL)
|
||||
/* If we request forced RTH - attempt to activate it no matter what
|
||||
* This might switch to emergency landing controller if GPS is unavailable */
|
||||
if (posControl.flags.forcedRTHActivated) {
|
||||
// If we request forced RTH - attempt to activate it no matter what
|
||||
// This might switch to emergency landing controller if GPS is unavailable
|
||||
return NAV_FSM_EVENT_SWITCH_TO_RTH;
|
||||
}
|
||||
|
||||
/* Pilot-triggered RTH (can override MANUAL), also fall-back for WP if there is no mission loaded
|
||||
* Prevent MANUAL falling back to RTH if selected during active mission (canActivateWaypoint is set false on MANUAL selection)
|
||||
* Also prevent WP falling back to RTH if WP mission planner is active */
|
||||
const bool blockWPFallback = IS_RC_MODE_ACTIVE(BOXMANUAL) || posControl.flags.wpMissionPlannerActive;
|
||||
if (IS_RC_MODE_ACTIVE(BOXNAVRTH) || (IS_RC_MODE_ACTIVE(BOXNAVWP) && !canActivateWaypoint && !blockWPFallback)) {
|
||||
/* Pilot-triggered RTH, also fall-back for WP if there is no mission loaded.
|
||||
* WP prevented from falling back to RTH if WP mission planner is active */
|
||||
const bool wpRthFallbackIsActive = IS_RC_MODE_ACTIVE(BOXNAVWP) && !isWpMissionLoaded && !posControl.flags.wpMissionPlannerActive;
|
||||
if (IS_RC_MODE_ACTIVE(BOXNAVRTH) || wpRthFallbackIsActive) {
|
||||
// Check for isExecutingRTH to prevent switching our from RTH in case of a brief GPS loss
|
||||
// If don't keep this, loss of any of the canActivateNavigation && canActivateAltHold
|
||||
// Without this loss of any of the canActivateNavigation && canActivateAltHold
|
||||
// will kick us out of RTH state machine via NAV_FSM_EVENT_SWITCH_TO_IDLE and will prevent any of the fall-back
|
||||
// logic to kick in (waiting for GPS on airplanes, switch to emergency landing etc)
|
||||
// logic kicking in (waiting for GPS on airplanes, switch to emergency landing etc)
|
||||
if (isExecutingRTH || (canActivateNavigation && canActivateAltHold && STATE(GPS_FIX_HOME))) {
|
||||
return NAV_FSM_EVENT_SWITCH_TO_RTH;
|
||||
}
|
||||
|
@ -3950,24 +3957,20 @@ static navigationFSMEvent_t selectNavEventFromBoxModeInput(void)
|
|||
|
||||
// MANUAL mode has priority over WP/PH/AH
|
||||
if (IS_RC_MODE_ACTIVE(BOXMANUAL)) {
|
||||
canActivateWaypoint = false; // Block WP mode if we are in PASSTHROUGH mode
|
||||
return NAV_FSM_EVENT_SWITCH_TO_IDLE;
|
||||
}
|
||||
|
||||
// Pilot-activated waypoint mission. Fall-back to RTH in case of no mission loaded
|
||||
// Block activation if using WP Mission Planner
|
||||
// Also check multimission mission change status before activating WP mode
|
||||
// Pilot-activated waypoint mission. Fall-back to RTH if no mission loaded.
|
||||
// Also check multimission mission change status before activating WP mode.
|
||||
#ifdef USE_MULTI_MISSION
|
||||
if (updateWpMissionChange() && IS_RC_MODE_ACTIVE(BOXNAVWP) && !posControl.flags.wpMissionPlannerActive) {
|
||||
if (updateWpMissionChange() && IS_RC_MODE_ACTIVE(BOXNAVWP) && canActivateWaypoint) {
|
||||
#else
|
||||
if (IS_RC_MODE_ACTIVE(BOXNAVWP) && !posControl.flags.wpMissionPlannerActive) {
|
||||
if (IS_RC_MODE_ACTIVE(BOXNAVWP) && canActivateWaypoint) {
|
||||
#endif
|
||||
if (FLIGHT_MODE(NAV_WP_MODE) || (canActivateWaypoint && canActivateNavigation && canActivateAltHold && STATE(GPS_FIX_HOME)))
|
||||
if (FLIGHT_MODE(NAV_WP_MODE) || (canActivateNavigation && canActivateAltHold && STATE(GPS_FIX_HOME))) {
|
||||
waypointWasActivated = true;
|
||||
return NAV_FSM_EVENT_SWITCH_TO_WAYPOINT;
|
||||
}
|
||||
else {
|
||||
// Arm the state variable if the WP BOX mode is not enabled
|
||||
canActivateWaypoint = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (IS_RC_MODE_ACTIVE(BOXNAVPOSHOLD)) {
|
||||
|
@ -3998,8 +4001,6 @@ static navigationFSMEvent_t selectNavEventFromBoxModeInput(void)
|
|||
return NAV_FSM_EVENT_SWITCH_TO_ALTHOLD;
|
||||
}
|
||||
} else {
|
||||
canActivateWaypoint = false;
|
||||
|
||||
// Launch mode can be activated if feature FW_LAUNCH is enabled or BOX is turned on prior to arming (avoid switching to LAUNCH in flight)
|
||||
canActivateLaunchMode = isNavLaunchEnabled() && (!sensors(SENSOR_GPS) || (sensors(SENSOR_GPS) && !isGPSHeadingValid()));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue