summaryrefslogtreecommitdiff
path: root/2004
diff options
context:
space:
mode:
authorschodet2004-04-18 13:58:39 +0000
committerschodet2004-04-18 13:58:39 +0000
commit53b51044e8589a541ca79d7df35871ffbd18ad00 (patch)
treecfb256a718251307a3e0f08097fabe1a362df408 /2004
parent8ac39128a46989dee644df52230234021c044d4b (diff)
Nouveau système de Goto.
Diffstat (limited to '2004')
-rw-r--r--2004/i/nono/src/motor/Makefile.defs2
-rw-r--r--2004/i/nono/src/motor/goto.h40
-rw-r--r--2004/i/nono/src/motor/goto_simple.cc41
-rw-r--r--2004/i/nono/src/motor/goto_simple.h41
-rw-r--r--2004/i/nono/src/motor/movement_goto.cc17
-rw-r--r--2004/i/nono/src/motor/movement_goto.h8
-rw-r--r--2004/i/nono/src/motor/movement_types.h1
-rw-r--r--2004/i/nono/src/motor/test_motor.cc3
8 files changed, 145 insertions, 8 deletions
diff --git a/2004/i/nono/src/motor/Makefile.defs b/2004/i/nono/src/motor/Makefile.defs
index f709a54..a273875 100644
--- a/2004/i/nono/src/motor/Makefile.defs
+++ b/2004/i/nono/src/motor/Makefile.defs
@@ -7,7 +7,7 @@ test_asserv_SOURCES = test_asserv.cc motor.a serial.a erreur.a config.a \
test_tracker_SOURCES = test_tracker.cc motor.a serial.a erreur.a config.a \
date.a utils.a logger.a
motor_a_SOURCES = asserv.cc tracker.cc motor.cc movement_basic.cc \
- movement_goto.cc movement_rotation.cc
+ movement_goto.cc movement_rotation.cc goto_simple.cc
test_motor: $(test_motor_SOURCES:%.cc=%.o)
diff --git a/2004/i/nono/src/motor/goto.h b/2004/i/nono/src/motor/goto.h
new file mode 100644
index 0000000..7dad57a
--- /dev/null
+++ b/2004/i/nono/src/motor/goto.h
@@ -0,0 +1,40 @@
+#ifndef goto_h
+#define goto_h
+// goto.h
+// nono - programme du robot 2004. {{{
+//
+// Copyright (C) 2004 Nicolas Schodet
+//
+// Robot APB Team/Efrei 2004.
+// Web: http://assos.efrei.fr/robot/
+// Email: robot AT efrei DOT fr
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+// }}}
+#include "tracker.h"
+
+/// Classe abstraite d'un fournisseur de point pour MovementGoto.
+class Goto
+{
+ public:
+ /// Destructeur.
+ virtual ~Goto (void) { }
+ /// Fournit le point le plus loin à moins de dist (mm).
+ virtual void get (const Tracker &t, double &dx, double &dy, double dist) =
+ 0;
+};
+
+#endif // goto_h
diff --git a/2004/i/nono/src/motor/goto_simple.cc b/2004/i/nono/src/motor/goto_simple.cc
new file mode 100644
index 0000000..1514800
--- /dev/null
+++ b/2004/i/nono/src/motor/goto_simple.cc
@@ -0,0 +1,41 @@
+// goto_simple.cc
+// nono - programme du robot 2004. {{{
+//
+// Copyright (C) 2004 Nicolas Schodet
+//
+// Robot APB Team/Efrei 2004.
+// Web: http://assos.efrei.fr/robot/
+// Email: robot AT efrei DOT fr
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+// }}}
+#include "goto_simple.h"
+
+/// Constructeur.
+/// (dx, dy) : position d'arrivée (mm).
+GotoSimple::GotoSimple (double dx, double dy)
+ : dx_ (dx), dy_ (dy)
+{
+}
+
+/// Fournit le point le plus loin à moins de dist (mm).
+void
+GotoSimple::get (const Tracker &t, double &dx, double &dy, double dist)
+{
+ dx = dx_;
+ dy = dy_;
+}
+
diff --git a/2004/i/nono/src/motor/goto_simple.h b/2004/i/nono/src/motor/goto_simple.h
new file mode 100644
index 0000000..7401c22
--- /dev/null
+++ b/2004/i/nono/src/motor/goto_simple.h
@@ -0,0 +1,41 @@
+#ifndef goto_simple_h
+#define goto_simple_h
+// goto_simple.h
+// nono - programme du robot 2004. {{{
+//
+// Copyright (C) 2004 Nicolas Schodet
+//
+// Robot APB Team/Efrei 2004.
+// Web: http://assos.efrei.fr/robot/
+// Email: robot AT efrei DOT fr
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+// }}}
+#include "goto.h"
+
+/// Classe abstraite d'un fournisseur de point pour MovementGoto.
+class GotoSimple : public Goto
+{
+ double dx_, dy_;
+ public:
+ /// Constructeur.
+ /// (dx, dy) : position d'arrivée (mm).
+ GotoSimple (double dx, double dy);
+ /// Fournit le point le plus loin à moins de dist (mm).
+ void get (const Tracker &t, double &dx, double &dy, double dist);
+};
+
+#endif // goto_simple_h
diff --git a/2004/i/nono/src/motor/movement_goto.cc b/2004/i/nono/src/motor/movement_goto.cc
index 78ae491..e83b8ec 100644
--- a/2004/i/nono/src/motor/movement_goto.cc
+++ b/2004/i/nono/src/motor/movement_goto.cc
@@ -55,20 +55,29 @@ MovementGotoParam::MovementGotoParam (void)
}
/// Constructeur.
-/// (x, y) : position d'arrivée (mm).
-MovementGoto::MovementGoto (double x, double y)
- : dX_ (x), dY_ (y),
+/// go : objet Goto, detruit dans le destructeur.
+MovementGoto::MovementGoto (Goto *go)
+ : goto_ (go),
il_ (0.0), ia_ (0.0), lel_ (0.0), lea_ (0.0)
{
}
+/// Destructeur.
+MovementGoto::~MovementGoto (void)
+{
+ delete goto_;
+}
+
/// Controlle la vitesse, retourne faux si mouvement terminé.
bool
MovementGoto::control (void)
{
+ double dx, dy;
+ // Récupère le prochain point.
+ goto_->get (*t_, dx, dy, param_.dist_);
// Calcule l'erreur.
double el, ea;
- if (!t_->computeError (dX_, dY_, el, ea, param_.eps_, param_.dist_))
+ if (!t_->computeError (dx, dy, el, ea, param_.eps_, param_.dist_))
{
return false;
}
diff --git a/2004/i/nono/src/motor/movement_goto.h b/2004/i/nono/src/motor/movement_goto.h
index 375946f..95dde47 100644
--- a/2004/i/nono/src/motor/movement_goto.h
+++ b/2004/i/nono/src/motor/movement_goto.h
@@ -25,6 +25,7 @@
//
// }}}
#include "movement.h"
+#include "goto.h"
/// Paramètres d'un mouvement Goto.
class MovementGotoParam
@@ -51,6 +52,7 @@ class MovementGotoParam
/// direction finale.
class MovementGoto : public Movement
{
+ Goto *goto_;
/// Position d'arrivée.
double dX_, dY_;
/// Integrales.
@@ -61,8 +63,10 @@ class MovementGoto : public Movement
static MovementGotoParam param_;
public:
/// Constructeur.
- /// (x, y) : position d'arrivée (mm).
- MovementGoto (double x, double y);
+ /// go : objet Goto, detruit dans le destructeur.
+ MovementGoto (Goto *go);
+ /// Destructeur.
+ ~MovementGoto (void);
/// Controlle la vitesse, retourne faux si mouvement terminé.
bool control (void);
};
diff --git a/2004/i/nono/src/motor/movement_types.h b/2004/i/nono/src/motor/movement_types.h
index 4a5e2d4..66ad1d0 100644
--- a/2004/i/nono/src/motor/movement_types.h
+++ b/2004/i/nono/src/motor/movement_types.h
@@ -27,5 +27,6 @@
#include "movement_basic.h"
#include "movement_goto.h"
#include "movement_rotation.h"
+#include "goto_simple.h"
#endif // movement_types_h
diff --git a/2004/i/nono/src/motor/test_motor.cc b/2004/i/nono/src/motor/test_motor.cc
index 5ad15a2..27d4e68 100644
--- a/2004/i/nono/src/motor/test_motor.cc
+++ b/2004/i/nono/src/motor/test_motor.cc
@@ -99,7 +99,8 @@ main (int argc, char **argv)
if (i >= argc) break;
dY = atof (argv[i++]);
cout << "goto " << dX << ' ' << dY << endl;
- Movement *mov = new MovementGoto (dX, dY);
+ Goto *g = new GotoSimple (dX, dY);
+ Movement *mov = new MovementGoto (g);
m.setMovement (mov);
}
break;