Skip to content

Commit

Permalink
add dynamicFilter mode. RP or RPY. fix as 0,1 not 1,2 :(
Browse files Browse the repository at this point in the history
  • Loading branch information
nerdCopter committed Mar 30, 2023
1 parent d56b242 commit 7e848ae
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/main/flight/pid.c
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,7 @@ void pidController(const pidProfile_t *pidProfile, const rollAndPitchTrims_t *an
float dDelta = ((feathered_pids * pureMeasurement) + ((1 - feathered_pids) * pureError)) * pidFrequency; //calculating the dterm determine how much is calculated using measurement vs error
//filter the dterm
#ifdef USE_GYRO_DATA_ANALYSE
if (isDynamicFilterActive() && pidProfile->dtermDynNotch && axis <= gyroConfig()->dyn_notch_mode) {
if (isDynamicFilterActive() && pidProfile->dtermDynNotch && axis <= gyroConfig()->dyn_notch_mode+1) {
for (int p = 0; p < gyroConfig()->dyn_notch_count; p++) {
if (getCenterFreq(axis, p) != previousNotchCenterFreq[axis][p]) {
previousNotchCenterFreq[axis][p] = getCenterFreq(axis, p);
Expand Down
2 changes: 1 addition & 1 deletion src/main/sensors/gyro.c
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,7 @@ static void gyroInitFilterDynamicNotch(gyroSensor_t *gyroSensor) {
gyroSensor->notchFilterDynApplyFn = nullFilterApply;
if (isDynamicFilterActive()) {
gyroSensor->notchFilterDynApplyFn = (filterApplyFnPtr)biquadFilterApplyDF1; // must be this function, not DF2
for (int axis = 0; axis < gyroConfig()->dyn_notch_mode; axis++) {
for (int axis = 0; axis < gyroConfig()->dyn_notch_mode+1; axis++) {
for (int axis2 = 0; axis2 < gyroConfig()->dyn_notch_count; axis2++) {
biquadFilterInit(&gyroSensor->gyroAnalyseState.notchFilterDyn[axis][axis2], 400, gyro.targetLooptime, gyroConfig()->dyn_notch_q / 100.0f, FILTER_NOTCH);
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/sensors/gyro.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ typedef struct smithPredictor_s {

#ifdef USE_GYRO_DATA_ANALYSE
typedef enum {
RP = 1,
RPY = 2
RP = 0,
RPY = 1
} dynamicGyroNotchMode_e;
#endif

Expand Down

0 comments on commit 7e848ae

Please sign in to comment.