summaryrefslogtreecommitdiff
path: root/i/chuck/src/motor/motor.hh
diff options
context:
space:
mode:
Diffstat (limited to 'i/chuck/src/motor/motor.hh')
-rw-r--r--i/chuck/src/motor/motor.hh86
1 files changed, 86 insertions, 0 deletions
diff --git a/i/chuck/src/motor/motor.hh b/i/chuck/src/motor/motor.hh
new file mode 100644
index 0000000..548c7bd
--- /dev/null
+++ b/i/chuck/src/motor/motor.hh
@@ -0,0 +1,86 @@
+#ifndef motor_hh
+#define motor_hh
+// motor.hh
+// marvin - programme du robot 2006. {{{
+//
+// Copyright (C) 2006 Nicolas Schodet
+//
+// Robot APB Team/Efrei 2005.
+// 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/asserv.hh"
+#include "log/log.hh"
+
+/// Handle movements.
+class Motor : public Asserv::Receiver
+{
+ private:
+ Asserv asserv_;
+ int seq_;
+ bool finish_;
+ bool blocked_;
+ double x_, y_, a_;
+ Log log_;
+ public:
+ /// Constructor.
+ Motor (void);
+ /// Try to empty emission queue, return true if empty.
+ bool sync (void) { return asserv_.sync (); }
+ /// Wait until emission queue is empty or timed out.
+ bool wait (int timeout = -1) { return asserv_.wait (timeout); }
+ /// Get asserv reference to change parameters.
+ Asserv &getAsserv (void) { return asserv_; }
+ /// True if last long move is finished.
+ bool finish (void) const { return finish_; }
+ /// True if blocked.
+ bool blocked (void) const { return blocked_; }
+ /// Linear and angular move. T(mm) is the linear distance. A(mm) is the
+ /// angular distance which means the arc length.
+ void move (double t, double a);
+ /// Rotate (rad).
+ void rotate (double a);
+ /// Find a hole.
+ void findHole (void);
+ /// Lock good hole (approximatively...)
+ void lockGoodHole(void);
+ /// Lock ennemy hole (non pas son cul)
+ void lockBadHole(void);
+ /// Stop now.
+ void stop (void);
+ /// get the file descriptor
+ int getFd(void) const;
+ /// Reset.
+ void reset (void);
+ /// get the position of robal
+ void getPosition(double & x, double & y, double & a) const;
+ private:
+ /// Next seq number.
+ inline void nextSeq (void);
+ /// Implement Asserv::Receiver callbacks.
+ void receiveAck (int seq);
+ void receiveCounterStat (int l, int r);
+ void receivePos (double x, double y, double a);
+ void receiveSpeedStat (int t, int a);
+ void receivePosStat (int te, int ti, int ae, int ai);
+ void receivePwmStat (int l, int r);
+ void receiveTimerStat (const int *t, int tn);
+ void receiveInPort (unsigned int port);
+};
+
+#endif // motor_hh