mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-26 09:45:37 +03:00
Merge pull request #587 from blckmn/development
Latest Betaflight Changes
This commit is contained in:
commit
8b997da831
3 changed files with 15 additions and 13 deletions
|
@ -180,7 +180,7 @@ static void resetAccelerometerTrims(flightDynamicsTrims_t *accelerometerTrims)
|
|||
accelerometerTrims->values.yaw = 0;
|
||||
}
|
||||
|
||||
static void resetPidProfile(pidProfile_t *pidProfile)
|
||||
void resetPidProfile(pidProfile_t *pidProfile)
|
||||
{
|
||||
|
||||
#if (defined(STM32F10X))
|
||||
|
@ -195,7 +195,7 @@ static void resetPidProfile(pidProfile_t *pidProfile)
|
|||
pidProfile->P8[PITCH] = 50;
|
||||
pidProfile->I8[PITCH] = 40;
|
||||
pidProfile->D8[PITCH] = 18;
|
||||
pidProfile->P8[YAW] = 90;
|
||||
pidProfile->P8[YAW] = 80;
|
||||
pidProfile->I8[YAW] = 45;
|
||||
pidProfile->D8[YAW] = 20;
|
||||
pidProfile->P8[PIDALT] = 50;
|
||||
|
@ -220,10 +220,10 @@ static void resetPidProfile(pidProfile_t *pidProfile)
|
|||
|
||||
pidProfile->yaw_p_limit = YAW_P_LIMIT_MAX;
|
||||
pidProfile->yaw_lpf_hz = 80;
|
||||
pidProfile->rollPitchItermIgnoreRate = 200;
|
||||
pidProfile->rollPitchItermIgnoreRate = 180;
|
||||
pidProfile->yawItermIgnoreRate = 35;
|
||||
pidProfile->dterm_lpf_hz = 50; // filtering ON by default
|
||||
pidProfile->deltaMethod = DELTA_FROM_ERROR;
|
||||
pidProfile->dterm_lpf_hz = 100; // filtering ON by default
|
||||
pidProfile->deltaMethod = DELTA_FROM_MEASUREMENT;
|
||||
pidProfile->dynamic_pid = 1;
|
||||
|
||||
#ifdef GTUNE
|
||||
|
|
|
@ -1272,11 +1272,10 @@ static bool processOutCommand(uint8_t cmdMSP)
|
|||
serialize16(currentProfile->pidProfile.yaw_lpf_hz);
|
||||
break;
|
||||
case MSP_ADVANCED_TUNING:
|
||||
headSerialReply(4 * 2 + 2);
|
||||
headSerialReply(3 * 2 + 2);
|
||||
serialize16(currentProfile->pidProfile.rollPitchItermIgnoreRate);
|
||||
serialize16(currentProfile->pidProfile.yawItermIgnoreRate);
|
||||
serialize16(currentProfile->pidProfile.yaw_p_limit);
|
||||
serialize16(masterConfig.rxConfig.airModeActivateThreshold);
|
||||
serialize8(currentProfile->pidProfile.deltaMethod);
|
||||
serialize8(masterConfig.batteryConfig.vbatPidCompensation);
|
||||
break;
|
||||
|
@ -1516,7 +1515,7 @@ static bool processInCommand(void)
|
|||
break;
|
||||
|
||||
case MSP_SET_RESET_CURR_PID:
|
||||
//resetPidProfile(¤tProfile->pidProfile);
|
||||
resetPidProfile(¤tProfile->pidProfile);
|
||||
break;
|
||||
|
||||
case MSP_SET_SENSOR_ALIGNMENT:
|
||||
|
@ -1857,6 +1856,7 @@ static bool processInCommand(void)
|
|||
currentProfile->pidProfile.yawItermIgnoreRate = read16();
|
||||
currentProfile->pidProfile.yaw_p_limit = read16();
|
||||
currentProfile->pidProfile.deltaMethod = read8();
|
||||
masterConfig.batteryConfig.vbatPidCompensation = read8();
|
||||
break;
|
||||
case MSP_SET_SPECIAL_PARAMETERS:
|
||||
currentControlRateProfile->rcYawRate8 = read8();
|
||||
|
|
|
@ -56,7 +56,7 @@ void useGyroConfig(gyroConfig_t *gyroConfigToUse, float gyro_lpf_hz)
|
|||
}
|
||||
|
||||
void initGyroFilterCoefficients(void) {
|
||||
int axis;
|
||||
int axis;
|
||||
if (gyroLpfCutFreq && targetLooptime) { /* Initialisation needs to happen once samplingrate is known */
|
||||
for (axis = 0; axis < 3; axis++) BiQuadNewLpf(gyroLpfCutFreq, &gyroFilterState[axis], targetLooptime);
|
||||
gyroFilterStateIsSet = true;
|
||||
|
@ -137,8 +137,8 @@ static void applyGyroZero(void)
|
|||
|
||||
void gyroUpdate(void)
|
||||
{
|
||||
int16_t gyroADCRaw[XYZ_AXIS_COUNT];
|
||||
int axis;
|
||||
int16_t gyroADCRaw[XYZ_AXIS_COUNT];
|
||||
int axis;
|
||||
|
||||
// range: +/- 8192; +/- 2000 deg/sec
|
||||
if (!gyro.read(gyroADCRaw)) {
|
||||
|
@ -161,10 +161,12 @@ void gyroUpdate(void)
|
|||
if (gyroLpfCutFreq) {
|
||||
if (!gyroFilterStateIsSet) initGyroFilterCoefficients(); /* initialise filter coefficients */
|
||||
|
||||
if (gyroFilterStateIsSet) {
|
||||
for (axis = 0; axis < XYZ_AXIS_COUNT; axis++){
|
||||
for (axis = 0; axis < XYZ_AXIS_COUNT; axis++) {
|
||||
if (gyroFilterStateIsSet) {
|
||||
gyroADCf[axis] = applyBiQuadFilter((float) gyroADC[axis], &gyroFilterState[axis]);
|
||||
gyroADC[axis] = lrintf(gyroADCf[axis]);
|
||||
} else {
|
||||
gyroADCf[axis] = gyroADC[axis]; // Otherwise float pid controller will not have gyro input when filter disabled
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue