summaryrefslogtreecommitdiff
path: root/2005
diff options
context:
space:
mode:
authorhaller2005-05-02 19:02:10 +0000
committerhaller2005-05-02 19:02:10 +0000
commit4fa1434052dd603cec70f0edfeeca8f47905fbfe (patch)
tree051959314bd51ca17d9b90567b64a90ff3a1f876 /2005
parent1919e963fa7c7004e121b690b2d6d0021ddf41a2 (diff)
Ajout des paramètres d'asserv eSat et dSample
Ajout d'une vietesse linéaire et rotation
Diffstat (limited to '2005')
-rw-r--r--2005/i/robert/src/asserv/asserv.cc49
-rw-r--r--2005/i/robert/src/asserv/asserv.hh9
-rw-r--r--2005/i/robert/src/asserv/test_asserv.cc14
3 files changed, 55 insertions, 17 deletions
diff --git a/2005/i/robert/src/asserv/asserv.cc b/2005/i/robert/src/asserv/asserv.cc
index fea281a..3288ac6 100644
--- a/2005/i/robert/src/asserv/asserv.cc
+++ b/2005/i/robert/src/asserv/asserv.cc
@@ -50,18 +50,20 @@ void Asserv::reset(void)
setKp(kp_);
setKi(ki_);
setKd(kd_);
+ setESat(eSat_);
setSpeedIntMax(speedIntMax_);
+ setDSample(dSample_);
setAccel(accel_);
- setMaxSpeed(maxSpeed_);
+ setMaxSpeed(maxSLin_, maxSRot_);
setUseTazFSM(useTazFSM_);
- //setInvPwm(leftInvPwm_, rightInvPwm_);
- //statCounter(pCounter_);
- //statPosition(pPosition_);
- //statMotor(pMotor_);
- //statPwm(pPwm_);
- //statTiming(pTiming_);
- //statInPort(pStatInPort_);
- //statSharp(pStatInPort_);
+ setInvPwm(leftInvPwm_, rightInvPwm_);
+ statCounter(pCounter_);
+ statPosition(pPosition_);
+ statMotor(pMotor_);
+ statPwm(pPwm_);
+ statTiming(pTiming_);
+ statInPort(pStatInPort_);
+ statSharp(pStatInPort_);
}
/// Essaie de purger la liste d'mission et indique si elle est vide.
@@ -281,12 +283,25 @@ void Asserv::setKd(double Kd)
proto_.send('p',"bw", 'd', static_cast<int>(Kd * 256));
}
+void Asserv::setESat(int eSat)
+{
+ eSat_ = eSat;
+ // Envoie l'AVR
+ proto_.send('p', "bw", 'E', eSat);
+}
+
void Asserv::setSpeedIntMax(int maxInt)
{
speedIntMax_ = maxInt;
proto_.send('p', "bW", 'I', maxInt);
}
+void Asserv::setDSample (int dSample)
+{
+ dSample_ = dSample;
+ proto_.send('p', "bb", 's', dSample);
+}
+
void Asserv::setAccel(int accel)
{
accel_ = accel_;
@@ -301,13 +316,16 @@ double Asserv::getAccel(void)
return mmPpas_ / (sPperiod_ * sPperiod_) / accel_; // XXX Vrifier ca
}
-void Asserv::setMaxSpeed(int maxSpeed)
+/// Rgle les vitesses maximum(lineaire et rotation)
+void Asserv::setMaxSpeed(int maxSLin, int maxSRot)
{
- maxSpeed_ = maxSpeed;
+ maxSLin_ = maxSLin;
+ maxSRot_ = maxSRot;
// Conversion mm->ppp
- int p = mms2ppp(maxSpeed);
+ int p = mms2ppp(maxSLin);
+ int r = radTo256(maxSRot);
// Envoie l'AVR
- proto_.send('p',"bb", 'm', p);
+ proto_.send('p',"bbb", 'm', p, r);
}
void Asserv::setUseTazFSM(bool use)
@@ -413,8 +431,11 @@ void Asserv::loadConfig(const Config & config)
kp_ = config.get<double>("asserv.kp");
ki_ = config.get<double>("asserv.ki");
kd_ = config.get<double>("asserv.kd");
+ eSat_ = config.get<int>("asserv.eSat");
speedIntMax_ = config.get<int>("asserv.speedIntMax");
- maxSpeed_ = config.get<int>("asserv.maxSpeed");
+ dSample_ = config.get<int>("asserv.dSample");
+ maxSLin_ = config.get<int>("asserv.maxSLin");
+ maxSRot_ = config.get<int>("asserv.maxSRot");
useTazFSM_ = config.get<bool>("asserv.useTazFSM");
mmPpas_ = config.get<double>("asserv.mmPpas");
sPperiod_ = config.get<double>("asserv.sPperiod");
diff --git a/2005/i/robert/src/asserv/asserv.hh b/2005/i/robert/src/asserv/asserv.hh
index 246ef5c..b322e0b 100644
--- a/2005/i/robert/src/asserv/asserv.hh
+++ b/2005/i/robert/src/asserv/asserv.hh
@@ -69,8 +69,11 @@ class Asserv : public NonCopyable, public Proto::Receiver
double kp_;
double ki_;
double kd_;
+ int eSat_;
int speedIntMax_;
- int maxSpeed_; //unit AVR
+ int dSample_;
+ int maxSLin_;//unit AVR
+ int maxSRot_;
bool leftInvPwm_, rightInvPwm_;
bool useTazFSM_;
// Stat
@@ -126,10 +129,12 @@ class Asserv : public NonCopyable, public Proto::Receiver
void setKp (double kp);
void setKi (double ki);
void setKd (double kd);
+ void setESat (int eSat);
void setSpeedIntMax (int maxInt);
+ void setDSample(int dSample);
void setAccel (int accel);
double getAccel (void);
- void setMaxSpeed(int maxSpeed);
+ void setMaxSpeed(int maxSLin, int maxSRot);
void setUseTazFSM(bool use);
void setInvPwm(bool leftInvPwm, bool rightInvPwm);
//@}
diff --git a/2005/i/robert/src/asserv/test_asserv.cc b/2005/i/robert/src/asserv/test_asserv.cc
index 56483b6..ce3307a 100644
--- a/2005/i/robert/src/asserv/test_asserv.cc
+++ b/2005/i/robert/src/asserv/test_asserv.cc
@@ -276,11 +276,21 @@ main (int argc, char **argv)
throw std::runtime_error("syntax error");
asserv.setKd(strtod(argv[i], 0));
break;
+ case 'E':
+ if(++i > argc)
+ throw std::runtime_error("syntax error");
+ asserv.setESat(strtol(argv[i], 0, 10));
+ break;
case 'I':
if(++i > argc)
throw std::runtime_error("syntax error");
asserv.setSpeedIntMax(strtol(argv[i], 0, 10));
break;
+ case 's':
+ if(++i > argc)
+ throw std::runtime_error("syntax error");
+ asserv.setDSample(strtol(argv[i], 0, 10));
+ break;
case 'A':
if(++i > argc)
throw std::runtime_error("syntax error");
@@ -289,7 +299,9 @@ main (int argc, char **argv)
case 'm':
if(++i > argc)
throw std::runtime_error("syntax error");
- asserv.setMaxSpeed(strtol(argv[i], 0, 10));
+ asserv.setMaxSpeed(strtol(argv[i], 0, 10),
+ strtol(argv[i + 1], 0, 10));
+ i++;
break;
case 'W':
if (++i + 1 > argc)