mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-19 14:25:20 +03:00
Fix 3D arming checks when using switched 3D mode
When FEATURE_3D is on and BOX3DONASWITCH is configured the "standard" throttle arming condition is used.
This commit is contained in:
parent
0315005445
commit
c97fbd04b8
2 changed files with 97 additions and 8 deletions
|
@ -221,6 +221,7 @@ void updateArmingStatus(void)
|
||||||
/* Ignore ARMING_DISABLED_THROTTLE (once arm switch is on) if we are in 3D mode */
|
/* Ignore ARMING_DISABLED_THROTTLE (once arm switch is on) if we are in 3D mode */
|
||||||
bool ignoreThrottle = feature(FEATURE_3D)
|
bool ignoreThrottle = feature(FEATURE_3D)
|
||||||
&& !IS_RC_MODE_ACTIVE(BOX3DDISABLE)
|
&& !IS_RC_MODE_ACTIVE(BOX3DDISABLE)
|
||||||
|
&& !isModeActivationConditionPresent(BOX3DONASWITCH)
|
||||||
&& !(getArmingDisableFlags() & ~(ARMING_DISABLED_ARM_SWITCH | ARMING_DISABLED_THROTTLE));
|
&& !(getArmingDisableFlags() & ~(ARMING_DISABLED_ARM_SWITCH | ARMING_DISABLED_THROTTLE));
|
||||||
|
|
||||||
// If arming is disabled and the ARM switch is on
|
// If arming is disabled and the ARM switch is on
|
||||||
|
|
|
@ -369,10 +369,7 @@ TEST(ArmingPreventionTest, In3DModeAllowArmingWhenEnteringThrottleDeadband)
|
||||||
// and
|
// and
|
||||||
rcData[THROTTLE] = 1400;
|
rcData[THROTTLE] = 1400;
|
||||||
ENABLE_STATE(SMALL_ANGLE);
|
ENABLE_STATE(SMALL_ANGLE);
|
||||||
|
simulationHaveRx = true;
|
||||||
// and
|
|
||||||
// RX has no link to radio
|
|
||||||
simulationHaveRx = false;
|
|
||||||
|
|
||||||
// and
|
// and
|
||||||
// arm channel has a safe default value
|
// arm channel has a safe default value
|
||||||
|
@ -441,10 +438,7 @@ TEST(ArmingPreventionTest, When3DModeDisabledThenNormalThrottleArmingConditionAp
|
||||||
// safe throttle value for 3D mode
|
// safe throttle value for 3D mode
|
||||||
rcData[THROTTLE] = 1500;
|
rcData[THROTTLE] = 1500;
|
||||||
ENABLE_STATE(SMALL_ANGLE);
|
ENABLE_STATE(SMALL_ANGLE);
|
||||||
|
simulationHaveRx = true;
|
||||||
// and
|
|
||||||
// RX has no link to radio
|
|
||||||
simulationHaveRx = false;
|
|
||||||
|
|
||||||
// and
|
// and
|
||||||
// arm channel has a safe default value
|
// arm channel has a safe default value
|
||||||
|
@ -518,6 +512,100 @@ TEST(ArmingPreventionTest, When3DModeDisabledThenNormalThrottleArmingConditionAp
|
||||||
EXPECT_EQ(0, getArmingDisableFlags());
|
EXPECT_EQ(0, getArmingDisableFlags());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(ArmingPreventionTest, WhenUsingSwitched3DModeThenNormalThrottleArmingConditionApplies)
|
||||||
|
{
|
||||||
|
// given
|
||||||
|
simulationFeatureFlags = FEATURE_3D; // Using 3D mode
|
||||||
|
simulationTime = 30e6; // 30 seconds after boot
|
||||||
|
gyroCalibDone = true;
|
||||||
|
|
||||||
|
// and
|
||||||
|
modeActivationConditionsMutable(0)->auxChannelIndex = 0;
|
||||||
|
modeActivationConditionsMutable(0)->modeId = BOXARM;
|
||||||
|
modeActivationConditionsMutable(0)->range.startStep = CHANNEL_VALUE_TO_STEP(1750);
|
||||||
|
modeActivationConditionsMutable(0)->range.endStep = CHANNEL_VALUE_TO_STEP(CHANNEL_RANGE_MAX);
|
||||||
|
modeActivationConditionsMutable(1)->auxChannelIndex = 1;
|
||||||
|
modeActivationConditionsMutable(1)->modeId = BOX3DONASWITCH;
|
||||||
|
modeActivationConditionsMutable(1)->range.startStep = CHANNEL_VALUE_TO_STEP(1750);
|
||||||
|
modeActivationConditionsMutable(1)->range.endStep = CHANNEL_VALUE_TO_STEP(CHANNEL_RANGE_MAX);
|
||||||
|
useRcControlsConfig(NULL);
|
||||||
|
|
||||||
|
// and
|
||||||
|
rxConfigMutable()->mincheck = 1050;
|
||||||
|
|
||||||
|
// and
|
||||||
|
rcData[THROTTLE] = 1000;
|
||||||
|
ENABLE_STATE(SMALL_ANGLE);
|
||||||
|
simulationHaveRx = true;
|
||||||
|
|
||||||
|
// and
|
||||||
|
// arm channel has a safe default value
|
||||||
|
rcData[4] = 1100;
|
||||||
|
|
||||||
|
// when
|
||||||
|
updateActivatedModes();
|
||||||
|
updateArmingStatus();
|
||||||
|
|
||||||
|
// expect
|
||||||
|
// ok to arm in 3D mode
|
||||||
|
EXPECT_FALSE(isUsingSticksForArming());
|
||||||
|
EXPECT_FALSE(isArmingDisabled());
|
||||||
|
EXPECT_EQ(0, getArmingDisableFlags());
|
||||||
|
|
||||||
|
// given
|
||||||
|
// raise throttle to unsafe position
|
||||||
|
rcData[THROTTLE] = 1500;
|
||||||
|
|
||||||
|
// when
|
||||||
|
updateActivatedModes();
|
||||||
|
updateArmingStatus();
|
||||||
|
|
||||||
|
// expect
|
||||||
|
// ok to arm in 3D mode
|
||||||
|
EXPECT_FALSE(isUsingSticksForArming());
|
||||||
|
EXPECT_TRUE(isArmingDisabled());
|
||||||
|
EXPECT_EQ(ARMING_DISABLED_THROTTLE, getArmingDisableFlags());
|
||||||
|
|
||||||
|
// given
|
||||||
|
// attempt to arm
|
||||||
|
rcData[4] = 1800;
|
||||||
|
|
||||||
|
// when
|
||||||
|
updateActivatedModes();
|
||||||
|
updateArmingStatus();
|
||||||
|
|
||||||
|
// expect
|
||||||
|
EXPECT_FALSE(isUsingSticksForArming());
|
||||||
|
EXPECT_TRUE(isArmingDisabled());
|
||||||
|
EXPECT_EQ(ARMING_DISABLED_THROTTLE | ARMING_DISABLED_ARM_SWITCH, getArmingDisableFlags());
|
||||||
|
|
||||||
|
// given
|
||||||
|
// throttle moved low
|
||||||
|
rcData[THROTTLE] = 1000;
|
||||||
|
|
||||||
|
// when
|
||||||
|
updateActivatedModes();
|
||||||
|
updateArmingStatus();
|
||||||
|
|
||||||
|
// expect
|
||||||
|
EXPECT_FALSE(isUsingSticksForArming());
|
||||||
|
EXPECT_TRUE(isArmingDisabled());
|
||||||
|
EXPECT_EQ(ARMING_DISABLED_ARM_SWITCH, getArmingDisableFlags());
|
||||||
|
|
||||||
|
// given
|
||||||
|
// arm switch turned off
|
||||||
|
rcData[4] = 1000;
|
||||||
|
|
||||||
|
// when
|
||||||
|
updateActivatedModes();
|
||||||
|
updateArmingStatus();
|
||||||
|
|
||||||
|
// expect
|
||||||
|
EXPECT_FALSE(isUsingSticksForArming());
|
||||||
|
EXPECT_FALSE(isArmingDisabled());
|
||||||
|
EXPECT_EQ(0, getArmingDisableFlags());
|
||||||
|
}
|
||||||
|
|
||||||
// STUBS
|
// STUBS
|
||||||
extern "C" {
|
extern "C" {
|
||||||
uint32_t micros(void) { return simulationTime; }
|
uint32_t micros(void) { return simulationTime; }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue