Skip to content

Commit 43a7bf5

Browse files
committed
update:ローパスフィルタの係数をメンバ変数に変更
1 parent 7a3a536 commit 43a7bf5

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

modules/Pid.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ double Pid::calculatePid(double currentValue, double delta)
5151
* 偏差が大きい際に過大な変化量を一気に与えず
5252
* 滑らかな変化にし、機体の暴走を防ぐため
5353
*/
54-
filteredDerivative = 0.8 * currentDerivative + (0.2) * filteredDerivative;
54+
filteredDerivative = alpha * currentDerivative + (1.0 - alpha) * filteredDerivative;
5555

5656
// 前回の偏差を更新する
5757
prevDeviation = currentDeviation;

modules/Pid.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ class Pid {
5959
double targetValue; // 目標値
6060
double maxIntegral = 100; // 累積積分値の最大値
6161
double minIntegral = -100; // 累積積分値の最小値
62+
double alpha = 0.8; // ローパスフィルタの係数
6263
};
6364

6465
#endif

0 commit comments

Comments
 (0)