summaryrefslogtreecommitdiff
path: root/2003/i/buzz/src/ia
diff options
context:
space:
mode:
Diffstat (limited to '2003/i/buzz/src/ia')
-rw-r--r--2003/i/buzz/src/ia/Makefile.defs8
-rw-r--r--2003/i/buzz/src/ia/ia.cc72
-rw-r--r--2003/i/buzz/src/ia/ia.h55
3 files changed, 135 insertions, 0 deletions
diff --git a/2003/i/buzz/src/ia/Makefile.defs b/2003/i/buzz/src/ia/Makefile.defs
new file mode 100644
index 0000000..19ac605
--- /dev/null
+++ b/2003/i/buzz/src/ia/Makefile.defs
@@ -0,0 +1,8 @@
+LIBS += ia.a
+TARGETS += buzz
+ia_a_SOURCES = ia.cc
+buzz_SOURCES = buzz.cc ia.a motor.a automate.a busp.a erreur.a config.a
+
+buzz: $(buzz_SOURCES:%.cc=%.o)
+
+ia.a: ${ia_a_SOURCES:%.cc=ia.a(%.o)}
diff --git a/2003/i/buzz/src/ia/ia.cc b/2003/i/buzz/src/ia/ia.cc
new file mode 100644
index 0000000..14f47a2
--- /dev/null
+++ b/2003/i/buzz/src/ia/ia.cc
@@ -0,0 +1,72 @@
+// ia.cc
+// buzz - Programme du robot Efrei Robotique I1-I2 2003
+// Copyright (C) 2003 Nicolas Schodet
+//
+#include "ia.h"
+
+// Instance unique.
+Ia *Ia::m_instance = 0;
+
+// Constructeur.
+Ia (const char *strat)
+{
+ // Instancie les objets du robot.
+ m_thresholds = new Thresholds ("rc/vision/palets.rgb");
+ m_camera = new Camera ();
+ m_image = new Image (c, t);
+ m_grafcet = new Grafcet (strat);
+ // Init.
+ m_instance = this;
+ m_paletFound = false;
+ for (int i = 0; i < 8; ++i)
+ {
+ m_var[i] = 0;
+ m_tempo[i] = 0;
+ }
+}
+
+// Destructeur.
+~Ia (void)
+{
+ m_instance = 0;
+ delete m_grafcet;
+ delete m_image;
+ delete m_camera;
+ delete m_thresholds;
+}
+
+// Cherche un palet.
+bool
+Ia::seekPalet (void)
+{
+ i->reread ();
+}
+
+// Va vers le palet précédement trouvé.
+void
+Ia::goPalet (void)
+{
+}
+
+// Variable de l'ia.
+int getVar (int var)
+{
+ return m_var[var];
+}
+
+void setVar (int var, int val)
+{
+ m_var[var] = val;
+}
+
+// Tempos de l'ia.
+void resetTempo (int tempo)
+{
+ m_tempo[tempo] = m_date.start ();
+}
+
+int getTempo (int tempo)
+{
+ return m_date.start () - m_tempo[tempo];
+}
+
diff --git a/2003/i/buzz/src/ia/ia.h b/2003/i/buzz/src/ia/ia.h
new file mode 100644
index 0000000..5ca9092
--- /dev/null
+++ b/2003/i/buzz/src/ia/ia.h
@@ -0,0 +1,55 @@
+#ifndef ia_h
+#define ia_h
+// ia.h
+// buzz - Programme du robot Efrei Robotique I1-I2 2003
+// Copyright (C) 2003 Nicolas Schodet
+#include "date/date.h"
+#include "automate/grafcet.h"
+#include "busp/busp.h"
+#include "camera/camera.h"
+#include "date/date.h"
+#include "motor/motor.h"
+#include "vision/image.h"
+#include "vision/thresholds.h"
+
+class Ia
+{
+ // Objets du robot.
+ Date m_date;
+ Busp m_busp;
+ Motor m_motor;
+ Image *m_image;
+ Thresholds *m_thresholds;
+ Camera *m_camera;
+ Grafcet *m_grafcet;
+ // Logique de recherche de palet.
+ bool m_paletFound;
+ double m_paletAngle, m_paletDistance;
+ // Instance unique.
+ static Ia *m_instance;
+ // Variables de l'ia.
+ int m_var[8];
+ // Tempos de l'ia.
+ int m_tempo[8];
+ public:
+ // Constructeur.
+ Ia (const char *strat);
+ // Destructeur.
+ ~Ia (void);
+ // Renvoie une référence vers l'instance unique.
+ Ia &getInstance (void) { return *m_instance; }
+ // Cherche un palet.
+ bool seekPalet (void);
+ // A-t-on trouvé un palet.
+ bool paletFound (void) { return m_paletFound; }
+ // Va vers le palet précédement trouvé.
+ void goPalet (void);
+ // Variable de l'ia.
+ int getVar (int var);
+ void setVar (int var, int val);
+ // Tempos de l'ia.
+ void resetTempo (int tempo);
+ int getTempo (int tempo);
+};
+
+#endif // ia_h