summaryrefslogtreecommitdiff
path: root/i/marvin/src
diff options
context:
space:
mode:
Diffstat (limited to 'i/marvin/src')
-rw-r--r--i/marvin/src/ai/ai.cc50
1 files changed, 40 insertions, 10 deletions
diff --git a/i/marvin/src/ai/ai.cc b/i/marvin/src/ai/ai.cc
index 0d24afa..ac06157 100644
--- a/i/marvin/src/ai/ai.cc
+++ b/i/marvin/src/ai/ai.cc
@@ -260,12 +260,36 @@ void Ai::progHomoloRobal(void)
void
Ai::progMatch(void)
{
+ bool isFinish;
/// On prépare le robot
prepare();
/// Faire des crêpes...
+ /// Init du barillet
+ es_.barilletDebutLancement();
+ while (!update ());
+ temporisation (1000);
+ es_.barilletLancement();
+ while (!update ());
+ /// En avant guingamp
+ motorMove(480,0);
+ /// On tourner de -90°
+ motorMove(432,432);
+ /// On dit bonjour au mur
+ if(motorMove(900, 0))
+ motorMove(200, 0);
+ /// On tourne bizarrement mais de 90°
+ motorMove(-72,-72);
+ motorMove(360,-360);
+ /// On avance un peu
+ motorMove(150,0);
+ // On tourne de 90°
+ motorMove(432,-432);
+ motorMove(1400,0);
+ afterMatch();
}
-void
+/// Avance le robal et dit si il a finit (true) ou si il a bloqué
+bool
Ai::motorMove (int d, int a)
{
motor_.move(d, a); /// XXX Voir la distance
@@ -273,7 +297,10 @@ Ai::motorMove (int d, int a)
{
update ();
}
- while (!motor_.finish ());
+ while (!motor_.finish () && !motor_.blocked());
+ if(motor_.finish())
+ return true;
+ return false;
}
void
@@ -312,12 +339,15 @@ Ai::motorSmartFindHole (double distOut)
do
{
update();
- /// On regarde si on a pas atteint la distOut
- motor_.getPosition(x, y, a);
- /// XXX C'est propre ça?
- dist = sqrt(((x - bx)*(x - bx)) + ((y - by)*(y - by)));
- if (dist > distOut)
- return 0;
+ if (distOut != 0)
+ {
+ /// On regarde si on a pas atteint la distOut
+ motor_.getPosition(x, y, a);
+ /// XXX C'est propre ça?
+ dist = sqrt(((x - bx)*(x - bx)) + ((y - by)*(y - by)));
+ if (dist > distOut)
+ return 0;
+ }
/// on regarde si les capteurs voit un trou
if(es_.colorSeen(es_.leftFrontRVB_) == es_.redColor_ ||
es_.colorSeen(es_.leftFrontRVB_) == es_.blueColor_)
@@ -330,7 +360,7 @@ Ai::motorSmartFindHole (double distOut)
motor_.findHole();
}
else if(es_.colorSeen(es_.rightFrontRVB_) == es_.redColor_ ||
- es_.colorSeen(es_.rightFrontRVB_) == es_.blueColor_)
+ es_.colorSeen(es_.rightFrontRVB_) == es_.blueColor_)
{
// Si c'est le cas on repositionne le robot
motor_.stop();
@@ -340,7 +370,7 @@ Ai::motorSmartFindHole (double distOut)
motor_.findHole();
}
}
- while (!motor_.finish() || motor_.blocked());
+ while (!motor_.finish() && !motor_.blocked());
/// On regarde si on a blocké
if(motor_.blocked())
return -1;