@@ -73,7 +73,7 @@ volatile axisData_t oldSetPoint;
7373volatile axisData_t setPoint ;
7474volatile int allowFilterInit = 1 ;
7575
76- extern float r_filter_weight ;
76+ float sharpness ;
7777
7878void allow_filter_init (void )
7979{
@@ -104,7 +104,7 @@ void filter_init(void)
104104 pt1FilterInit (& ay_filter , k , 0.0f );
105105 pt1FilterInit (& az_filter , k , 0.0f );
106106
107- r_filter_weight = (float )filterConfig .r_weight / 100 .0f ;
107+ sharpness = (float )filterConfig .sharpness / 250 .0f ;
108108}
109109
110110void filter_data (volatile axisData_t * gyroRateData , volatile axisData_t * gyroAccData , float gyroTempData , filteredData_t * filteredData )
@@ -131,23 +131,23 @@ void filter_data(volatile axisData_t *gyroRateData, volatile axisData_t *gyroAcc
131131 filteredData -> rateData .z = biquad_update (filteredData -> rateData .z , & (lpfFilterStateRate .z ));
132132
133133// calculate the error
134- float errorMultiplierX = ABS (setPoint .x - filteredData -> rateData .x / 6.0f ) ;
135- float errorMultiplierY = ABS (setPoint .y - filteredData -> rateData .y / 6.0f ) ;
136- float errorMultiplierZ = ABS (setPoint .z - filteredData -> rateData .z / 6.0f ) ;
134+ float errorMultiplierX = ABS (setPoint .x - filteredData -> rateData .x ) * sharpness ;
135+ float errorMultiplierY = ABS (setPoint .y - filteredData -> rateData .y ) * sharpness ;
136+ float errorMultiplierZ = ABS (setPoint .z - filteredData -> rateData .z ) * sharpness ;
137137
138- float setPointChangeBoostX = CONSTRAIN ((ABS (setPoint .x - setPoint .x ) / 10.0f ) + 1.0f , 1.0f , 10.0f );
139- float setPointChangeBoostY = CONSTRAIN ((ABS (setPoint .y - setPoint .y ) / 10.0f ) + 1.0f , 1.0f , 10.0f );
140- float setPointChangeBoostZ = CONSTRAIN ((ABS (setPoint .z - setPoint .z ) / 10.0f ) + 1.0f , 1.0f , 10.0f );
138+ // float setPointChangeBoostX = CONSTRAIN((ABS(setPoint.x - setPoint.x) / 10.0f) + 1.0f, 1.0f, 10.0f);
139+ // float setPointChangeBoostY = CONSTRAIN((ABS(setPoint.y - setPoint.y) / 10.0f) + 1.0f, 1.0f, 10.0f);
140+ // float setPointChangeBoostZ = CONSTRAIN((ABS(setPoint.z - setPoint.z) / 10.0f) + 1.0f, 1.0f, 10.0f);
141141
142142// errorMultiplierX = errorMultiplierX * CONSTRAIN(ABS(setPoint.x / 100.0f), 0.1f, 1.0f);
143143// errorMultiplierY = errorMultiplierY * CONSTRAIN(ABS(setPoint.y / 100.0f), 0.1f, 1.0f);
144144// errorMultiplierZ = errorMultiplierZ * CONSTRAIN(ABS(setPoint.z / 100.0f), 0.1f, 1.0f);
145145
146146// give a boost to the setpoint, used to caluclate the filter cutoff, based on the error and setpoint/gyrodata
147147
148- errorMultiplierX = CONSTRAIN (errorMultiplierX * setPointChangeBoostX * ABS (1.0f - (setPoint .x / filteredData -> rateData .x )) + 1.0f , 1.0f , 10.0f );
149- errorMultiplierY = CONSTRAIN (errorMultiplierY * setPointChangeBoostX * ABS (1.0f - (setPoint .y / filteredData -> rateData .y )) + 1.0f , 1.0f , 10.0f );
150- errorMultiplierZ = CONSTRAIN (errorMultiplierZ * setPointChangeBoostX * ABS (1.0f - (setPoint .z / filteredData -> rateData .z )) + 1.0f , 1.0f , 10.0f );
148+ errorMultiplierX = CONSTRAIN (errorMultiplierX * ABS (1.0f - (setPoint .x / filteredData -> rateData .x )) + 1.0f , 1.0f , 10.0f );
149+ errorMultiplierY = CONSTRAIN (errorMultiplierY * ABS (1.0f - (setPoint .y / filteredData -> rateData .y )) + 1.0f , 1.0f , 10.0f );
150+ errorMultiplierZ = CONSTRAIN (errorMultiplierZ * ABS (1.0f - (setPoint .z / filteredData -> rateData .z )) + 1.0f , 1.0f , 10.0f );
151151
152152
153153 if (setPointNew )
0 commit comments