mirror of
https://github.com/iNavFlight/inav.git
synced 2025-07-26 01:35:35 +03:00
Update navigation.c
This commit is contained in:
parent
8f74cf3e40
commit
9a942a5e97
1 changed files with 32 additions and 26 deletions
|
@ -4322,22 +4322,6 @@ static navigationFSMEvent_t selectNavEventFromBoxModeInput(void)
|
||||||
}
|
}
|
||||||
posControl.rthSanityChecker.rthSanityOK = true;
|
posControl.rthSanityChecker.rthSanityOK = true;
|
||||||
|
|
||||||
/* 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 */
|
/* Airplane specific modes */
|
||||||
if (STATE(AIRPLANE)) {
|
if (STATE(AIRPLANE)) {
|
||||||
// LAUNCH mode has priority over any other NAV mode
|
// LAUNCH mode has priority over any other NAV mode
|
||||||
|
@ -4377,14 +4361,36 @@ static navigationFSMEvent_t selectNavEventFromBoxModeInput(void)
|
||||||
return NAV_FSM_EVENT_SWITCH_TO_RTH;
|
return NAV_FSM_EVENT_SWITCH_TO_RTH;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Pilot-triggered RTH, also fall-back for WP if there is no mission loaded.
|
/* WP mission activation control:
|
||||||
* WP prevented from falling back to RTH if WP mission planner is active */
|
* canActivateWaypoint & waypointWasActivated are used to prevent WP mission
|
||||||
const bool wpRthFallbackIsActive = IS_RC_MODE_ACTIVE(BOXNAVWP) && !isWpMissionLoaded && !posControl.flags.wpMissionPlannerActive;
|
* auto restarting after interruption by Manual or RTH modes.
|
||||||
|
* WP mode must be deselected before it can be reactivated again
|
||||||
|
* WP Mode also inhibited when Mission Planner is active */
|
||||||
|
static bool waypointWasActivated = false;
|
||||||
|
bool canActivateWaypoint = isWaypointMissionValid();
|
||||||
|
bool wpRthFallbackIsActive = false;
|
||||||
|
|
||||||
|
if (IS_RC_MODE_ACTIVE(BOXMANUAL) || posControl.flags.wpMissionPlannerActive) {
|
||||||
|
canActivateWaypoint = false;
|
||||||
|
} else {
|
||||||
|
if (waypointWasActivated && !FLIGHT_MODE(NAV_WP_MODE)) {
|
||||||
|
canActivateWaypoint = false;
|
||||||
|
|
||||||
|
if (!IS_RC_MODE_ACTIVE(BOXNAVWP)) {
|
||||||
|
canActivateWaypoint = true;
|
||||||
|
waypointWasActivated = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
wpRthFallbackIsActive = IS_RC_MODE_ACTIVE(BOXNAVWP) && !canActivateWaypoint;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Pilot-triggered RTH, also fall-back for WP if no mission is loaded.
|
||||||
|
* Check for isExecutingRTH to prevent switching our from RTH in case of a brief GPS loss
|
||||||
|
* 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 kicking in (waiting for GPS on airplanes, switch to emergency landing etc) */
|
||||||
if (IS_RC_MODE_ACTIVE(BOXNAVRTH) || wpRthFallbackIsActive) {
|
if (IS_RC_MODE_ACTIVE(BOXNAVRTH) || wpRthFallbackIsActive) {
|
||||||
// Check for isExecutingRTH to prevent switching our from RTH in case of a brief GPS loss
|
|
||||||
// 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 kicking in (waiting for GPS on airplanes, switch to emergency landing etc)
|
|
||||||
if (isExecutingRTH || (canActivateNavigation && canActivateAltHold && STATE(GPS_FIX_HOME))) {
|
if (isExecutingRTH || (canActivateNavigation && canActivateAltHold && STATE(GPS_FIX_HOME))) {
|
||||||
return NAV_FSM_EVENT_SWITCH_TO_RTH;
|
return NAV_FSM_EVENT_SWITCH_TO_RTH;
|
||||||
}
|
}
|
||||||
|
@ -4398,11 +4404,11 @@ static navigationFSMEvent_t selectNavEventFromBoxModeInput(void)
|
||||||
// Pilot-activated waypoint mission. Fall-back to RTH if no mission loaded.
|
// Pilot-activated waypoint mission. Fall-back to RTH if no mission loaded.
|
||||||
// Also check multimission mission change status before activating WP mode.
|
// Also check multimission mission change status before activating WP mode.
|
||||||
#ifdef USE_MULTI_MISSION
|
#ifdef USE_MULTI_MISSION
|
||||||
if (updateWpMissionChange() && IS_RC_MODE_ACTIVE(BOXNAVWP) && canActivateWaypoint) {
|
if (updateWpMissionChange() && IS_RC_MODE_ACTIVE(BOXNAVWP)) {
|
||||||
#else
|
#else
|
||||||
if (IS_RC_MODE_ACTIVE(BOXNAVWP) && canActivateWaypoint) {
|
if (IS_RC_MODE_ACTIVE(BOXNAVWP)) {
|
||||||
#endif
|
#endif
|
||||||
if (FLIGHT_MODE(NAV_WP_MODE) || (canActivateNavigation && canActivateAltHold && STATE(GPS_FIX_HOME))) {
|
if (FLIGHT_MODE(NAV_WP_MODE) || (canActivateWaypoint && canActivateNavigation && canActivateAltHold && STATE(GPS_FIX_HOME))) {
|
||||||
waypointWasActivated = true;
|
waypointWasActivated = true;
|
||||||
return NAV_FSM_EVENT_SWITCH_TO_WAYPOINT;
|
return NAV_FSM_EVENT_SWITCH_TO_WAYPOINT;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue