summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--i/chuck/src/ai/ai.cc40
-rw-r--r--i/chuck/src/es/es.cc1
2 files changed, 29 insertions, 12 deletions
diff --git a/i/chuck/src/ai/ai.cc b/i/chuck/src/ai/ai.cc
index 0810990..da62abd 100644
--- a/i/chuck/src/ai/ai.cc
+++ b/i/chuck/src/ai/ai.cc
@@ -158,7 +158,7 @@ Ai::prepare (void)
//on fait tomber le roulo apré le top départ
es_.roulo_tombe();
temporisation(1500);
- es_.roulo_roule(0xD8);
+ es_.roulo_roule(0xDD);
es_.setOthersStat (0);
std::cout<<"le roulo auré du tombé"<<std::endl;
// Shut up fucking beach !
@@ -301,10 +301,32 @@ Ai::progMatch(void)
bool
Ai::motorMove (double d, double a)
{
+ double xStart, yStart, xCur, yCur, dummy;
+ motor_.getPosition (xStart, yStart, dummy);
+
motor_.move(d, a); /// XXX Voir la distance
do
{
update ();
+ if(es_.getSharpAck())
+ {
+ // Stop !
+ stop ();
+ // Go back a little bit
+ motor_.move (-100, 0);
+ do
+ {
+ update ();
+ } while (!motor_.finish ());
+ // Get current position
+ motor_.getPosition (xCur, yCur, dummy);
+ // Re eanble sharps
+ es_.launchSharpDetection ();
+ // Go to the position we want first
+ double xDiff = xStart - xCur;
+ double yDiff = yStart - yCur;
+ motor_.move (sqrt (xDiff * xDiff + yDiff * yDiff), 0);
+ }
}
while (!motor_.finish ()/* && !motor_.blocked()*/);
if(motor_.finish())
@@ -317,9 +339,9 @@ Ai::motorRotate (double d)
{
motor_.rotate (d);
do
- {
- update ();
- }
+ {
+ update ();
+ }
while (!motor_.finish ());
}
@@ -331,13 +353,7 @@ Ai::motorDeblock (void)
void
Ai::avoidrobot(void)
{
- motorRotate(3.14116/2*(coefcolor));//faire calcul ailleur
- motorMove(100.,0.);
- motorRotate(3.14116/(-2)*(coefcolor));//voir plus haut
- motorMove(300.,0.);
- motorRotate(3.14116/(-2)*(coefcolor));
- motorMove(100.,0.);
- motorRotate(3.14116/2*(coefcolor));
- motorMove(300.,0.);
+ es_.launchSharpDetection();
+
}
diff --git a/i/chuck/src/es/es.cc b/i/chuck/src/es/es.cc
index 668aab1..1f32925 100644
--- a/i/chuck/src/es/es.cc
+++ b/i/chuck/src/es/es.cc
@@ -289,6 +289,7 @@ Es::roulo_tombe(void)
void
Es::launchSharpDetection (void)
{
+ ackSharp_ = false;
setSharpUpdate (2, freqSharp_);
}