mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-23 00:05:33 +03:00
Remove lowpass.c // replace by pt1
unittests fix
This commit is contained in:
parent
19d1a92c4f
commit
83d8a8441c
11 changed files with 40 additions and 338 deletions
|
@ -119,7 +119,8 @@ extern uint32_t currentTime;
|
|||
extern uint8_t PIDweight[3];
|
||||
extern bool antiWindupProtection;
|
||||
|
||||
|
||||
static filterStatePt1_t filteredCycleTimeState;
|
||||
uint16_t filteredCycleTime;
|
||||
static bool isRXDataNew;
|
||||
|
||||
typedef void (*pidControllerFuncPtr)(pidProfile_t *pidProfile, controlRateConfig_t *controlRateConfig,
|
||||
|
@ -177,21 +178,10 @@ void filterRc(void){
|
|||
static int16_t deltaRC[4] = { 0, 0, 0, 0 };
|
||||
static int16_t factor, rcInterpolationFactor;
|
||||
uint16_t rxRefreshRate;
|
||||
static biquad_t filteredCycleTimeState;
|
||||
static bool filterIsSet;
|
||||
uint16_t filteredCycleTime;
|
||||
|
||||
// Set RC refresh rate for sampling and channels to filter
|
||||
initRxRefreshRate(&rxRefreshRate);
|
||||
|
||||
/* Initialize cycletime filter */
|
||||
if (!filterIsSet) {
|
||||
BiQuadNewLpf(0.5f, &filteredCycleTimeState, targetLooptime);
|
||||
filterIsSet = true;
|
||||
}
|
||||
|
||||
filteredCycleTime = applyBiQuadFilter((float) cycleTime, &filteredCycleTimeState);
|
||||
|
||||
rcInterpolationFactor = rxRefreshRate / filteredCycleTime + 1;
|
||||
|
||||
if (isRXDataNew) {
|
||||
|
@ -647,6 +637,12 @@ void taskMainPidLoop(void)
|
|||
cycleTime = getTaskDeltaTime(TASK_SELF);
|
||||
dT = (float)targetLooptime * 0.000001f;
|
||||
|
||||
// Calculate average cycle time and average jitter
|
||||
filteredCycleTime = filterApplyPt1(cycleTime, &filteredCycleTimeState, 0.5f, dT);
|
||||
|
||||
debug[0] = cycleTime;
|
||||
debug[1] = cycleTime - filteredCycleTime;
|
||||
|
||||
imuUpdateGyroAndAttitude();
|
||||
|
||||
annexCode();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue