summaryrefslogtreecommitdiff
path: root/i/chuck
diff options
context:
space:
mode:
authorbecquet2007-05-11 12:47:52 +0000
committerbecquet2007-05-11 12:47:52 +0000
commitb95709754c870cbb793266ce8e605a81d01a4f75 (patch)
tree57cb6c9adbff2044c112d28b44f2488da6ff9c04 /i/chuck
parent65e6a92b917c506516a952580015deee24ea358e (diff)
Diffstat (limited to 'i/chuck')
-rw-r--r--i/chuck/src/ai/ai.cc200
-rw-r--r--i/chuck/src/ai/ai.hh7
-rw-r--r--i/chuck/src/ai/test_ai.cc26
-rw-r--r--i/chuck/src/es/es.cc40
-rw-r--r--i/chuck/src/es/es.hh23
-rw-r--r--i/chuck/src/es/test_es.cc55
-rw-r--r--i/chuck/src/interpreter/interpreter.hh3
7 files changed, 39 insertions, 315 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)
{
}
diff --git a/i/chuck/src/ai/ai.hh b/i/chuck/src/ai/ai.hh
index 467955b..781935a 100644
--- a/i/chuck/src/ai/ai.hh
+++ b/i/chuck/src/ai/ai.hh
@@ -71,16 +71,11 @@ class Ai
void prepare (void);
/// Some after after a match
void afterMatch(void);
- /// Reference sensors
- void referenceSensors (void);
- /// programme d'homologation du robal
- void progHomoloRobal(void);
/// programme de match du robal
void progMatch(void);
+ void progHomoloRobal(void);
bool motorMove (int d, int a);
void motorRotate (double d);
- void motorBasicFindHole (void);
- int motorSmartFindHole (double distOut);
void motorDeblock(void);
};
#endif // ai_hh
diff --git a/i/chuck/src/ai/test_ai.cc b/i/chuck/src/ai/test_ai.cc
index 6a7d09f..661384f 100644
--- a/i/chuck/src/ai/test_ai.cc
+++ b/i/chuck/src/ai/test_ai.cc
@@ -57,32 +57,6 @@ class TestAi : public Tester
{
Interpreter &interpreter = getInterpreter();
// Add functions
- interpreter.add("init", Interpreter::memFunc(ai_, &Ai::init),
- "Initialise le robal(void)");
- interpreter.add("prepare", Interpreter::memFunc(ai_, &Ai::prepare),
- "Lance la procédure pré-Match");
- interpreter.add("afterMatch", Interpreter::memFunc(ai_,
- &Ai::afterMatch),
- "Lance la procédure post match");
- interpreter.add("stop", Interpreter::memFunc(ai_, &Ai::stop),
- "Stop le robal(void)");
- interpreter.add("tempo", Interpreter::memFunc(ai_,
- &Ai::temporisation),
- "On temporise(int msec)");
- interpreter.add("jack", Interpreter::memFunc(ai_, &Ai::waitJack),
- "On attend que le jack sorte/rentre(bool sorte)");
- interpreter.add("sensors", Interpreter::memFunc(ai_,
- &Ai::referenceSensors),
- "Initialise les capteurs RVB(void)");
- interpreter.add("homologation", Interpreter::memFunc(ai_,
- &Ai::progHomoloRobal),
- "Programme d'homologation du robal");
- interpreter.add("match", Interpreter::memFunc(ai_, &Ai::progMatch),
- "Programme de match qui déchire du robal");
- interpreter.add("findHoleBasic", Interpreter::memFunc(ai_, &Ai::motorBasicFindHole),
- "Find a hole, basic version");
- interpreter.add ("_postcall",
- Interpreter::memFunc (*this, &TestAi::postcall));
}
void postRun(void)
{
diff --git a/i/chuck/src/es/es.cc b/i/chuck/src/es/es.cc
index 12a6f3d..452e689 100644
--- a/i/chuck/src/es/es.cc
+++ b/i/chuck/src/es/es.cc
@@ -83,8 +83,6 @@ Es::reset (void)
setAckStat (ackFreq_);
setOthersStat (othersStat_);
lcdGetKey (lcdKeyStat_);
-
- enableAllSensors (true);
log_ ("Es", Log::debug) << "Reset Es done.";
}
@@ -124,16 +122,6 @@ Es::isColorModeBlue (void)
return colorModeBlue_;
}
-/// Enable all the sensors or just the 4 and 1 near the ground
-void
-Es::enableAllSensors (bool enable)
-{
- if (enable)
- proto_.send ('u', "b", 1);
- else
- proto_.send ('u', "b", 0);
-}
-
/// Set frequency of jack, selectoul printed out function
void
Es::setOthersStat (int freq)
@@ -141,11 +129,11 @@ Es::setOthersStat (int freq)
proto_.send ('O', "b", freq);
}
-// Discute avec les servo...
-void Es::setServoPos (int servo_mask, int servoPos)
-{
- proto_.send ('m', "bb", servo_mask, servoPos);
-}
+
+
+
+
+
/// Set update frequency of sharps
void
@@ -188,7 +176,7 @@ Es::lcdGetKey (int freq)
void Es::receive(char command, const Proto::Frame & frame)
{
- int errCode, red, blue, clear, green, compt, value;
+ int errCode, clear, compt, value;
int stat1, stat2, stat3, stat4;
switch (command)
@@ -242,6 +230,22 @@ void Es::receive(char command, const Proto::Frame & frame)
sharps_[compt] = value;
}
break;
+ }
+}
+
+//Activation du truk ki monte et descend.
+void
+Es::bouge_ascenceur(int sens,uint8_t vit,uint8_t tps)
+{
+ if (sens == UP)
+ {
+ proto_.send('a',"bbb",vit,tps,0x01);
+ }
+ if (sens == DOWN)
+ {
+ proto_.send('a',"bbb",vit,tps,0x00);
}
+ //faire un static pour savoir la dernière commande.
+ //permettra de faire l'inverse en automatique.
}
diff --git a/i/chuck/src/es/es.hh b/i/chuck/src/es/es.hh
index 1d5c13d..0de1264 100644
--- a/i/chuck/src/es/es.hh
+++ b/i/chuck/src/es/es.hh
@@ -36,8 +36,8 @@ class Config;
class Es : public Proto::Receiver
{
public:
- typedef std::vector<int> Sharps;
-
+ enum ascen{UP,DOWN};
+ typedef std::vector<int> Sharps;
private:
// Objet Proto de communication vers la carte es
Proto proto_;
@@ -93,14 +93,14 @@ class Es : public Proto::Receiver
/// Get the color mode of the button
bool isColorModeBlue (void);
- /// Enable all the sensors or just the 4 and 1 near the ground
- void enableAllSensors (bool enable);
+
+
/// Set frequency of jack, selectoul printed out function
/// Use this function with frequency 0 to disable this stat.
void setOthersStat (int freq);
- /// Discute avec les servo...
- void setServoPos (int servo_mask, int servoPos);
+
+
/// Set update frequency of sharps
void setSharpUpdate (int sharp_mask, int freq);
@@ -115,14 +115,13 @@ class Es : public Proto::Receiver
/// Get the current pressed keys of the LCD
void lcdGetKey (int freq);
- /// Front sensor
- bool frontSensor (void) { return front_sensor_; }
- /// Clear sensor
- void clearFrontSensor (void) { front_sensor_ = false; }
+
+
+
///Activé l'assenceur
- void bouge_ascenceur(int sensrot);
-
+ void bouge_ascenceur(int sens,uint8_t vit,uint8_t tps);
+ //a faire
private:
/// Update system for one sensor
void updateAnalysisSensor (int value, int index, int threshold);
diff --git a/i/chuck/src/es/test_es.cc b/i/chuck/src/es/test_es.cc
index 1e39167..b96baa5 100644
--- a/i/chuck/src/es/test_es.cc
+++ b/i/chuck/src/es/test_es.cc
@@ -64,15 +64,7 @@ class TestEs : public Tester
interpreter.add ("wait", Interpreter::memFunc (*this, &TestEs::wait),
"Blocking wait (time)\n"
" - time : time to wait in ms");
- interpreter.add
- ("colorRef", Interpreter::memFunc (es_, &Es::refColor),
- "Reference current color as green for sensors (mask)");
- interpreter.add
- ("rvbAll", Interpreter::memFunc (es_, &Es::enableAllSensors),
- "Drop a ball at the rear ()");
- interpreter.add
- ("servoPos", Interpreter::memFunc (es_, &Es::setServoPos),
- "Set servo position (mask, pos)");
+
interpreter.add
("sharpUp", Interpreter::memFunc (es_, &Es::setSharpUpdate),
"Set sharp update frequency (mask, freq)");
@@ -91,48 +83,9 @@ class TestEs : public Tester
interpreter.add
("lcdKey", Interpreter::memFunc (es_, &Es::lcdGetKey),
"Set stat for key if pressed (freq)");
- interpreter.add
- ("turbSpeed", Interpreter::memFunc (es_, &Es::setTurbineSpeed),
- "Set turbine speed (num, speed)\n"
- " - num : 1 front, 2 rear\n"
- " - speed : 256 - 819");
- interpreter.add
- ("turbMinSpeed", Interpreter::memFunc (es_,
- &Es::barilletDebutLancement),
- avant1 = 0x20, arriere3 = 0x24};
- "Turbine minimal speed ()");
- interpreter.add
- ("turbFrontFull", Interpreter::memFunc (es_,
- &Es::barilletLancement),
- "Turbine front full speed ()");
- interpreter.add
- ("barSleep", Interpreter::memFunc (es_, &Es::barilletSleep),
- "Barillet in sleep mode (low speed turbine)");
- interpreter.add
- ("turbDepose", Interpreter::memFunc (es_, &Es::deposeBalle),
- "Drop a ball at the rear ()");
- interpreter.add
- ("barDropWhite", Interpreter::memFunc (es_, &Es::dropWhiteBall),
- "drop une balle blanche");
- interpreter.add("barDropBlack", Interpreter::memFunc (es_,
- &Es::dropBlackBall),
- "drop une balle noire");
- interpreter.add("barSetEmpty", Interpreter::memFunc (es_,
- &Es::setEmptyHoleFront),
- "met un trou vide en position avale une balle");
- interpreter.add
- ("barExtract", Interpreter::memFunc (es_, &Es::extraitBalle),
- "Extract a ball ()");
- interpreter.add
- ("barInit", Interpreter::memFunc (es_, &Es::barilletInit),
- "Init barillet ()");
- interpreter.add
- ("barGoTo", Interpreter::memFunc (es_, &Es::rotationBarillet),
- "Barillet go to position (pos)\n"
- " - pos : in 40° of a round");
- interpreter.add
- ("barPurge", Interpreter::memFunc (es_, &Es::barilletEmpty),
- "Extract a ball ()");
+ interpreter.add ("ascenseur", Interpreter::memFunc(es_,
+ &Es::bouge_ascenceur),"Set sens , vitesse , tps\n" "sens : 0 UP 1 DOWN\n" "vit and tps : en hex");
+
interpreter.add ("_postcall",
Interpreter::memFunc (*this, &TestEs::postcall));
}
diff --git a/i/chuck/src/interpreter/interpreter.hh b/i/chuck/src/interpreter/interpreter.hh
index 60b57cd..3341ea1 100644
--- a/i/chuck/src/interpreter/interpreter.hh
+++ b/i/chuck/src/interpreter/interpreter.hh
@@ -1,5 +1,4 @@
-#
-fndef interpreter_hh
+#ifndef interpreter_hh
#define interpreter_hh
// interpreter.hh
// marvin - programme du robot 2006. {{{