diff --git a/src/main/flight/rth_estimator.c b/src/main/flight/rth_estimator.c index d9897c32c7..4ddc719037 100644 --- a/src/main/flight/rth_estimator.c +++ b/src/main/flight/rth_estimator.c @@ -77,7 +77,7 @@ static int8_t RTHInitialAltitudeChangePitchAngle(float altitudeChange) { // pitch in degrees // output in Watt static float estimatePitchPower(float pitch) { - int16_t altitudeChangeThrottle = fixedWingPitchToThrottleCorrection(DEGREES_TO_DECIDEGREES(pitch)); + int16_t altitudeChangeThrottle = (int16_t)pitch * navConfig()->fw.pitch_to_throttle; altitudeChangeThrottle = constrain(altitudeChangeThrottle, navConfig()->fw.min_throttle, navConfig()->fw.max_throttle); const float altitudeChangeThrToCruiseThrRatio = (float)(altitudeChangeThrottle - getThrottleIdleValue()) / (navConfig()->fw.cruise_throttle - getThrottleIdleValue()); return (float)heatLossesCompensatedPower(batteryMetersConfig()->idle_power + batteryMetersConfig()->cruise_power * altitudeChangeThrToCruiseThrRatio) / 100; diff --git a/src/main/navigation/navigation.h b/src/main/navigation/navigation.h index cf835dbcd7..fea8b8e7b6 100755 --- a/src/main/navigation/navigation.h +++ b/src/main/navigation/navigation.h @@ -463,7 +463,7 @@ bool loadNonVolatileWaypointList(void); bool saveNonVolatileWaypointList(void); float getFinalRTHAltitude(void); -int16_t fixedWingPitchToThrottleCorrection(int16_t pitch); +int16_t fixedWingPitchToThrottleCorrection(int16_t pitch, timeUs_t currentTimeUs); /* Geodetic functions */ typedef enum { diff --git a/src/main/navigation/navigation_fixedwing.c b/src/main/navigation/navigation_fixedwing.c index 0784373f91..c9a63653e0 100755 --- a/src/main/navigation/navigation_fixedwing.c +++ b/src/main/navigation/navigation_fixedwing.c @@ -479,9 +479,9 @@ int16_t fixedWingPitchToThrottleCorrection(int16_t pitch, timeUs_t currentTimeUs static pt1Filter_t pitchToThrFilterState; // Apply low-pass filter to pitch angle to smooth throttle correction - filteredPitch = pt1FilterApply4(&pitchToThrFilterState, pitch, getPitchToThrottleSmoothnessCutoffFreq(NAV_FW_BASE_PITCH_CUTOFF_FREQUENCY_HZ), US2S(deltaMicrosPitchToThrCorr)); + int16_t filteredPitch = (int16_t)pt1FilterApply4(&pitchToThrFilterState, pitch, getPitchToThrottleSmoothnessCutoffFreq(NAV_FW_BASE_PITCH_CUTOFF_FREQUENCY_HZ), US2S(deltaMicrosPitchToThrCorr)); - if (abs(pitch - filteredPitch) > navConfig()->fw.pitch_to_throttle_thresh) { + if (ABS(pitch - filteredPitch) > navConfig()->fw.pitch_to_throttle_thresh) { // Unfiltered throttle correction outside of pitch deadband return DECIDEGREES_TO_DEGREES(pitch) * navConfig()->fw.pitch_to_throttle; }