Adaptation K22F

Dependencies:   mbed

Committer:
singularity
Date:
Tue Dec 16 15:52:17 2014 +0000
Revision:
0:6004a7230f87
Creation k22F

Who changed what in which revision?

UserRevisionLine numberNew contents of line
singularity 0:6004a7230f87 1 #include "Pid.h"
singularity 0:6004a7230f87 2
singularity 0:6004a7230f87 3 Pid::Pid()
singularity 0:6004a7230f87 4 {
singularity 0:6004a7230f87 5 this->kp = 0;
singularity 0:6004a7230f87 6 this->ki = 0;
singularity 0:6004a7230f87 7 this->kd = 0;
singularity 0:6004a7230f87 8 }
singularity 0:6004a7230f87 9
singularity 0:6004a7230f87 10 Pid::Pid(float Kp, float Ki, float Kd)
singularity 0:6004a7230f87 11 {
singularity 0:6004a7230f87 12 this->kp = Kp;
singularity 0:6004a7230f87 13 this->ki = Ki;
singularity 0:6004a7230f87 14 this->kd = Kd;
singularity 0:6004a7230f87 15 }
singularity 0:6004a7230f87 16
singularity 0:6004a7230f87 17 void Pid::setKp(float Kp)
singularity 0:6004a7230f87 18 {
singularity 0:6004a7230f87 19 this->kp = Kp;
singularity 0:6004a7230f87 20 }
singularity 0:6004a7230f87 21 void Pid::setKi(float Ki)
singularity 0:6004a7230f87 22 {
singularity 0:6004a7230f87 23 this->ki = Ki;
singularity 0:6004a7230f87 24 }
singularity 0:6004a7230f87 25
singularity 0:6004a7230f87 26 void Pid::setKd(float Kd)
singularity 0:6004a7230f87 27 {
singularity 0:6004a7230f87 28 this->kd = Kd;
singularity 0:6004a7230f87 29 }
singularity 0:6004a7230f87 30 float Pid::getCommande(float p_erreur, float i_erreur, float d_erreur)
singularity 0:6004a7230f87 31 {
singularity 0:6004a7230f87 32 return this->kp * p_erreur +
singularity 0:6004a7230f87 33 this->ki * i_erreur +
singularity 0:6004a7230f87 34 this->kd * d_erreur;
singularity 0:6004a7230f87 35 }
singularity 0:6004a7230f87 36
singularity 0:6004a7230f87 37 float Pid::getCommande(Erreur e)
singularity 0:6004a7230f87 38 {
singularity 0:6004a7230f87 39 return this->getCommande(e.p,e.i,e.d);
singularity 0:6004a7230f87 40 }