make sure rxRefreshRate > 0
This commit is contained in:
parent
d7c0fa4d6e
commit
001fb8d432
|
@ -204,7 +204,7 @@ void processRcCommand(void)
|
|||
rxRefreshRate = rxGetRefreshRate();
|
||||
}
|
||||
|
||||
if (isRXDataNew) {
|
||||
if (isRXDataNew && rxRefreshRate > 0) {
|
||||
rcInterpolationStepCount = rxRefreshRate / targetPidLooptime;
|
||||
|
||||
for (int channel=ROLL; channel < interpolationChannels; channel++) {
|
||||
|
@ -227,10 +227,8 @@ void processRcCommand(void)
|
|||
rcCommandInterp[channel] += rcStepSize[channel];
|
||||
rcCommand[channel] = rcCommandInterp[channel];
|
||||
readyToCalculateRateAxisCnt = MAX(channel, FD_YAW); // throttle channel doesn't require rate calculation
|
||||
readyToCalculateRate = true;
|
||||
}
|
||||
} else {
|
||||
rcInterpolationStepCount = 0;
|
||||
readyToCalculateRate = true;
|
||||
}
|
||||
} else {
|
||||
rcInterpolationStepCount = 0; // reset factor in case of level modes flip flopping
|
||||
|
|
|
@ -438,14 +438,14 @@ void pidController(const pidProfile_t *pidProfile, const rollAndPitchTrims_t *an
|
|||
// -----calculate D component
|
||||
if (axis != FD_YAW) {
|
||||
// apply filters
|
||||
float gyroRateD = dtermNotchFilterApplyFn(dtermFilterNotch[axis], gyroRate);
|
||||
gyroRateD = dtermLpfApplyFn(dtermFilterLpf[axis], gyroRateD);
|
||||
float gyroRateFiltered = dtermNotchFilterApplyFn(dtermFilterNotch[axis], gyroRate);
|
||||
gyroRateFiltered = dtermLpfApplyFn(dtermFilterLpf[axis], gyroRateFiltered);
|
||||
|
||||
float dynC = dtermSetpointWeight;
|
||||
if (pidProfile->setpointRelaxRatio < 100) {
|
||||
dynC *= MIN(getRcDeflectionAbs(axis) * relaxFactor, 1.0f);
|
||||
}
|
||||
const float rD = dynC * currentPidSetpoint - gyroRateD; // cr - y
|
||||
const float rD = dynC * currentPidSetpoint - gyroRateFiltered; // cr - y
|
||||
// Divide rate change by dT to get differential (ie dr/dt)
|
||||
float delta = (rD - previousRateError[axis]) / dT;
|
||||
|
||||
|
|
Loading…
Reference in New Issue