Merge pull request #5022 from mikeller/fix_rates_interpolation_bug

Fixed rates / interpolation bug.
This commit is contained in:
Michael Keller 2018-01-25 18:11:09 +13:00 committed by GitHub
commit 9fc5bacaac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 14 deletions

View File

@ -192,8 +192,7 @@ void processRcCommand(void)
const uint8_t interpolationChannels = rxConfig()->rcInterpolationChannels + 2; //"RP", "RPY", "RPYT"
uint16_t rxRefreshRate;
bool readyToCalculateRate = false;
uint8_t readyToCalculateRateAxisCnt = 0;
uint8_t updatedChannel = 0;
if (rxConfig()->rcInterpolation) {
// Set RC refresh rate for sampling and channels to filter
@ -229,27 +228,22 @@ void processRcCommand(void)
// Interpolate steps of rcCommand
if (rcInterpolationStepCount > 0) {
for (int channel=ROLL; channel < interpolationChannels; channel++) {
rcCommandInterp[channel] += rcStepSize[channel];
rcCommand[channel] = rcCommandInterp[channel];
readyToCalculateRateAxisCnt = MAX(channel, FD_YAW); // throttle channel doesn't require rate calculation
for (updatedChannel = ROLL; updatedChannel < interpolationChannels; updatedChannel++) {
rcCommandInterp[updatedChannel] += rcStepSize[updatedChannel];
rcCommand[updatedChannel] = rcCommandInterp[updatedChannel];
}
readyToCalculateRate = true;
}
} else {
rcInterpolationStepCount = 0; // reset factor in case of level modes flip flopping
}
if (readyToCalculateRate || isRXDataNew) {
if (isRXDataNew) {
readyToCalculateRateAxisCnt = FD_YAW;
}
if (isRXDataNew || updatedChannel) {
const uint8_t maxUpdatedAxis = isRXDataNew ? FD_YAW : MIN(updatedChannel, FD_YAW); // throttle channel doesn't require rate calculation
#if defined(SITL)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunsafe-loop-optimizations"
#endif
for (int axis = 0; axis <= readyToCalculateRateAxisCnt; axis++) {
for (int axis = FD_ROLL; axis <= maxUpdatedAxis; axis++) {
#if defined(SITL)
#pragma GCC diagnostic pop
#endif
@ -260,11 +254,14 @@ void processRcCommand(void)
debug[2] = rcInterpolationStepCount;
debug[3] = setpointRate[0];
}
// Scaling of AngleRate to camera angle (Mixing Roll and Yaw)
if (rxConfig()->fpvCamAngleDegrees && IS_RC_MODE_ACTIVE(BOXFPVANGLEMIX) && !FLIGHT_MODE(HEADFREE_MODE)) {
scaleRcCommandToFpvCamAngle();
}
}
if (isRXDataNew) {
isRXDataNew = false;
}
}