From 01f9051ce4d7221a588a2d3853f15662911986f9 Mon Sep 17 00:00:00 2001 From: haller Date: Thu, 25 May 2006 05:14:33 +0000 Subject: Codage de l'AI d'homologation... --- i/marvin/src/ai/ai.cc | 67 ++++++++++++++++++++++++++++++++++++++++++++------- i/marvin/src/ai/ai.hh | 3 +++ 2 files changed, 61 insertions(+), 9 deletions(-) (limited to 'i/marvin') diff --git a/i/marvin/src/ai/ai.cc b/i/marvin/src/ai/ai.cc index d9bfd0a..986f53b 100644 --- a/i/marvin/src/ai/ai.cc +++ b/i/marvin/src/ai/ai.cc @@ -130,15 +130,21 @@ Ai::waitJack (bool out) void Ai::prepare (void) { + es_.setOthersStat (10); + while (!update ()); // XXX We should check if the jack is not already in // We first wait for the jack to be put inside waitJack (false); // We reference all the color referenceSensors (); + es_.barilletInit(); + while (!update ()); // We first wait for the jack to be put inside waitJack (true); // Ok the match begin ! Go go go ! Timer::startRound (); + es_.setOthersStat (0); + while (!update ()); } /// Reference sensors @@ -160,26 +166,69 @@ void Ai::progHomoloRobal(void) { /// On init le robal prepare(); - /// PAF BEGIN!!! (lancer le timer) - Timer::startRound(); + es_.barilletDebutLancement(); + while (!update ()); + temporisation (1000); + es_.barilletLancement(); + while (!update ()); /// on avance un poil parce que le mur c'est mal - motor_.move(400, 0); + motorMove(500, 0); + motorRotate(-0.54); + motorMove(1200, 0); + motorRotate(M_PI); + motorFindHole (); + /// On tourne XXX - motor_.rotate(-M_PI/4); +/// motorRotate(-M_PI/4); /// On cherche au moins une balle (sinon c'est con) - es_.barilletLancement(); - motor_.move(1000, 0); /// XXX Voir la distance +/// motorMove(1000, 0); /// XXX Voir la distance /// XXX Avancer d'une certaine facon pour choper des balles /// XXX Ouais ba y'a encore ddes truc à faire là /// On cherche un tru (repositionnement??) - motor_.lockGoodHole(); - motor_.findHole(); +/// motor_.lockGoodHole(); +/// while (!update ()); +/// motor_.findHole(); +/// while (!update ()); /// On trouve un trou, chouette /// Aspirer le trou - es_.extraitBalle(); + //es_.extraitBalle(); /// mettre une baballe es_.dropWhiteBall(); + while (!update ()); /// Tourner 3 fois en chantant du Mickael Jackson /// Again.... /// Fin du match } + +void +Ai::motorMove (int d, int a) +{ + motor_.move(d, a); /// XXX Voir la distance + do + { + update (); + } + while (!motor_.finish ()); +} + +void +Ai::motorRotate (double d) +{ + motor_.rotate (d); + do + { + update (); + } + while (!motor_.finish ()); +} + +void +Ai::motorFindHole (void) +{ + motor_.findHole (); + do + { + update (); + } + while (!motor_.finish ()); +} diff --git a/i/marvin/src/ai/ai.hh b/i/marvin/src/ai/ai.hh index 8d673e5..f0143ec 100644 --- a/i/marvin/src/ai/ai.hh +++ b/i/marvin/src/ai/ai.hh @@ -72,5 +72,8 @@ class Ai void referenceSensors (void); /// programme d'homologation du robal void progHomoloRobal(void); + void motorMove (int d, int a); + void motorRotate (double d); + void motorFindHole (void); }; #endif // ai_hh -- cgit v1.2.3