From fe37f66264914ca37c77be02cec2c1d1a10043d7 Mon Sep 17 00:00:00 2001 From: haller Date: Sat, 23 Apr 2005 20:46:35 +0000 Subject: Ajout du Makefile.def pour ai Définition terminée d'un premier header pour ai Première implémentation de ai Ne compile pas --- 2005/i/robert/src/ai/Makefile.defs | 7 +++ 2005/i/robert/src/ai/ai.cc | 98 ++++++++++++++++++++++++++++++++++++++ 2005/i/robert/src/ai/ai.hh | 33 +++++++------ 3 files changed, 124 insertions(+), 14 deletions(-) create mode 100644 2005/i/robert/src/ai/Makefile.defs diff --git a/2005/i/robert/src/ai/Makefile.defs b/2005/i/robert/src/ai/Makefile.defs new file mode 100644 index 0000000..4855ca6 --- /dev/null +++ b/2005/i/robert/src/ai/Makefile.defs @@ -0,0 +1,7 @@ +PROGRAMS += test_ai + +ai_OBJECTS = ai.o + +test_ai_OBJECTS = test_ai.o $(ai_OBJECTS) + +test_ai: $(test_ai_OBJECTS) diff --git a/2005/i/robert/src/ai/ai.cc b/2005/i/robert/src/ai/ai.cc index 3e81151..599efc1 100644 --- a/2005/i/robert/src/ai/ai.cc +++ b/2005/i/robert/src/ai/ai.cc @@ -23,3 +23,101 @@ // // }}} +/// Constructeur +Ai::Ai(const Config & config) + :motor(config), roundDuration(config.get("ai.roundDuration")), + enMouvement(false) +{ +} + +/// Initialise le robot +void init(void) +{ + // Initialise les moteurs + motor_.init(); + // initialise la carte es + es_.init(); + // XXX peut-il faire des actions?? +} + +/// stop le robot +void stop(void) +{ + // Stop les moteurs + motor_.stop(); +} + +/// Lance le robot +void run(void) +{ + // XXX Effectue plein d'actions plus ou moins conne + +} + +// Attend le jack entré (false) ou sorti (true). +void waitJack (bool out) +{ + while (es_.stateJack() != out) + update(); +} + +/// Rejoint un point. (argument en mm) +void goTo (double x, double y) // XXX Y'a une vitesse par defaut?? +{ + while (motor_.getX() != x || motor_.getY() != y) + { + motor_.goTo(x,y); + update(); + } +} + +/// Recale contre une bordure. +void recale (void) +{ + while(!es_.capteursContact()) + { + motor_.recalage(); //XXX hum... + update(); + } +} + +/// Mouvement basic. XXX c'est quoi les arguments là?? +void basic (double v, double d) +{ + motor.setSpeed(v); + do + { + motor_.linearMove(d); + update(); // XXX Et si on se prend un mur????? + } + while (!motor_.waiting()); +} + +/// Rotation (argument en radian) +void rotation (double a) +{ + do + { + motor_.rotation(a); + update(); + }while (!motor_.waiting()); +} + +/// Monte(vrai) ou descend(faux) l'ascenceur +void ascenceur (bool monte) +{ + while(es_.stateAsc() != monte ? true : false) + { + es_.moveAsc(monte); // XXX bon le nom de la fonction est à chier on est d'accord + update(); + } +} + +/// Désactive les ventouse +void ventouses (void) +{ + es_.ventouses(); + while(!es_.stateVentouses()) // XXX Ca, ca doit servir à rien + update(); +} + diff --git a/2005/i/robert/src/ai/ai.hh b/2005/i/robert/src/ai/ai.hh index 94b001e..b86412e 100644 --- a/2005/i/robert/src/ai/ai.hh +++ b/2005/i/robert/src/ai/ai.hh @@ -13,7 +13,7 @@ // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. -// +// // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -31,6 +31,9 @@ class Ai private: // Modules de controle du robot Motor motor_; + Es es_; + // Scheduler du robot + Scheduler scheduler_; // Gpio gpio_; // XXX // Paramètre de Ai const int roundDuration_; @@ -40,17 +43,17 @@ class Ai public: /// Constructeur Ai(const Config & config); - // Initialise le robot. - void init (void); - /// Arrète le robot. - void stop (void); - /// Lance le robot. - void run (int strat); - protected: - /// Lance le robot. - void run0 (void); - void run1 (void); - /// Attend. + // Initialise le robot. + void init (void); + /// Arrète le robot. + void stop (void); + /// Lance le robot. + void run (int strat); + protected: + /// Lance le robot. + void run0 (void); + void run1 (void); + /// Attend. void wait (int t); // Attend le jack entré (false) ou sorti (true). void waitJack (bool out); @@ -58,12 +61,14 @@ class Ai void goTo (double x, double y); /// Recale contre une bordure. void recale (void); - /// Recale et ajuste en X contre une bordure. - void recaleX (double x, double a); /// Mouvement basic. void basic (double v, double d); /// Rotation. void rotation (double a); + /// Monte(vrai) ou descend(faux) l'ascenceur + void ascenceur (bool monte); + /// Désactive les ventouse + void ventouses (void); }; #endif // ai_hh -- cgit v1.2.3