summaryrefslogtreecommitdiff
path: root/2005/i/robert/src
diff options
context:
space:
mode:
Diffstat (limited to '2005/i/robert/src')
-rw-r--r--2005/i/robert/src/ai/Makefile.defs6
-rw-r--r--2005/i/robert/src/ai/ai.cc48
-rw-r--r--2005/i/robert/src/ai/ai.hh8
-rw-r--r--2005/i/robert/src/ai/test_ai.cc63
4 files changed, 70 insertions, 55 deletions
diff --git a/2005/i/robert/src/ai/Makefile.defs b/2005/i/robert/src/ai/Makefile.defs
index f150cac..581568d 100644
--- a/2005/i/robert/src/ai/Makefile.defs
+++ b/2005/i/robert/src/ai/Makefile.defs
@@ -2,6 +2,10 @@ PROGRAMS += test_ai
ai_OBJECTS = ai.o
-test_ai_OBJECTS = test_ai.o $(ai_OBJECTS) $(motor_OBJECTS)
+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)
test_ai: $(test_ai_OBJECTS)
diff --git a/2005/i/robert/src/ai/ai.cc b/2005/i/robert/src/ai/ai.cc
index cdb9d4c..12e8f88 100644
--- a/2005/i/robert/src/ai/ai.cc
+++ b/2005/i/robert/src/ai/ai.cc
@@ -23,7 +23,10 @@
//
// }}}
-#include"ai.hh"
+#include "ai.hh"
+#include "config/config.hh"
+#include "timer/timer.hh"
+#include "ovision/see/ovision.hh"
static void
callback (void)
@@ -33,10 +36,10 @@ callback (void)
/// Constructeur
Ai::Ai(const Config & config)
:motor_(config), es_(config),
- roundDuration_(config.get<int>("ai.roundDuration")),
- vitesseAsc_(config.set<int>("ai.vitesseAsc")),
schedulableMotor_ (callback, motor_.getFd ()),
- schedulableEs_ (callback, es_.getFd ())
+ schedulableEs_ (callback, es_.getFd ()),
+ roundDuration_(config.get<int>("ai.roundDuration")),
+ vitesseAsc_(config.get<int>("ai.vitesseAsc"))
{
scheduler_.insert (schedulableMotor_);
scheduler_.insert (schedulableEs_);
@@ -50,8 +53,8 @@ void Ai::init(void)
// initialise la carte es
es_.init();
// on init la vision
- ovision_.init(es_.getColor() ? Group::ZoneType::RedSkittle :
- Group::ZoneType::GreenColor);
+ oVision_.init(motor_.colorState() ? Group::redSkittle :
+ Group::greenSkittle);
}
/// stop le robot
@@ -75,16 +78,16 @@ void Ai::run(void)
// Attend la seconde sortie du jack(Daniel)
waitJack(true);
// on lance le temps
- Timer::start_round();
+ Timer::startRound();
// Aller devant la boule
- goTo(x, y, 0);
+ goTo(10, 10, 0); // XXX Mauvaise valeur, changer valeur
// Taper la boule
- basic(d);
+ basic(1245665486); // XXX Mauvaise valeur, changer valeur
// se placer devant nos quilles près du pont
- basic(-d);
+ basic(5568786); // XXX Mauvaise valeur, changer valeur
rotation(-M_PI / 2);
- goTo(x,y, M_PI);
- basic(-d);
+ goTo(4546,42424242, M_PI); // XXX Mauvaise valeur, changer valeur
+ basic(56465456); // XXX Mauvaise valeur, changer valeur
// Après attendre... XXX Ou voir un truc qui bouge
// Un truc
// Detecter les quilles tombées (voir si se déplacer proches du rb adverses serait utiles)
@@ -94,10 +97,15 @@ void Ai::run(void)
// redetecter le tout
}
+/// Attend.
+void Ai::wait (int t)
+{
+}
+
// Attend le jack entré (false) ou sorti (true).
void Ai::waitJack (bool out)
{
- while (es_.stateJack() != out)
+ while (motor_.jackState() != out)
update();
}
@@ -115,11 +123,6 @@ void Ai::goTo (double x, double y ,double a)
// XXX Voir ca plus précisemment
void Ai::recale (void)
{
- while(!es_.capteursContact())
- {
- motor_.recalage();
- update();
- }
}
/// Mouvement basic.
@@ -146,9 +149,9 @@ void Ai::rotation (double a)
/// Monte(vrai) ou descend(faux) l'ascenceur
void Ai::ascenceur (bool monte)
{
- while(es_.stateAsc() != monte ? true : false)
+ while(es_.getAscCurPos() != monte ? true : false)
{
- es_.moveAsc(monte);
+ //es_.moveAsc(monte);
// XXX On peut régler la vitesse de l'asc( config min max acc haut et bas entier unité ons'entape)
update();
}
@@ -158,7 +161,8 @@ void Ai::ascenceur (bool monte)
void Ai::ventouses (void) /// XXX Temps à régler dans la config
{
es_.ventouses();
- while(!es_.stateVentouses()) // XXX Ca, ca doit servir à rien
- update();
}
+void Ai::update (void)
+{
+}
diff --git a/2005/i/robert/src/ai/ai.hh b/2005/i/robert/src/ai/ai.hh
index a349ca4..187fdb6 100644
--- a/2005/i/robert/src/ai/ai.hh
+++ b/2005/i/robert/src/ai/ai.hh
@@ -28,7 +28,10 @@
#include "motor/motor.hh"
#include "es/es.hh"
#include "scheduler/scheduler.hh"
-#include "config/config.hh"
+#include "scheduler/schedulable_read_fd.hh"
+#include "ovision/see/ovision.hh"
+
+class Config;
/// Intelligence (encore plus heu...) artificielle
class Ai
@@ -37,7 +40,7 @@ class Ai
// Modules de controle du robot
Motor motor_;
Es es_;
- ovision_ ov_;
+ OVision oVision_;
// Scheduler du robot
scheduler::Scheduler scheduler_;
scheduler::SchedulableReadFd schedulableMotor_;
@@ -55,7 +58,6 @@ class Ai
void stop (void);
/// Lance le robot.
void run (void);
- /// Lance le robot.
/// Attend.
void wait (int t);
// Attend le jack entré (false) ou sorti (true).
diff --git a/2005/i/robert/src/ai/test_ai.cc b/2005/i/robert/src/ai/test_ai.cc
index 91077c0..c71c09b 100644
--- a/2005/i/robert/src/ai/test_ai.cc
+++ b/2005/i/robert/src/ai/test_ai.cc
@@ -26,6 +26,11 @@
// }}}
/// Affiche un memo de suntaxe.
+
+#include <iostream>
+#include "ai/ai.hh"
+#include "timer/timer.hh"
+
void
syntax (void)
{
@@ -49,7 +54,7 @@ main (int argc, char **argv)
return 1;
}
Config config(argc, argv);
- Ai ai(config);
+ Ai ai_(config);
i = 1;
while (i < argc)
{
@@ -60,13 +65,13 @@ main (int argc, char **argv)
switch(argv[++i][0])
{
case 'i':
- ai.init();
+ ai_.init();
break;
case 's':
- ai.stop();
+ ai_.stop();
break;
case 'r':
- ai.run();
+ ai_.run();
break;
case 'j':
if(++i > argc)
@@ -74,56 +79,56 @@ main (int argc, char **argv)
if(argv[i][0] == 0)
{
std::cout << "Attente de l'entrée de Jack" << std::endl;
- ai.waitJack(false);
+ ai_.waitJack(false);
}
else
{
- std::cout << "Attente de la sortie de Jack" << std:endl;
- ai.waitJack(true);
+ std::cout << "Attente de la sortie de Jack" << std::endl;
+ ai_.waitJack(true);
}
break;
case 'g':
if(++i + 2 > argc)
throw std::runtime_error("syntax error");
- ai.goTo(strtod(argv[i], 0),
+ ai_.goTo(strtod(argv[i], 0),
strtod(argv[i + 1], 0),
strtod(argv[i + 2], 0));
i += 2;
break;
- case 'r':
- ai.recale();
+ case 'R':
+ ai_.recale();
break;
case 'b':
if(++i > argc)
throw std::runtime_error("syntax error");
- ai.basic(strtod(argv[i]));
+ ai_.basic(strtod(argv[i], 0));
break;
- case 'r':
+ case 'a':
if(++i > argc)
throw std::runtime_error("syntax error");
- ai.rotation(strtod(argv[i]));
+ ai_.rotation(strtod(argv[i], 0));
break;
- case 'a':
+ case 'A':
if(++i + 1 > argc)
throw std::runtime_error("syntax error");
- switch(argv[i])
- {
- case '0':
- ai.moveAsc(BAS);
- break;
- case '1':
- ai.moveAsc(MILIEU);
- break;
- case '2':
- ai.moveAsc(HAUT);
- break;
- }
+// switch(argv[i])
+// {
+// case '0':
+// ai.moveAsc(BAS);
+// break;
+// case '1':
+// ai.moveAsc(MILIEU);
+// break;
+// case '2':
+// ai.moveAsc(HAUT);
+// break;
+// }
break;
case 'v':
- ai.ventouses();
+ ai_.ventouses();
break;
case 'U':
- ai.update();
+ ai_.update();
break;
}
break;
@@ -137,7 +142,7 @@ main (int argc, char **argv)
t = Timer::getProgramTime ();
while (t < stop)
{
- asserv.wait (stop - t);
+ ai_.wait (stop - t);
t = Timer::getProgramTime ();
}
break;