Skip to content

Commit

Permalink
Merge pull request #8069 from breadoven/abo_spiral_climb_enum_fix
Browse files Browse the repository at this point in the history
Fix RTH Climb First enum ambiguity
  • Loading branch information
DzikuVx authored May 30, 2022
2 parents 63a60ad + 7c628fb commit 3914c4f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/main/navigation/navigation.c
Original file line number Diff line number Diff line change
Expand Up @@ -1171,7 +1171,7 @@ static navigationFSMEvent_t navOnEnteringState_NAV_STATE_RTH_INITIALIZE(navigati

if (STATE(FIXED_WING_LEGACY)) {
// Airplane - climbout before heading home
if (navConfig()->general.flags.rth_climb_first == ON_FW_SPIRAL) {
if (navConfig()->general.flags.rth_climb_first == RTH_CLIMB_ON_FW_SPIRAL) {
// Spiral climb centered at xy of RTH activation
calculateInitialHoldPosition(&targetHoldPos);
} else {
Expand Down Expand Up @@ -1220,7 +1220,7 @@ static navigationFSMEvent_t navOnEnteringState_NAV_STATE_RTH_CLIMB_TO_SAFE_ALT(n
const float rthAltitudeMargin = MAX(FW_RTH_CLIMB_MARGIN_MIN_CM, (rthClimbMarginPercent/100.0) * fabsf(posControl.rthState.rthInitialAltitude - posControl.rthState.homePosition.pos.z));

// If we reached desired initial RTH altitude or we don't want to climb first
if (((navGetCurrentActualPositionAndVelocity()->pos.z - posControl.rthState.rthInitialAltitude) > -rthAltitudeMargin) || (navConfig()->general.flags.rth_climb_first == OFF) || rthAltControlStickOverrideCheck(ROLL) || rthClimbStageActiveAndComplete()) {
if (((navGetCurrentActualPositionAndVelocity()->pos.z - posControl.rthState.rthInitialAltitude) > -rthAltitudeMargin) || (navConfig()->general.flags.rth_climb_first == RTH_CLIMB_OFF) || rthAltControlStickOverrideCheck(ROLL) || rthClimbStageActiveAndComplete()) {

// Delayed initialization for RTH sanity check on airplanes - allow to finish climb first as it can take some distance
if (STATE(FIXED_WING_LEGACY)) {
Expand Down Expand Up @@ -1251,7 +1251,7 @@ static navigationFSMEvent_t navOnEnteringState_NAV_STATE_RTH_CLIMB_TO_SAFE_ALT(n

// Climb to safe altitude and turn to correct direction
if (STATE(FIXED_WING_LEGACY)) {
if (navConfig()->general.flags.rth_climb_first == ON_FW_SPIRAL) {
if (navConfig()->general.flags.rth_climb_first == RTH_CLIMB_ON_FW_SPIRAL) {
float altitudeChangeDirection = (tmpHomePos->z += FW_RTH_CLIMB_OVERSHOOT_CM) > navGetCurrentActualPositionAndVelocity()->pos.z ? 1 : -1;
updateClimbRateToAltitudeController(altitudeChangeDirection * navConfig()->general.max_auto_climb_rate, ROC_TO_ALT_NORMAL);
} else {
Expand Down
6 changes: 3 additions & 3 deletions src/main/navigation/navigation.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,9 @@ typedef enum {
} navOverridesMotorStop_e;

typedef enum {
OFF,
ON,
ON_FW_SPIRAL,
RTH_CLIMB_OFF,
RTH_CLIMB_ON,
RTH_CLIMB_ON_FW_SPIRAL,
} navRTHClimbFirst_e;

typedef enum { // keep aligned with fixedWingLaunchState_t
Expand Down

0 comments on commit 3914c4f

Please sign in to comment.