@@ -359,7 +359,7 @@ static navigationFSMEvent_t navOnEnteringState_NAV_STATE_FW_LANDING_ABORT(naviga
359
359
#ifdef USE_GEOZONE
360
360
static navigationFSMEvent_t navOnEnteringState_NAV_STATE_SEND_TO_INITALIZE (navigationFSMState_t previousState );
361
361
static navigationFSMEvent_t navOnEnteringState_NAV_STATE_SEND_TO_IN_PROGRESS (navigationFSMState_t previousState );
362
- static navigationFSMEvent_t navOnEnteringState_NAV_STATE_SEND_TO_FINISHED (navigationFSMState_t previousState );
362
+ static navigationFSMEvent_t navOnEnteringState_NAV_STATE_SEND_TO_FINISHED (navigationFSMState_t previousState );
363
363
#endif
364
364
365
365
static const navigationFSMStateDescriptor_t navFSM [NAV_STATE_COUNT ] = {
@@ -1007,6 +1007,8 @@ static const navigationFSMStateDescriptor_t navFSM[NAV_STATE_COUNT] = {
1007
1007
[NAV_FSM_EVENT_SUCCESS ] = NAV_STATE_IDLE ,
1008
1008
[NAV_FSM_EVENT_ERROR ] = NAV_STATE_IDLE ,
1009
1009
[NAV_FSM_EVENT_SWITCH_TO_IDLE ] = NAV_STATE_IDLE ,
1010
+ [NAV_FSM_EVENT_SWITCH_TO_RTH ] = NAV_STATE_RTH_INITIALIZE ,
1011
+ [NAV_FSM_EVENT_SWITCH_TO_EMERGENCY_LANDING ] = NAV_STATE_EMERGENCY_LANDING_INITIALIZE ,
1010
1012
}
1011
1013
},
1012
1014
@@ -1204,8 +1206,8 @@ static const navigationFSMStateDescriptor_t navFSM[NAV_STATE_COUNT] = {
1204
1206
[NAV_FSM_EVENT_SUCCESS ] = NAV_STATE_SEND_TO_IN_PROGESS ,
1205
1207
[NAV_FSM_EVENT_ERROR ] = NAV_STATE_IDLE ,
1206
1208
[NAV_FSM_EVENT_SWITCH_TO_IDLE ] = NAV_STATE_IDLE ,
1207
- }
1208
- },
1209
+ }
1210
+ },
1209
1211
1210
1212
[NAV_STATE_SEND_TO_IN_PROGESS ] = {
1211
1213
.persistentId = NAV_PERSISTENT_ID_SEND_TO_IN_PROGRES ,
@@ -1217,7 +1219,7 @@ static const navigationFSMStateDescriptor_t navFSM[NAV_STATE_COUNT] = {
1217
1219
.mwError = MW_NAV_ERROR_NONE ,
1218
1220
.onEvent = {
1219
1221
[NAV_FSM_EVENT_TIMEOUT ] = NAV_STATE_SEND_TO_IN_PROGESS , // re-process the state
1220
- [NAV_FSM_EVENT_SUCCESS ] = NAV_STATE_SEND_TO_FINISHED ,
1222
+ [NAV_FSM_EVENT_SUCCESS ] = NAV_STATE_SEND_TO_FINISHED ,
1221
1223
[NAV_FSM_EVENT_SWITCH_TO_IDLE ] = NAV_STATE_IDLE ,
1222
1224
[NAV_FSM_EVENT_SWITCH_TO_ALTHOLD ] = NAV_STATE_ALTHOLD_INITIALIZE ,
1223
1225
[NAV_FSM_EVENT_SWITCH_TO_POSHOLD_3D ] = NAV_STATE_POSHOLD_3D_INITIALIZE ,
@@ -1690,23 +1692,23 @@ static navigationFSMEvent_t navOnEnteringState_NAV_STATE_RTH_HEAD_HOME(navigatio
1690
1692
calculateAndSetActiveWaypointToLocalPosition (geozoneGetCurrentRthAvoidWaypoint ());
1691
1693
return NAV_FSM_EVENT_NONE ;
1692
1694
} else if (geozone .avoidInRTHInProgress ) {
1693
- if (isWaypointReached (geozoneGetCurrentRthAvoidWaypoint (), & posControl .activeWaypoint .bearing )) {
1695
+ if (isWaypointReached (geozoneGetCurrentRthAvoidWaypoint (), & posControl .activeWaypoint .bearing )) {
1694
1696
if (geoZoneIsLastRthWaypoint ()) {
1695
1697
// Already at Home?
1696
1698
fpVector3_t * tmpHomePos = rthGetHomeTargetPosition (RTH_HOME_ENROUTE_PROPORTIONAL );
1697
1699
if (isWaypointReached (tmpHomePos , & posControl .activeWaypoint .bearing )) {
1698
1700
setDesiredPosition (tmpHomePos , posControl .rthState .homePosition .heading , NAV_POS_UPDATE_XY | NAV_POS_UPDATE_Z | NAV_POS_UPDATE_HEADING );
1699
1701
return NAV_FSM_EVENT_SUCCESS ;
1700
1702
}
1701
-
1703
+
1702
1704
posControl .rthState .rthInitialAltitude = posControl .actualState .abs .pos .z ;
1703
1705
return NAV_FSM_EVENT_SWITCH_TO_NAV_STATE_RTH_INITIALIZE ;
1704
1706
} else {
1705
1707
geozoneAdvanceRthAvoidWaypoint ();
1706
1708
calculateAndSetActiveWaypointToLocalPosition (geozoneGetCurrentRthAvoidWaypoint ());
1707
1709
return NAV_FSM_EVENT_NONE ;
1708
1710
}
1709
- }
1711
+ }
1710
1712
setDesiredPosition (geozoneGetCurrentRthAvoidWaypoint (), 0 , NAV_POS_UPDATE_XY | NAV_POS_UPDATE_Z | NAV_POS_UPDATE_BEARING );
1711
1713
return NAV_FSM_EVENT_NONE ;
1712
1714
} else if (wpCount < 0 && geoZoneConfig ()-> noWayHomeAction == NO_WAY_HOME_ACTION_EMRG_LAND ) {
@@ -2566,7 +2568,7 @@ static navigationFSMEvent_t navOnEnteringState_NAV_STATE_FW_LANDING_ABORT(naviga
2566
2568
static navigationFSMEvent_t navOnEnteringState_NAV_STATE_SEND_TO_INITALIZE (navigationFSMState_t previousState )
2567
2569
{
2568
2570
UNUSED (previousState );
2569
-
2571
+
2570
2572
if (checkForPositionSensorTimeout ()) {
2571
2573
return NAV_FSM_EVENT_SWITCH_TO_IDLE ;
2572
2574
}
@@ -3606,12 +3608,12 @@ bool isProbablyStillFlying(void)
3606
3608
* Z-position controller
3607
3609
*-----------------------------------------------------------*/
3608
3610
float getDesiredClimbRate (float targetAltitude , timeDelta_t deltaMicros )
3609
- {
3610
-
3611
+ {
3612
+
3611
3613
const bool emergLandingIsActive = navigationIsExecutingAnEmergencyLanding ();
3612
-
3614
+
3613
3615
#ifdef USE_GEOZONE
3614
- if (!emergLandingIsActive && geozone .nearestHorZoneHasAction && ((geozone .currentzoneMaxAltitude != 0 && navGetCurrentActualPositionAndVelocity ()-> pos .z >= geozone .currentzoneMaxAltitude && posControl .desiredState .climbRateDemand > 0 ) ||
3616
+ if (!emergLandingIsActive && geozone .nearestHorZoneHasAction && ((geozone .currentzoneMaxAltitude != 0 && navGetCurrentActualPositionAndVelocity ()-> pos .z >= geozone .currentzoneMaxAltitude && posControl .desiredState .climbRateDemand > 0 ) ||
3615
3617
(geozone .currentzoneMinAltitude != 0 && navGetCurrentActualPositionAndVelocity ()-> pos .z <= geozone .currentzoneMinAltitude && posControl .desiredState .climbRateDemand < 0 ))) {
3616
3618
return 0.0f ;
3617
3619
}
@@ -4310,7 +4312,7 @@ void applyWaypointNavigationAndAltitudeHold(void)
4310
4312
posControl .activeWaypointIndex = posControl .startWpIndex ;
4311
4313
// Reset RTH trackback
4312
4314
resetRthTrackBack ();
4313
-
4315
+
4314
4316
#ifdef USE_GEOZONE
4315
4317
posControl .flags .sendToActive = false;
4316
4318
#endif
@@ -5109,7 +5111,7 @@ void abortSendTo(void)
5109
5111
5110
5112
void activateForcedPosHold (void )
5111
5113
{
5112
- if (!geozone .avoidInRTHInProgress ) {
5114
+ if (!geozone .avoidInRTHInProgress ) {
5113
5115
abortFixedWingLaunch ();
5114
5116
posControl .flags .forcedPosholdActive = true;
5115
5117
navProcessFSMEvents (selectNavEventFromBoxModeInput ());
0 commit comments