summaryrefslogtreecommitdiff
path: root/i/chuck/src/ai/ai.cc
diff options
context:
space:
mode:
authorbecquet2007-05-11 12:47:52 +0000
committerbecquet2007-05-11 12:47:52 +0000
commitb95709754c870cbb793266ce8e605a81d01a4f75 (patch)
tree57cb6c9adbff2044c112d28b44f2488da6ff9c04 /i/chuck/src/ai/ai.cc
parent65e6a92b917c506516a952580015deee24ea358e (diff)
Diffstat (limited to 'i/chuck/src/ai/ai.cc')
-rw-r--r--i/chuck/src/ai/ai.cc200
1 files changed, 0 insertions, 200 deletions
diff --git a/i/chuck/src/ai/ai.cc b/i/chuck/src/ai/ai.cc
index 7bf5c5a..5d328c2 100644
--- a/i/chuck/src/ai/ai.cc
+++ b/i/chuck/src/ai/ai.cc
@@ -143,10 +143,6 @@ Ai::prepare (void)
// 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();
- es_.lcdPrint("Barillet pret ?");
es_.lcdPrint("Virer le jack !");
while (!update ());
// We first wait for the jack to be put inside
@@ -172,8 +168,6 @@ Ai::afterMatch(void)
while (!update());
waitJack(false);
// On vide le barillet
- es_.barilletEmpty();
- es_.lcdPrint("Vidange barillet");
while (!update());
waitJack(true);
// On init les cartes histoire de
@@ -182,30 +176,14 @@ Ai::afterMatch(void)
es_.lcdPrint("Power off!!");
while (!update());
}
-
-/// Reference sensors
-void
-Ai::referenceSensors (void)
-{
- // Reference sensors
- es_.refColor (reference_sensor_mask_);
- // Update data
- while (!update ());
- // Disable capturing all sensors
- es_.enableAllSensors (false);
- // Update data
- while (!update ());
-}
/// programme d'homologation du robal
void Ai::progHomoloRobal(void)
{
/// On init le robal
prepare();
- es_.barilletDebutLancement();
while (!update ());
temporisation (1000);
- es_.barilletLancement();
while (!update ());
/// on avance un poil parce que le mur c'est mal
std::cout << "Move !" << std::endl;
@@ -219,7 +197,6 @@ void Ai::progHomoloRobal(void)
motorMove(500, 0);
// temporisation (100);
std::cout << "Find hole !" << std::endl;
- motorBasicFindHole ();
/// On tourne XXX
/// motorRotate(-M_PI/4);
@@ -236,20 +213,13 @@ void Ai::progHomoloRobal(void)
/// Aspirer le trou
//es_.extraitBalle();
/// mettre une baballe
- es_.dropWhiteBall();
while (!update ());
temporisation (3000);
- es_.deposeBalle ();
while (!update ());
temporisation (3000);
motorMove(300, 0);
-
- std::cout << "Find hole !" << std::endl;
- motorBasicFindHole ();
- es_.dropWhiteBall();
while (!update ());
temporisation (3000);
- es_.deposeBalle ();
while (!update ());
temporisation (3000);
motorMove(300, 0);
@@ -269,15 +239,10 @@ Ai::progMatch(void)
/// On prépare le robot
prepare();
/// Faire des crêpes...
- /// Init du barillet
- es_.barilletDebutLancement();
while (!update ());
- log_ ("match") << "Totem activator";
- es_.totemActivator (true);
/// En avant guingamp
log_ ("match") << "Eloignement du bord";
motorMove(480,0);
- es_.barilletLancement();
while (!update ());
/// On tourner de -90°
log_ ("match") << "Petite rotation de 90°";
@@ -312,90 +277,6 @@ Ai::progMatch(void)
/* Save angle */
motor_.getPosition (dummy, dummy, aStart);
- do
- {
- log_ ("match") << "Start loop for finding holes";
-
- // Save Y position each time
- motor_.getPosition (dummy, distanceCur, dummy);
-
- // Look for an hole !
- if (rotationSens % 2)
- remainingDist = std::abs (distanceMax[1] - distanceCur);
- else
- remainingDist = std::abs (distanceMax[0] - distanceCur);
- // Protection again stupid computing
- if (remainingDist > 0.)
- ret = motorSmartFindHole (remainingDist);
- else
- // Force a turn back !
- ret = 0;
- switch (ret)
- {
- case 0:
- // Here we should turn back in the other way
- log_ ("match") << "Trop long, demi tour !";
- if (rotationSens % 2)
- motor_.move (432, -432);
- else
- motor_.move (432, 432);
- rotationSens++;
- /* Compute the new angle */
- motor_.getPosition (dummy, dummy, aStart);
- break;
- case -2:
- /// La couleur est unknown
- log_ ("match") << "Hooooo une couleur de l'espace!!!!";
- // break;
- case 2:
- case 1:
- {
- log_ ("match") << "Ok on a une couleur!";
- bool retDrop;
- //if (((ret == es_.blueColor_) && es_.isColorModeBlue () )
- // || ((ret != es_.blueColor_) && !es_.isColorModeBlue ()))
- if (true)
- {
- // If it is our colour, put a white ball,
- log_ ("match") << "C'est notre couleur -> drop white !";
- retDrop = es_.dropWhiteBall();
- while (!update ());
- if (retDrop)
- {
- log_ ("match") << "Tempo & depot!";
- temporisation (3000);
- es_.deposeBalle ();
- temporisation (1000);
- while (!update ());
- }
- }
- else
- {
- // otherwise, put a black one.
- log_ ("match") << "Pas notre couleur, drop noir!";
- retDrop = es_.dropBlackBall();
- while (!update ());
- if (retDrop)
- {
- log_ ("match") << "Tempo & depot!";
- temporisation (3000);
- es_.deposeBalle ();
- temporisation (1000);
- while (!update ());
- }
- }
- // Put ourself back in the right direction
- motor_.getPosition (dummy, dummy, aEnd);
- log_ ("match") << "Remise en place de l'angle : " << aStart << " end " << aEnd;
- motor_.rotate (aStart - aEnd);
- }
- break;
- default:
- log_ ("match") << "Hooooo on a default!!!!";
- break;
- }
- } while (true);
-
afterMatch();
}
@@ -426,87 +307,6 @@ Ai::motorRotate (double d)
}
void
-Ai::motorBasicFindHole (void)
-{
- motor_.findHole ();
- do
- {
- update ();
- }
- while (!motor_.finish ());
- es_.enableAllSensors (true);
- es_.setRVBHoleStat (2);
- temporisation (500);
- log_ ("FindHole") << "We see" << es_.colorSeen (es_.holeRVB_) ;
- es_.setRVBHoleStat (0);
-}
-
-/// Renvoie une couleur définie dans es ou -1 si on s'est mangé un mur ou 0 si
-/// distanceOut
-int
-Ai::motorSmartFindHole (double distOut)
-{
- /// On sauvegarde la position actuelle
- double bx, x, by, y, ba, a;
- double dist;
- motor_.getPosition(bx, by, ba);
- /// on lance le robal à la recherche d'un tru
- motor_.findHole();
- do
- {
- update();
- 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_)
- {
- // Si c'est le cas on repositionne le robot
- motor_.stop();
- while(!update());
- // XXX Vérifier l'angle
- motorRotate(0.21);
- motor_.findHole();
- }
- else if(es_.colorSeen(es_.rightFrontRVB_) == es_.redColor_ ||
- es_.colorSeen(es_.rightFrontRVB_) == es_.blueColor_)
- {
- // Si c'est le cas on repositionne le robot
- motor_.stop();
- while(!update());
- // XXX Vérifier l'angle
- log_ ("SmartFindHole") << "Rotation spéciale ho un trou sous le capteur";
- motorRotate(-0.21);
- motor_.findHole();
- }
- }
- while (!motor_.finish() /*&& !motor_.blocked()*/);
- /// On regarde si on a blocké
-// if(motor_.blocked())
-// return -1;
- if(motor_.finish())
- {
- es_.enableAllSensors (true);
- es_.setRVBHoleStat (2);
- temporisation (500);
- int ret = es_.colorSeen(es_.holeRVB_);
- es_.setRVBHoleStat (0);
- es_.enableAllSensors (false);
- return ret;
- }
- /// XXX Le return qui ne doit jamais arriver normalement...
- return 0;
-}
-
-/// Procedure to unblock the robal
-void
Ai::motorDeblock (void)
{
}