summaryrefslogtreecommitdiff
path: root/2004/i/nono/src/motor/motor.h
diff options
context:
space:
mode:
Diffstat (limited to '2004/i/nono/src/motor/motor.h')
-rw-r--r--2004/i/nono/src/motor/motor.h80
1 files changed, 80 insertions, 0 deletions
diff --git a/2004/i/nono/src/motor/motor.h b/2004/i/nono/src/motor/motor.h
new file mode 100644
index 0000000..ddc32ee
--- /dev/null
+++ b/2004/i/nono/src/motor/motor.h
@@ -0,0 +1,80 @@
+#ifndef motor_h
+#define motor_h
+// motor.h
+// nono - programme du robot 2004. {{{
+//
+// Copyright (C) 2003 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 "asserv.h"
+#include "tracker.h"
+#include "movement.h"
+
+class Motor : public AsservTracker
+{
+ // Object d'asservissement.
+ Asserv asserv_;
+ // Suiveur de position.
+ Tracker tracker_;
+ // Pointeur vers l'instance unique.
+ static Motor *instance_;
+ // Echelles (mm/unit, mm/s.unit, mm/s^2.unit).
+ double s_, vs_, as_;
+ // Mouvement en cours.
+ Movement *movement_;
+ // Vitesses maximale et minimale (unit).
+ int maxSpeed_, minSpeed_;
+ public:
+ // Constructeur.
+ Motor (void);
+ // Destructeur.
+ virtual ~Motor (void);
+ // Récupère l'instance unique.
+ static Motor &getInstance (void) { return *instance_; }
+ // Appelée lors d'une mise à jour des compteurs.
+ void updateCounter (int l, int r);
+ // Choisi le mouvement en cours.
+ void setMovement (Movement *m);
+ // Active l'asservissement.
+ void go (bool fl = true) { asserv_.go (fl); }
+ // Teste si l'émission est terminée.
+ bool ok (void) { return asserv_.ok (); }
+ // Attend que toute les émissions soit terminées.
+ void waitOk (void) { asserv_.waitOk (); }
+ // Teste si les mouvements sont terminés.
+ bool end (void);
+ // Attend la fin de tout les mouvements.
+ void waitEnd (void);
+ // Teste si les moteurs sont arrétés.
+ bool stopped (void);
+ // Attend que les moteurs soient arrétés.
+ void waitStopped (void);
+ // Récupère l'object tracker.
+ const Tracker &getTracker (void) const { return tracker_; }
+ // Paramètre la vitesse des moteurs.
+ void speed (double l, double r);
+ // Va vers un point, renvois faux si atteind.
+ bool goTo (double x, double y, double eps = 5.0);
+ // Va vers un point, en formant un arc de cercle, renvois faux si atteind.
+ bool goToArc (double x, double y, double eps = 5.0);
+};
+
+#endif // motor_h