1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-23 16:25:31 +03:00

Merge pull request #9495 from ctzsnooze/Actual-Rates

New Actual Rates model : set rates in deg/s, independently of each other
This commit is contained in:
Michael Keller 2020-03-04 12:54:13 +13:00 committed by GitHub
commit f33dd32c33
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 1 deletions

View file

@ -336,7 +336,7 @@ static const char * const lookupTableGyroOverflowCheck[] = {
#endif
static const char * const lookupTableRatesType[] = {
"BETAFLIGHT", "RACEFLIGHT", "KISS"
"BETAFLIGHT", "RACEFLIGHT", "KISS", "ACTUAL"
};
#ifdef USE_OVERCLOCK

View file

@ -28,6 +28,7 @@ typedef enum {
RATES_TYPE_BETAFLIGHT = 0,
RATES_TYPE_RACEFLIGHT,
RATES_TYPE_KISS,
RATES_TYPE_ACTUAL,
} ratesType_e;
typedef enum {

View file

@ -193,6 +193,18 @@ float applyKissRates(const int axis, float rcCommandf, const float rcCommandfAbs
return kissAngle;
}
float applyActualRates(const int axis, float rcCommandf, const float rcCommandfAbs)
{
float expof = currentControlRateProfile->rcExpo[axis] / 100.0f;
expof = rcCommandfAbs * (powerf(rcCommandf, 5) * expof + rcCommandf * (1 - expof));
const float centerSensitivity = currentControlRateProfile->rcRates[axis] * 10.0f;
const float stickMovement = MAX(0, currentControlRateProfile->rates[axis] * 10.0f - centerSensitivity);
const float angleRate = rcCommandf * centerSensitivity + stickMovement * expof;
return angleRate;
}
float applyCurve(int axis, float deflection)
{
return applyRates(axis, deflection, fabsf(deflection));
@ -816,6 +828,10 @@ void initRcProcessing(void)
case RATES_TYPE_KISS:
applyRates = applyKissRates;
break;
case RATES_TYPE_ACTUAL:
applyRates = applyActualRates;
break;
}