summaryrefslogtreecommitdiff
path: root/2005/i/robert/src/ai
diff options
context:
space:
mode:
Diffstat (limited to '2005/i/robert/src/ai')
-rw-r--r--2005/i/robert/src/ai/Makefile.defs4
-rw-r--r--2005/i/robert/src/ai/ai.cc65
-rw-r--r--2005/i/robert/src/ai/ai.hh3
-rw-r--r--2005/i/robert/src/ai/test_ai.cc4
4 files changed, 69 insertions, 7 deletions
diff --git a/2005/i/robert/src/ai/Makefile.defs b/2005/i/robert/src/ai/Makefile.defs
index 581568d..4eaade9 100644
--- a/2005/i/robert/src/ai/Makefile.defs
+++ b/2005/i/robert/src/ai/Makefile.defs
@@ -4,8 +4,6 @@ ai_OBJECTS = ai.o
test_ai_OBJECTS = test_ai.o $(ai_OBJECTS) $(motor_OBJECTS) $(log_OBJECTS) \
$(asserv_OBJECTS) $(proto_OBJECTS) $(utils_OBJECTS) $(serial_OBJECTS) \
-$(timer_OBJECTS) $(config_OBJECTS) $(scheduler_OBJECTS) $(es_OBJECTS) \
-$(ovision_OBJECTS) $(image_OBJECTS) $(video4linux_OBJECTS) $(net_OBJECTS) \
-$(data_OBJECTS)
+$(timer_OBJECTS) $(config_OBJECTS) $(scheduler_OBJECTS) $(es_OBJECTS)
test_ai: $(test_ai_OBJECTS)
diff --git a/2005/i/robert/src/ai/ai.cc b/2005/i/robert/src/ai/ai.cc
index 847fe76..096f529 100644
--- a/2005/i/robert/src/ai/ai.cc
+++ b/2005/i/robert/src/ai/ai.cc
@@ -149,6 +149,50 @@ Ai::initBalNonFiable (void)
protectQuillePont ();
}
+
+// test
+void
+Ai::initTest (void)
+{
+ init();
+ std::cout << "Le jack est en attente" << std::endl;
+ waitJack(false);
+ std::cout << "Le jack est entré" << std::endl;
+ // Reset la PWM à zéro si on a fait de la merde en le posant sur la table
+ resetPwm ();
+ // Attend la première sortie du jack(init)
+ waitJack(true);
+ std::cout << "Le jack est sorti" << std::endl;
+
+ //début des tests
+ std::cout << "VItesse default" << std::endl;
+ basic(200);
+ basic(200);
+
+ setMaxSpeed(8,-1);
+ std::cout << "VItesse à 8" << std::endl;
+ basic(-200);
+ std::cout << "Re 200" << std::endl;
+ basic(200);
+ std::cout << "Av 200" << std::endl;
+
+ setMaxSpeed(4,-1);
+ std::cout << "VItesse à 4" << std::endl;
+ basic(-200);
+ std::cout << "Re 200" << std::endl;
+ basic(200);
+ std::cout << "Av 200" << std::endl;
+
+ setMaxSpeed(2,-1);
+ std::cout << "VItesse à 2" << std::endl;
+ basic(-200);
+ std::cout << "Re 200" << std::endl;
+ basic(200);
+ std::cout << "Av 200" << std::endl;
+}
+
+
+
// Balistique fiable.
void
Ai::initBalFiable (void)
@@ -170,14 +214,17 @@ Ai::protectQuillePont (void)
std::cout << "GoTo 870,-675 -> Pi" << std::endl;
goTo(1225, -1125, M_PI);
// On change la vitesse max pour reculer
- motor_.setMaxSpeed (128, -1);
+ std::cout << "On change la vitesse à 2" << std::endl;
+ motor_.setMaxSpeed (2, -1);
// Taper la boule
std::cout << "On recule lentement de 200mm" << std::endl;
basic(-200);
// On restaure la vitesse
- motor_.setMaxSpeed (64, -1);
+ std::cout << "On restaure la vitesse à 8" << std::endl;
+ motor_.setMaxSpeed (8, -1);
// On attend un peu pour protéger
- temporisation (15000); // XXX A changer
+ std::cout << "On temporise" << std::endl;
+ temporisation (1500); // 15000 XXX A changer
// XXX à finir
// On se barre des quilles
basic (200);
@@ -326,6 +373,8 @@ void Ai::resetPwm (void)
motor_.setPwm (0, 0);
// synchronise
update();
+ // XXX
+ update();
}
/// Initialise le robot pour faire un match (placement).
@@ -372,5 +421,13 @@ void Ai::initMatch (void)
Timer::startRound();
// On temporise pour laisser Taz sortir
std::cout << "Attente du 15 secondes" << std::endl;
- temporisation(15000);
+ //temporisation(15000);
+}
+
+void
+Ai::setMaxSpeed (int l, int r)
+{
+ motor_.setMaxSpeed (l, r);
+ update ();
}
+
diff --git a/2005/i/robert/src/ai/ai.hh b/2005/i/robert/src/ai/ai.hh
index a4f6719..f39993a 100644
--- a/2005/i/robert/src/ai/ai.hh
+++ b/2005/i/robert/src/ai/ai.hh
@@ -91,6 +91,9 @@ class Ai
void initBalFiable (void);
// Va du point de départ au pont pour protéger les quilles.
void protectQuillePont (void);
+ // test
+ void initTest (void);
+ void setMaxSpeed (int l, int r);
};
#endif // ai_hh
diff --git a/2005/i/robert/src/ai/test_ai.cc b/2005/i/robert/src/ai/test_ai.cc
index 835ee8d..da34917 100644
--- a/2005/i/robert/src/ai/test_ai.cc
+++ b/2005/i/robert/src/ai/test_ai.cc
@@ -85,6 +85,10 @@ main (int argc, char **argv)
{
ai_.initBalFiable ();
}
+ if (argv[i][0] == '2')
+ {
+ ai_.initTest ();
+ }
break;
case 'j':
if(++i > argc)