summaryrefslogtreecommitdiff
path: root/2004/i/nono/src/motor/motor.h
blob: ddc32ee3bc08bf23c80861200493b601742a2527 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
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