summaryrefslogtreecommitdiff
path: root/2005/i/robert/src/ai/ai.cc
diff options
context:
space:
mode:
authorhaller2005-05-06 19:26:03 +0000
committerhaller2005-05-06 19:26:03 +0000
commita95c0b822899c7004cfe06e1a6dfb84461ebc125 (patch)
tree5bece17dd4c0eb7ac8220360ae5f3c673c84fc5f /2005/i/robert/src/ai/ai.cc
parent2f229e93056445ca05e0948ff663d850efcb3566 (diff)
Ai :
Intégration de la vision (test à faire)
Diffstat (limited to '2005/i/robert/src/ai/ai.cc')
-rw-r--r--2005/i/robert/src/ai/ai.cc73
1 files changed, 71 insertions, 2 deletions
diff --git a/2005/i/robert/src/ai/ai.cc b/2005/i/robert/src/ai/ai.cc
index 55cb27d..7cd50ab 100644
--- a/2005/i/robert/src/ai/ai.cc
+++ b/2005/i/robert/src/ai/ai.cc
@@ -71,8 +71,8 @@ void Ai::init(void)
// initialise la carte es
es_.init();
// on init la vision
- //oVision_.init(motor_.colorState() ? Group::redSkittle :
-// Group::greenSkittle); /// XXX
+ oVision_.init(motor_.colorState() ? Group::redSkittle :
+ Group::greenSkittle);
while (!update());
}
@@ -400,6 +400,75 @@ Ai::parcourtFond (void)
std::cout << "Fini : " << Timer::getRoundTime () << std::endl;
}
+// *** Fonctions de vision ***
+
+// On scan tout autour du robot
+void Ai::scanVision (bool followLine) /// XXX mettre un argument
+{
+ double angleDepart = motor_.getA();
+ std::vector<std::vector<Zone> > skittles;
+ for (int i = 0; i < (followLine ? 1 : 4) ; i++)
+ {
+ // On prend la photo
+ oVision_.takeShoot();
+ // On analyse la photo
+ oVision_.update();
+ // On mets la liste brute dans le vector
+ skittles.push_back(oVision_.getSkittles());
+ // on tournicote
+ motor_.rotation(angleDepart + ((i + 1) * M_PI/4));
+ }
+ analyseSkittles(skittles);
+}
+
+// XXX Aucun moyen de tourner pour l'instant (donc followLine only)
+// On analyse les quilles pour ne garder que les prétendants
+void Ai::analyseSkittles(std::vector<std::vector<Zone> > skittlesBrut)
+{
+ goodSkittles_.clear();
+ // On regarde pour tout les angles
+ for(std::vector<std::vector<Zone> >::iterator it = skittlesBrut.begin();
+ it != skittlesBrut.end(); it++)
+ {
+ // On regarde zone par zone
+ for(std::vector<Zone>::iterator it2 = it->begin(); it2 != it->end(); it2++)
+ {
+ if (!it2->alone)
+ continue;
+ if (it2->vertical)
+ continue;
+ if (it2->partial)
+ continue;
+ if (it2->small)
+ continue;
+ goodSkittles_.push_back(*it2);
+ }
+ }
+}
+
+
+// On remonte la ze quille la meilleur détecté par la cam
+void Ai::remonteWithCam(void)
+{
+ int x, y , angle, dist;
+ Zone zeSkittles = goodSkittles_.back();
+ oVision_.getLoc(zeSkittles, x, y, angle, dist);
+ dist -= 9;
+ rotation(motor_.getA() + angle);
+ setMaxSpeed(2,1);
+ basic(dist);
+ ascenceur(true);
+ basic (-dist - 5);
+ rotation(M_PI);
+ rotation(M_PI / 2);
+ basic(30); // XXX vérifier valeur
+ ventouses();
+ setMaxSpeed(8, 4);
+ basic(-30); // XXX Vérifier valeur
+ ascenceur(false);
+ rotation(3 * M_PI / 4);
+}
+
// Va du point de départ au pont pour protéger les quilles.
void
Ai::protectQuillePont (void)