summaryrefslogtreecommitdiff
path: root/2005/i/robert
diff options
context:
space:
mode:
authorhaller2005-05-03 23:28:47 +0000
committerhaller2005-05-03 23:28:47 +0000
commit6eaaa29c57b70f3e9aa48c2d14fe9acfe008669d (patch)
treeda107aa5c792ad33248d411caffbe23a99f82aec /2005/i/robert
parent994270d9db219b565fcf940c6214e046f91aba35 (diff)
Correction de quelques bug (conversion)
Diffstat (limited to '2005/i/robert')
-rw-r--r--2005/i/robert/src/asserv/asserv.cc27
-rw-r--r--2005/i/robert/src/asserv/asserv.hh12
-rw-r--r--2005/i/robert/src/asserv/test_asserv.cc6
3 files changed, 20 insertions, 25 deletions
diff --git a/2005/i/robert/src/asserv/asserv.cc b/2005/i/robert/src/asserv/asserv.cc
index 3288ac6..dd0902b 100644
--- a/2005/i/robert/src/asserv/asserv.cc
+++ b/2005/i/robert/src/asserv/asserv.cc
@@ -35,8 +35,6 @@ Asserv::Asserv (const Config & config, Receiver & receiver)
loadConfig(config);
//Ouverture du port série
proto_.open(ttyName_);
- //Initialisation de l'AVR
- reset();
}
/// Reset de l'AVR
@@ -262,25 +260,25 @@ void Asserv::setEpsilon(double epsilon)
proto_.send('p',"bd", 'e', static_cast<int>(epsilon * 256));
}
-void Asserv::setKp(double Kp)
+void Asserv::setKp(int Kp)
{
kp_ = Kp;
// Envoie à l'AVR
- proto_.send('p',"bw", 'p', static_cast<int>(Kp * 256));
+ proto_.send('p',"bw", 'p', Kp);
}
-void Asserv::setKi(double Ki)
+void Asserv::setKi(int Ki)
{
ki_ = Ki;
// Envoie à l'AVR
- proto_.send('p',"bw", 'i', static_cast<int>(Ki * 256));
+ proto_.send('p',"bw", 'i', Ki);
}
-void Asserv::setKd(double Kd)
+void Asserv::setKd(int Kd)
{
kd_ = Kd;
// Envoie à l'AVR
- proto_.send('p',"bw", 'd', static_cast<int>(Kd * 256));
+ proto_.send('p',"bw", 'd', Kd);
}
void Asserv::setESat(int eSat)
@@ -321,11 +319,8 @@ void Asserv::setMaxSpeed(int maxSLin, int maxSRot)
{
maxSLin_ = maxSLin;
maxSRot_ = maxSRot;
- // Conversion mm->ppp
- int p = mms2ppp(maxSLin);
- int r = radTo256(maxSRot);
// Envoie à l'AVR
- proto_.send('p',"bbb", 'm', p, r);
+ proto_.send('p',"bbb", 'm', maxSLin, maxSRot);
}
void Asserv::setUseTazFSM(bool use)
@@ -340,7 +335,7 @@ void Asserv::setInvPwm(bool leftInvPwm, bool rightInvPwm)
leftInvPwm_ = leftInvPwm;
rightInvPwm_ = rightInvPwm;
// Envoie la commande à l'AVR
- proto_.send('p', "bbb", 'W', leftInvPwm ? 1 : 0, rightInvPwm ? 1 : 0);
+ proto_.send('p', "bbb", 'w', leftInvPwm , rightInvPwm);
}
/// implémentation du proto::Receiver
@@ -428,9 +423,9 @@ void Asserv::loadConfig(const Config & config)
footing_ = config.get<int>("asserv.footing");
epsilon_ = config.get<double>("asserv.epsilon");
accel_ = config.get<int>("asserv.accel");
- kp_ = config.get<double>("asserv.kp");
- ki_ = config.get<double>("asserv.ki");
- kd_ = config.get<double>("asserv.kd");
+ kp_ = config.get<int>("asserv.kp");
+ ki_ = config.get<int>("asserv.ki");
+ kd_ = config.get<int>("asserv.kd");
eSat_ = config.get<int>("asserv.eSat");
speedIntMax_ = config.get<int>("asserv.speedIntMax");
dSample_ = config.get<int>("asserv.dSample");
diff --git a/2005/i/robert/src/asserv/asserv.hh b/2005/i/robert/src/asserv/asserv.hh
index b322e0b..de135c3 100644
--- a/2005/i/robert/src/asserv/asserv.hh
+++ b/2005/i/robert/src/asserv/asserv.hh
@@ -66,9 +66,9 @@ class Asserv : public NonCopyable, public Proto::Receiver
int footing_; //truc
double epsilon_; //mm
int accel_; //unité AVR
- double kp_;
- double ki_;
- double kd_;
+ int kp_;
+ int ki_;
+ int kd_;
int eSat_;
int speedIntMax_;
int dSample_;
@@ -126,9 +126,9 @@ class Asserv : public NonCopyable, public Proto::Receiver
void setAngle(double angle);
void setFooting(int16_t dist);
void setEpsilon(double e);
- void setKp (double kp);
- void setKi (double ki);
- void setKd (double kd);
+ void setKp (int kp);
+ void setKi (int ki);
+ void setKd (int kd);
void setESat (int eSat);
void setSpeedIntMax (int maxInt);
void setDSample(int dSample);
diff --git a/2005/i/robert/src/asserv/test_asserv.cc b/2005/i/robert/src/asserv/test_asserv.cc
index ce3307a..ba9d033 100644
--- a/2005/i/robert/src/asserv/test_asserv.cc
+++ b/2005/i/robert/src/asserv/test_asserv.cc
@@ -264,17 +264,17 @@ main (int argc, char **argv)
case 'p':
if(++i > argc)
throw std::runtime_error("syntax error");
- asserv.setKp(strtod(argv[i], 0));
+ asserv.setKp(strtol(argv[i], 0, 10));
break;
case 'i':
if(++i > argc)
throw std::runtime_error("syntax error");
- asserv.setKi(strtod(argv[i], 0));
+ asserv.setKi(strtol(argv[i], 0, 10));
break;
case 'd':
if(++i > argc)
throw std::runtime_error("syntax error");
- asserv.setKd(strtod(argv[i], 0));
+ asserv.setKd(strtol(argv[i], 0, 10));
break;
case 'E':
if(++i > argc)