mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-20 06:45:16 +03:00
Keep I-terms at zero throttle for fixed wings (#13127)
* Keep Iterms at zero throttle for fixed wing mixer * Ctz suggestions * Update src/main/fc/core.c based on ladvinap suggestion Co-authored-by: Petr Ledvina <ledvinap@gmail.com> --------- Co-authored-by: Petr Ledvina <ledvinap@gmail.com>
This commit is contained in:
parent
efe1825afa
commit
dd198b2cda
1 changed files with 7 additions and 20 deletions
|
@ -768,30 +768,17 @@ bool processRx(timeUs_t currentTimeUs)
|
||||||
failsafeStartMonitoring();
|
failsafeStartMonitoring();
|
||||||
}
|
}
|
||||||
|
|
||||||
const throttleStatus_e throttleStatus = calculateThrottleStatus();
|
const bool throttleActive = calculateThrottleStatus() != THROTTLE_LOW;
|
||||||
const uint8_t throttlePercent = calculateThrottlePercentAbs();
|
const uint8_t throttlePercent = calculateThrottlePercentAbs();
|
||||||
|
|
||||||
const bool launchControlActive = isLaunchControlActive();
|
const bool launchControlActive = isLaunchControlActive();
|
||||||
|
airmodeIsActivated = airmodeIsEnabled() && ARMING_FLAG(ARMED) && throttlePercent >= rxConfig()->airModeActivateThreshold && !launchControlActive;
|
||||||
|
|
||||||
if (airmodeIsEnabled() && ARMING_FLAG(ARMED) && !launchControlActive) {
|
if (ARMING_FLAG(ARMED) && (airmodeIsActivated || throttleActive || launchControlActive || isFixedWing())) {
|
||||||
if (throttlePercent >= rxConfig()->airModeActivateThreshold) {
|
|
||||||
airmodeIsActivated = true; // Prevent iterm from being reset
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
airmodeIsActivated = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* In airmode iterm should be prevented to grow when Low thottle and Roll + Pitch Centered.
|
|
||||||
This is needed to prevent iterm winding on the ground, but keep full stabilisation on 0 throttle while in air */
|
|
||||||
if (throttleStatus == THROTTLE_LOW && !airmodeIsActivated && !launchControlActive) {
|
|
||||||
pidSetItermReset(true);
|
|
||||||
if (currentPidProfile->pidAtMinThrottle)
|
|
||||||
pidStabilisationState(PID_STABILISATION_ON);
|
|
||||||
else
|
|
||||||
pidStabilisationState(PID_STABILISATION_OFF);
|
|
||||||
} else {
|
|
||||||
pidSetItermReset(false);
|
pidSetItermReset(false);
|
||||||
pidStabilisationState(PID_STABILISATION_ON);
|
pidStabilisationState(PID_STABILISATION_ON);
|
||||||
|
} else {
|
||||||
|
pidSetItermReset(true);
|
||||||
|
pidStabilisationState(currentPidProfile->pidAtMinThrottle ? PID_STABILISATION_ON : PID_STABILISATION_OFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_RUNAWAY_TAKEOFF
|
#ifdef USE_RUNAWAY_TAKEOFF
|
||||||
|
@ -814,7 +801,7 @@ bool processRx(timeUs_t currentTimeUs)
|
||||||
// - sticks are active and have deflection greater than runaway_takeoff_deactivate_stick_percent
|
// - sticks are active and have deflection greater than runaway_takeoff_deactivate_stick_percent
|
||||||
// - pidSum on all axis is less then runaway_takeoff_deactivate_pidlimit
|
// - pidSum on all axis is less then runaway_takeoff_deactivate_pidlimit
|
||||||
bool inStableFlight = false;
|
bool inStableFlight = false;
|
||||||
if (!featureIsEnabled(FEATURE_MOTOR_STOP) || airmodeIsEnabled() || (throttleStatus != THROTTLE_LOW)) { // are motors running?
|
if (!featureIsEnabled(FEATURE_MOTOR_STOP) || airmodeIsEnabled() || throttleActive) { // are motors running?
|
||||||
const uint8_t lowThrottleLimit = pidConfig()->runaway_takeoff_deactivate_throttle;
|
const uint8_t lowThrottleLimit = pidConfig()->runaway_takeoff_deactivate_throttle;
|
||||||
const uint8_t midThrottleLimit = constrain(lowThrottleLimit * 2, lowThrottleLimit * 2, RUNAWAY_TAKEOFF_HIGH_THROTTLE_PERCENT);
|
const uint8_t midThrottleLimit = constrain(lowThrottleLimit * 2, lowThrottleLimit * 2, RUNAWAY_TAKEOFF_HIGH_THROTTLE_PERCENT);
|
||||||
if ((((throttlePercent >= lowThrottleLimit) && areSticksActive(RUNAWAY_TAKEOFF_DEACTIVATE_STICK_PERCENT)) || (throttlePercent >= midThrottleLimit))
|
if ((((throttlePercent >= lowThrottleLimit) && areSticksActive(RUNAWAY_TAKEOFF_DEACTIVATE_STICK_PERCENT)) || (throttlePercent >= midThrottleLimit))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue