@@ -1859,6 +1859,7 @@ static navigationFSMEvent_t navOnEnteringState_NAV_STATE_WAYPOINT_PRE_ACTION(nav
18591859 case NAV_WP_ACTION_LAND :
18601860 calculateAndSetActiveWaypoint (& posControl .waypointList [posControl .activeWaypointIndex ]);
18611861 posControl .wpInitialDistance = calculateDistanceToDestination (& posControl .activeWaypoint .pos );
1862+ posControl .wpInitialAltitude = posControl .actualState .abs .pos .z ;
18621863 posControl .wpAltitudeReached = false;
18631864 return NAV_FSM_EVENT_SUCCESS ; // will switch to NAV_STATE_WAYPOINT_IN_PROGRESS
18641865
@@ -1922,16 +1923,12 @@ static navigationFSMEvent_t navOnEnteringState_NAV_STATE_WAYPOINT_IN_PROGRESS(na
19221923 fpVector3_t tmpWaypoint ;
19231924 tmpWaypoint .x = posControl .activeWaypoint .pos .x ;
19241925 tmpWaypoint .y = posControl .activeWaypoint .pos .y ;
1925- setDesiredPosition (& tmpWaypoint , 0 , NAV_POS_UPDATE_XY | NAV_POS_UPDATE_BEARING );
1926-
1927- // Use linear climb between WPs arriving at WP altitude when within 10% of total distance to WP
1928- // Update climb rate until within 100cm of total climb xy distance to WP
1929- float climbRate = 0.0f ;
1930- if (posControl .wpDistance - 0.1f * posControl .wpInitialDistance > 100.0f ) {
1931- climbRate = posControl .actualState .velXY * (posControl .activeWaypoint .pos .z - posControl .actualState .abs .pos .z ) /
1932- (posControl .wpDistance - 0.1f * posControl .wpInitialDistance );
1933- }
1934- updateClimbRateToAltitudeController (climbRate , posControl .activeWaypoint .pos .z , ROC_TO_ALT_TARGET );
1926+ /* Use linear climb/descent between WPs arriving at WP altitude when within 10% of total distance to WP */
1927+ tmpWaypoint .z = scaleRangef (constrainf (posControl .wpDistance , 0.1f * posControl .wpInitialDistance , posControl .wpInitialDistance ),
1928+ posControl .wpInitialDistance , 0.1f * posControl .wpInitialDistance ,
1929+ posControl .wpInitialAltitude , posControl .activeWaypoint .pos .z );
1930+
1931+ setDesiredPosition (& tmpWaypoint , 0 , NAV_POS_UPDATE_XY | NAV_POS_UPDATE_Z | NAV_POS_UPDATE_BEARING );
19351932
19361933 if (STATE (MULTIROTOR )) {
19371934 switch (wpHeadingControl .mode ) {
@@ -3703,7 +3700,7 @@ void setWaypoint(uint8_t wpNumber, const navWaypoint_t * wpData)
37033700 setDesiredPosition (& wpPos .pos , DEGREES_TO_CENTIDEGREES (wpData -> p1 ), waypointUpdateFlags );
37043701 }
37053702 // WP #1 - #NAV_MAX_WAYPOINTS - common waypoints - pre-programmed mission
3706- else if ((wpNumber >= 1 ) && (wpNumber <= NAV_MAX_WAYPOINTS ) && !FLIGHT_MODE (NAV_WP_MODE )) {
3703+ else if ((wpNumber >= 1 ) && (wpNumber <= NAV_MAX_WAYPOINTS ) && !FLIGHT_MODE (NAV_WP_MODE )) {
37073704 // WP upload is not allowed why WP mode is active
37083705 if (wpData -> action == NAV_WP_ACTION_WAYPOINT || wpData -> action == NAV_WP_ACTION_JUMP || wpData -> action == NAV_WP_ACTION_RTH || wpData -> action == NAV_WP_ACTION_HOLD_TIME || wpData -> action == NAV_WP_ACTION_LAND || wpData -> action == NAV_WP_ACTION_SET_POI || wpData -> action == NAV_WP_ACTION_SET_HEAD ) {
37093706 // Only allow upload next waypoint (continue upload mission) or first waypoint (new mission)
0 commit comments