mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-19 14:25:20 +03:00
Add anti gravity as feature and mode
This commit is contained in:
parent
53bd377742
commit
2d9306652d
9 changed files with 365 additions and 8 deletions
|
@ -179,7 +179,7 @@ static void resetPidProfile(pidProfile_t *pidProfile)
|
|||
pidProfile->yawRateAccelLimit = 10.0f;
|
||||
pidProfile->rateAccelLimit = 0.0f;
|
||||
pidProfile->itermThrottleThreshold = 350;
|
||||
pidProfile->itermAcceleratorGain = 1.0f;
|
||||
pidProfile->itermAcceleratorGain = 3.0f;
|
||||
}
|
||||
|
||||
void resetProfile(profile_t *profile)
|
||||
|
|
|
@ -56,6 +56,7 @@ typedef enum {
|
|||
FEATURE_RX_SPI = 1 << 25,
|
||||
FEATURE_SOFTSPI = 1 << 26,
|
||||
FEATURE_ESC_SENSOR = 1 << 27,
|
||||
FEATURE_ANTI_GRAVITY = 1 << 28,
|
||||
} features_e;
|
||||
|
||||
void beeperOffSet(uint32_t mask);
|
||||
|
|
|
@ -123,7 +123,7 @@ static const box_t boxes[CHECKBOX_ITEM_COUNT + 1] = {
|
|||
{ BOXANGLE, "ANGLE;", 1 },
|
||||
{ BOXHORIZON, "HORIZON;", 2 },
|
||||
{ BOXBARO, "BARO;", 3 },
|
||||
//{ BOXVARIO, "VARIO;", 4 },
|
||||
{ BOXANTIGRAVITY, "ANTI GRAVITY;", 4 },
|
||||
{ BOXMAG, "MAG;", 5 },
|
||||
{ BOXHEADFREE, "HEADFREE;", 6 },
|
||||
{ BOXHEADADJ, "HEADADJ;", 7 },
|
||||
|
@ -327,6 +327,10 @@ void initActiveBoxIds(void)
|
|||
activeBoxIds[activeBoxIdCount++] = BOXAIRMODE;
|
||||
}
|
||||
|
||||
if (!feature(FEATURE_ANTI_GRAVITY)) {
|
||||
activeBoxIds[activeBoxIdCount++] = BOXANTIGRAVITY;
|
||||
}
|
||||
|
||||
if (sensors(SENSOR_ACC)) {
|
||||
activeBoxIds[activeBoxIdCount++] = BOXANGLE;
|
||||
activeBoxIds[activeBoxIdCount++] = BOXHORIZON;
|
||||
|
@ -444,6 +448,7 @@ static uint32_t packFlightModeFlags(void)
|
|||
IS_ENABLED(IS_RC_MODE_ACTIVE(BOXBLACKBOX)) << BOXBLACKBOX |
|
||||
IS_ENABLED(FLIGHT_MODE(FAILSAFE_MODE)) << BOXFAILSAFE |
|
||||
IS_ENABLED(IS_RC_MODE_ACTIVE(BOXAIRMODE)) << BOXAIRMODE |
|
||||
IS_ENABLED(IS_RC_MODE_ACTIVE(BOXANTIGRAVITY)) << BOXANTIGRAVITY |
|
||||
IS_ENABLED(IS_RC_MODE_ACTIVE(BOXFPVANGLEMIX)) << BOXFPVANGLEMIX;
|
||||
|
||||
uint32_t ret = 0;
|
||||
|
|
|
@ -181,8 +181,9 @@ void processRcCommand(void)
|
|||
|
||||
if (isRXDataNew) {
|
||||
currentRxRefreshRate = constrain(getTaskDeltaTime(TASK_RX),1000,20000);
|
||||
if (currentProfile->pidProfile.itermAcceleratorGain > 1.0f)
|
||||
if (isAntiGravityModeActive()) {
|
||||
checkForThrottleErrorResetState(currentRxRefreshRate);
|
||||
}
|
||||
}
|
||||
|
||||
if (rxConfig()->rcInterpolation || flightModeFlags) {
|
||||
|
|
|
@ -73,6 +73,10 @@ bool isAirmodeActive(void) {
|
|||
return (IS_RC_MODE_ACTIVE(BOXAIRMODE) || feature(FEATURE_AIRMODE));
|
||||
}
|
||||
|
||||
bool isAntiGravityModeActive(void) {
|
||||
return (IS_RC_MODE_ACTIVE(BOXANTIGRAVITY) || feature(FEATURE_ANTI_GRAVITY));
|
||||
}
|
||||
|
||||
void blackboxLogInflightAdjustmentEvent(adjustmentFunction_e adjustmentFunction, int32_t newValue) {
|
||||
#ifndef BLACKBOX
|
||||
#define UNUSED(x) (void)(x)
|
||||
|
|
|
@ -24,7 +24,7 @@ typedef enum {
|
|||
BOXANGLE,
|
||||
BOXHORIZON,
|
||||
BOXBARO,
|
||||
// BOXVARIO,
|
||||
BOXANTIGRAVITY,
|
||||
BOXMAG,
|
||||
BOXHEADFREE,
|
||||
BOXHEADADJ,
|
||||
|
@ -271,6 +271,7 @@ typedef struct adjustmentProfile_s {
|
|||
} adjustmentProfile_t;
|
||||
|
||||
bool isAirmodeActive(void);
|
||||
bool isAntiGravityModeActive(void);
|
||||
void resetAdjustmentStates(void);
|
||||
void updateAdjustmentStates(adjustmentRange_t *adjustmentRanges);
|
||||
void processRcAdjustments(controlRateConfig_t *controlRateConfig, struct rxConfig_s *rxConfig);
|
||||
|
|
|
@ -479,10 +479,16 @@ void mixTable(pidProfile_t *pidProfile)
|
|||
const float motorOutputRange = motorOutputMax - motorOutputMin;
|
||||
|
||||
float scaledAxisPIDf[3];
|
||||
// Limit the PIDsum
|
||||
scaledAxisPIDf[FD_ROLL] = constrainf((axisPID_P[FD_ROLL] + axisPID_I[FD_ROLL] * throttle + axisPID_D[FD_ROLL]) / PID_MIXER_SCALING, -pidProfile->pidSumLimit, pidProfile->pidSumLimit);
|
||||
scaledAxisPIDf[FD_PITCH] = constrainf((axisPID_P[FD_PITCH] + axisPID_I[FD_PITCH] * throttle + axisPID_D[FD_PITCH]) / PID_MIXER_SCALING, -pidProfile->pidSumLimit, pidProfile->pidSumLimit);
|
||||
scaledAxisPIDf[FD_YAW] = constrainf((axisPID_P[FD_YAW] + axisPID_I[FD_YAW] * throttle) / PID_MIXER_SCALING, -pidProfile->pidSumLimit, pidProfile->pidSumLimitYaw);
|
||||
// Calculate and Limit the PIDsum
|
||||
scaledAxisPIDf[FD_ROLL] =
|
||||
constrainf((axisPID_P[FD_ROLL] + axisPID_I[FD_ROLL] + axisPID_D[FD_ROLL]) / PID_MIXER_SCALING,
|
||||
-pidProfile->pidSumLimit, pidProfile->pidSumLimit);
|
||||
scaledAxisPIDf[FD_PITCH] =
|
||||
constrainf((axisPID_P[FD_PITCH] + axisPID_I[FD_PITCH] + axisPID_D[FD_PITCH]) / PID_MIXER_SCALING,
|
||||
-pidProfile->pidSumLimit, pidProfile->pidSumLimit);
|
||||
scaledAxisPIDf[FD_YAW] =
|
||||
constrainf((axisPID_P[FD_YAW] + axisPID_I[FD_YAW]) / PID_MIXER_SCALING,
|
||||
-pidProfile->pidSumLimit, pidProfile->pidSumLimitYaw);
|
||||
|
||||
// Calculate voltage compensation
|
||||
const float vbatCompensationFactor = (batteryConfig && pidProfile->vbatPidCompensation) ? calculateVbatPidCompensation() : 1.0f;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue