11 : controller(controller_), dist(), pid(targetSpeed, Kp, Ki, Kd)
18 prevDistance = dist.
getDistance(leftAngle, rightAngle);
31 double nextDistance = dist.
getDistance(leftAngle, rightAngle);
34 double currentSpeed = nextDistance - prevDistance;
37 prevDistance = dist.
getDistance(leftAngle, rightAngle);
40 double pidValue = pid.
control(currentSpeed);
43 double pwmValue = pidValue;
double calculateSpeed(int targetSpeed, double Kp, double Ki, double Kd)
SpeedControl(Controller &controller_, int targetSpeed, double Kp, double Ki, double Kd)
const double setParameter(double target_, double Kp_, double Ki_=0.0, double Kd_=0.0)
目標値とPIDゲインの設定をする関数
double control(double value, double delta=0.004)
double getDistance(int leftAngle, int rightAngle)
左右の平均走行距離を計算して戻り値として返す