summaryrefslogtreecommitdiff
path: root/2005/i/robert
diff options
context:
space:
mode:
Diffstat (limited to '2005/i/robert')
-rw-r--r--2005/i/robert/runtime/rc/config6
-rw-r--r--2005/i/robert/src/ai/ai.cc35
-rw-r--r--2005/i/robert/src/motor/motor.cc7
-rw-r--r--2005/i/robert/src/motor/motor.hh2
4 files changed, 39 insertions, 11 deletions
diff --git a/2005/i/robert/runtime/rc/config b/2005/i/robert/runtime/rc/config
index 11f6099..9c7f686 100644
--- a/2005/i/robert/runtime/rc/config
+++ b/2005/i/robert/runtime/rc/config
@@ -2,14 +2,16 @@
asserv.tty = "/dev/ttyS1"
asserv.footing = 0xE3F
asserv.epsilon = 200.00
-asserv.accel = 64 #faut que ca fasse 8 dans l'AVR
+# Aprés homolgation, passage de 64 à 96
+asserv.accel = 96 #faut que ca fasse 8 dans l'AVR
asserv.kp = 0x0FFF
asserv.ki = 0x0040
asserv.kd = 0x0FFF
asserv.eSat = 1023 # p E w
asserv.speedIntMax = 8191 #Isat
asserv.dSample = 1 # p s b
-asserv.maxSLin = 16
+# Aprés homolgation, passage de 16 à 8
+asserv.maxSLin = 8
asserv.maxSRot = 4
asserv.useTazFSM = false
asserv.pwmMax = 256
diff --git a/2005/i/robert/src/ai/ai.cc b/2005/i/robert/src/ai/ai.cc
index c184f95..34eb75d 100644
--- a/2005/i/robert/src/ai/ai.cc
+++ b/2005/i/robert/src/ai/ai.cc
@@ -43,14 +43,16 @@ Ai::Ai(const Config & config)
roundDuration_(config.get<int>("ai.roundDuration")),
vitesseAsc_(config.get<int>("ai.vitesseAsc"))
{
- //instance = this
scheduler_.insert (schedulableMotor_);
scheduler_.insert (schedulableEs_);
}
+/// Destructeur
Ai::~Ai (void)
{
+ // On réinitialise
init ();
+ // On sync
do {
update ();
}
@@ -75,6 +77,11 @@ void Ai::stop(void)
{
// Stop les moteurs
motor_.stop();
+ // On sync
+ do
+ {
+ update ();
+ } while (!motor_.idle ());
}
/// Lance le robot
@@ -86,7 +93,8 @@ void Ai::run(void)
// Attend l'entrée du jack "pret à initialiser"
std::cout << "On attend le jack" << std::endl;
waitJack(false);
- std::cout << "Le jack est mis" << std::endl;
+ std::cout << "Le jack est mis, on réinit la PWM" << std::endl;
+ motor_.setPwm (0, 0);
// Attend la première sortie du jack(init)
waitJack(true);
std::cout << "Le jack est sorti" << std::endl;
@@ -193,7 +201,6 @@ void Ai::goTo (double x, double y ,double a)
}
/// Recale contre une bordure.
-// XXX Voir ca plus précisemment
void Ai::recale (void)
{
motor_.recalage();
@@ -219,12 +226,22 @@ void Ai::basic (double d)
void Ai::rotation (double a)
{
// On vérifie que ca ne fasse pas moins de trois degré
- // XXX
- motor_.rotation(a);
- do
- {
- update();
- }while (!motor_.idle()); // XXX Gérer le cas d'une rotation trop petite
+ // On récupère l'angle
+ double destNorm;
+ // On normalise si besoin
+ if (a < 0)
+ destNorm += 2 * M_PI;
+ // On récupère la différence d'angle
+ double diff = motor_.getA () - destNorm;
+ double limit = 3 / 360 * 2 * M_PI; // 3 degré en radian XXX
+ if (diff > limit || diff < - limit)
+ {
+ motor_.rotation(a);
+ do
+ {
+ update();
+ } while (!motor_.idle());
+ }
}
/// Monte(vrai) ou descend(faux) l'ascenceur
diff --git a/2005/i/robert/src/motor/motor.cc b/2005/i/robert/src/motor/motor.cc
index 9cf55f8..c292e9c 100644
--- a/2005/i/robert/src/motor/motor.cc
+++ b/2005/i/robert/src/motor/motor.cc
@@ -58,6 +58,7 @@ void Motor::init (void)
void Motor::stop(void)
{
asserv_.setSpeed();
+ idle_ = true;
}
double Motor::getX(void)
@@ -85,6 +86,12 @@ void Motor::setPosition(double x, double y, double a) //XXX Faire trois setteur
posA_ = a;
}
+void
+Motor::setPwm(int leftPwm, int rightPwm)
+{
+ asserv_.setPwm (leftPwm, rightPwm);
+}
+
void Motor::goTo(double x, double y, double a)
{
diff --git a/2005/i/robert/src/motor/motor.hh b/2005/i/robert/src/motor/motor.hh
index 062957c..b527525 100644
--- a/2005/i/robert/src/motor/motor.hh
+++ b/2005/i/robert/src/motor/motor.hh
@@ -115,6 +115,8 @@ class Motor : public Asserv::Receiver
void receiveSpeedStat (int leftError, int leftInt, int rightError,
int rightInt);
void receivePwm (double leftPwm, double rightPwm);
+ // Défini les valeurs de la PWM
+ void setPwm(int leftPwm = 0, int rightPwm = 0);
void receiveTiming (int motorTimer4,
int motorTimer3, int motorTimer2,
int motorTimer1, int motorTimer0);