summaryrefslogtreecommitdiff
path: root/i/marvin
diff options
context:
space:
mode:
Diffstat (limited to 'i/marvin')
-rw-r--r--i/marvin/src/Makefile.defs2
-rw-r--r--i/marvin/src/ai/Makefile.defs5
-rw-r--r--i/marvin/src/ai/ai.cc21
-rw-r--r--i/marvin/src/ai/ai.hh2
-rw-r--r--i/marvin/src/ai/test_ai.cc42
-rw-r--r--i/marvin/src/motor/motor.cc7
-rw-r--r--i/marvin/src/motor/motor.hh2
7 files changed, 71 insertions, 10 deletions
diff --git a/i/marvin/src/Makefile.defs b/i/marvin/src/Makefile.defs
index 077f133..aa882b7 100644
--- a/i/marvin/src/Makefile.defs
+++ b/i/marvin/src/Makefile.defs
@@ -25,7 +25,7 @@ SUBDIRS = utils utils/meta \
log serial timer \
data scheduler \
proto asserv es \
- motor socket
+ motor socket ai
# Répertoire où placer les objets.
OBJ_DIR := obj
diff --git a/i/marvin/src/ai/Makefile.defs b/i/marvin/src/ai/Makefile.defs
new file mode 100644
index 0000000..5016f06
--- /dev/null
+++ b/i/marvin/src/ai/Makefile.defs
@@ -0,0 +1,5 @@
+PROGRAMS += test_ai
+
+ai_OBJECTS = ai.o $(motor_OBJECTS) $(es_OBJECTS) $(scheduler_OBJECTS)
+
+test_ai_OBJECTS = test_ai.o $(ai_OBJECTS) $(tester_OBJECTS)
diff --git a/i/marvin/src/ai/ai.cc b/i/marvin/src/ai/ai.cc
index 1adcf5e..bbf3158 100644
--- a/i/marvin/src/ai/ai.cc
+++ b/i/marvin/src/ai/ai.cc
@@ -22,10 +22,17 @@
// Email: <nicolas@boiteameuh.org>
// }}}
#include "ai.hh"
+#include "config/config.hh"
+#include "timer/timer.hh"
+
+/// Fonction callback useless
+static void
+callback (void)
+{}
//constructeur
Ai::Ai (const Config & config)
- : motor_(config), es_(config), log_ ("Ai"),
+ :es_(config), log_ ("Ai"),
schedulableMotor_(callback, motor_.getFd()),
schedulableEs_(callback, es_.getFd()),
round_duration_ (config.get<int> ("ai.round_duration")),
@@ -114,7 +121,7 @@ Ai::waitJack (bool out)
{
do
{
- udpate ();
+ update ();
}
while (es_.isJackOut () != out);
}
@@ -156,21 +163,21 @@ void Ai::progHomoloRobal(void)
/// PAF BEGIN!!! (lancer le timer)
Timer::startRound();
/// on avance un poil parce que le mur c'est mal
- move(400, 0);
+ motor_.move(400, 0);
/// On tourne XXX
- rotate(-M_PI/4);
+ motor_.rotate(-M_PI/4);
/// On cherche au moins une balle (sinon c'est con)
- barilletLancement();
+ es_.barilletLancement();
/// XXX Avancer d'une certaine facon pour choper des balles
/// XXX Ouais ba y'a encore ddes truc à faire là
/// On cherche un tru (repositionnement??)
- motor_.lockGoodHole();
+ // XXX motor_.lockGoodHole();
motor_.findHole();
/// On trouve un trou, chouette
/// Aspirer le trou
es_.extraitBalle();
/// mettre une baballe
- es_.deposeBlanche();
+ // XXX es_.deposeBlanche();
/// Tourner 3 fois en chantant du Mickael Jackson
/// Again....
/// Fin du match
diff --git a/i/marvin/src/ai/ai.hh b/i/marvin/src/ai/ai.hh
index 25bba63..8d673e5 100644
--- a/i/marvin/src/ai/ai.hh
+++ b/i/marvin/src/ai/ai.hh
@@ -66,8 +66,6 @@ class Ai
bool update (void);
/// La célèbre fonction sync
bool sync (void);
- /// Stop the mouvement of the motor
- void stop (void);
/// Init things for a match.
void prepare (void);
/// Reference sensors
diff --git a/i/marvin/src/ai/test_ai.cc b/i/marvin/src/ai/test_ai.cc
index 9412277..b4f3882 100644
--- a/i/marvin/src/ai/test_ai.cc
+++ b/i/marvin/src/ai/test_ai.cc
@@ -35,4 +35,46 @@ class TestAI : public Tester
{
// Update ?
}
+ public:
+ TestAI(int argc, char ** argv)
+ :Tester(argc, argv), ai_(config_)
+ {}
+ void preRun (void)
+ {
+ Interpreter &interpreter = getInterpreter();
+ // Add functions
+ interpreter.add("init", Interpreter::memFunc(ai_, &Ai::init),
+ "Initialise le robal(void)");
+ 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");
+ }
+ void postRun(void)
+ {
+ // On init le robal histoire de ...
+ ai_.init();
+ }
+};
+
+int main (int argc, char **argv)
+{
+ try
+ {
+ TestAI ta(argc, argv);
+ ta.run ();
+ }
+ catch (const std::exception &e)
+ {
+ std::cerr << e.what () << std::endl;
+ }
}
diff --git a/i/marvin/src/motor/motor.cc b/i/marvin/src/motor/motor.cc
index 2664df0..5f3987a 100644
--- a/i/marvin/src/motor/motor.cc
+++ b/i/marvin/src/motor/motor.cc
@@ -74,6 +74,13 @@ Motor::stop (void)
asserv_.speed (0, 0);
}
+/// get the file descriptor
+int
+Motor::getFd(void)
+{
+ return asserv_.getFd();
+}
+
/// Next seq number.
void
Motor::nextSeq (void)
diff --git a/i/marvin/src/motor/motor.hh b/i/marvin/src/motor/motor.hh
index 5770ebb..7cc7e78 100644
--- a/i/marvin/src/motor/motor.hh
+++ b/i/marvin/src/motor/motor.hh
@@ -54,6 +54,8 @@ class Motor : public Asserv::Receiver
void findHole (void);
/// Stop now.
void stop (void);
+ /// get the file descriptor
+ int getFd(void);
/// Reset.
void reset (void);
private: