Fixed array out of bounds issue - not all set.
This commit is contained in:
parent
00c0ca7c71
commit
d779daad2d
|
@ -56,7 +56,7 @@ void useGyroConfig(gyroConfig_t *gyroConfigToUse, float gyro_lpf_hz)
|
||||||
}
|
}
|
||||||
|
|
||||||
void initGyroFilterCoefficients(void) {
|
void initGyroFilterCoefficients(void) {
|
||||||
int axis;
|
int axis;
|
||||||
if (gyroLpfCutFreq && targetLooptime) { /* Initialisation needs to happen once samplingrate is known */
|
if (gyroLpfCutFreq && targetLooptime) { /* Initialisation needs to happen once samplingrate is known */
|
||||||
for (axis = 0; axis < 3; axis++) BiQuadNewLpf(gyroLpfCutFreq, &gyroFilterState[axis], targetLooptime);
|
for (axis = 0; axis < 3; axis++) BiQuadNewLpf(gyroLpfCutFreq, &gyroFilterState[axis], targetLooptime);
|
||||||
gyroFilterStateIsSet = true;
|
gyroFilterStateIsSet = true;
|
||||||
|
@ -137,8 +137,8 @@ static void applyGyroZero(void)
|
||||||
|
|
||||||
void gyroUpdate(void)
|
void gyroUpdate(void)
|
||||||
{
|
{
|
||||||
int16_t gyroADCRaw[XYZ_AXIS_COUNT];
|
int16_t gyroADCRaw[XYZ_AXIS_COUNT];
|
||||||
int axis;
|
int axis;
|
||||||
|
|
||||||
// range: +/- 8192; +/- 2000 deg/sec
|
// range: +/- 8192; +/- 2000 deg/sec
|
||||||
if (!gyro.read(gyroADCRaw)) {
|
if (!gyro.read(gyroADCRaw)) {
|
||||||
|
@ -161,13 +161,13 @@ void gyroUpdate(void)
|
||||||
if (gyroLpfCutFreq) {
|
if (gyroLpfCutFreq) {
|
||||||
if (!gyroFilterStateIsSet) initGyroFilterCoefficients(); /* initialise filter coefficients */
|
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]);
|
gyroADCf[axis] = applyBiQuadFilter((float) gyroADC[axis], &gyroFilterState[axis]);
|
||||||
gyroADC[axis] = lrintf(gyroADCf[axis]);
|
gyroADC[axis] = lrintf(gyroADCf[axis]);
|
||||||
|
} else {
|
||||||
|
gyroADCf[axis] = gyroADC[axis]; // Otherwise float pid controller will not have gyro input when filter disabled
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
gyroADCf[axis] = gyroADC[axis]; // Otherwise float pid controller will not have gyro input when filter disabled
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue