summaryrefslogtreecommitdiff
path: root/i/chuck/src/asserv/asserv.hh
diff options
context:
space:
mode:
authorbecquet2007-05-10 18:49:20 +0000
committerbecquet2007-05-10 18:49:20 +0000
commit8f486613be58ced269db1d437e560c16558604e8 (patch)
tree41e94b2122a118cb06abf6fc2a0038cd1dfbec4a /i/chuck/src/asserv/asserv.hh
parent4daa2c76c2a028e4b2c8ab379e7d1e0f535a0a31 (diff)
Création de chuck, le programme du robot 2007.
Diffstat (limited to 'i/chuck/src/asserv/asserv.hh')
-rw-r--r--i/chuck/src/asserv/asserv.hh141
1 files changed, 141 insertions, 0 deletions
diff --git a/i/chuck/src/asserv/asserv.hh b/i/chuck/src/asserv/asserv.hh
new file mode 100644
index 0000000..ddbc104
--- /dev/null
+++ b/i/chuck/src/asserv/asserv.hh
@@ -0,0 +1,141 @@
+#ifndef asserv_hh
+#define asserv_hh
+// asserv.hh
+// marvin - programme du robot 2006. {{{
+//
+// Copyright (C) 2006 Nicolas Schodet
+//
+// Robot APB Team/Efrei 2006.
+// 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 "proto/proto.hh"
+
+/// Dialog class with the motor control board.
+/// Units:
+/// - step: one step distance.
+/// - period: one motor control sampling period.
+class Asserv : public Proto::Receiver
+{
+ public:
+ /// Asserv clients must implement Receiver.
+ class Receiver
+ {
+ public:
+ virtual ~Receiver (void) { }
+ virtual void receiveAck (int seq) = 0;
+ virtual void receiveCounterStat (int l, int r) = 0;
+ virtual void receivePos (double x, double y, double a) = 0;
+ virtual void receiveSpeedStat (int t, int a) = 0;
+ virtual void receivePosStat (int te, int ti, int ae, int ai) = 0;
+ virtual void receivePwmStat (int l, int r) = 0;
+ virtual void receiveTimerStat (const int *t, int tn) = 0;
+ virtual void receiveInPort (unsigned int port) = 0;
+ };
+ private:
+ Proto proto_;
+ std::string tty_;
+ Receiver &receiver_;
+ int intervalCounterStat_, intervalPos_, intervalSpeedStat_,
+ intervalPosStat_, intervalPwmStat_, intervalTimerStat_,
+ intervalInPort_;
+ int footing_;
+ int tAccel_, aAccel_;
+ int tMaxSpeed_, aMaxSpeed_, tMaxSpeedSlow_, aMaxSpeedSlow_;
+ int tkp_, tki_, tkd_, akp_, aki_, akd_, esat_, isat_;
+ bool lInvertPwm_, rInvertPwm_;
+ double stepPerMm_;
+ public:
+ /// Constructor.
+ Asserv (Asserv::Receiver &receiver);
+ /// Essaie de purger la liste d'émission et indique si elle est vide.
+ bool sync (void);
+ /// Attend que toute les émissions soit terminées.
+ bool wait (int timeout = -1);
+ /// Récupère le File Descriptor
+ int getFd (void) const;
+ /// Reset the board and send parameters.
+ void reset (void);
+ /// Set PWM.
+ void pwm (int l, int r);
+ /// Position consign offset.
+ void offset (double t, double a);
+ /// Set speed.
+ void speed (int t, int a);
+ /// Speed controlled position consign offset.
+ void speedTo (double t, double a, int seq);
+ /// Speed controlled angle consign offset.
+ void speedAngle (double a, int seq);
+ /// Find a hole.
+ void findHole (int seq);
+ /// Acknoledge.
+ void ack (int seq);
+ /// Change counter stat interval.
+ void setIntervalCounterStat (int i);
+ /// Change position report interval.
+ void setIntervalPos (int i);
+ /// Change speed stat interval.
+ void setIntervalSpeedStat (int i);
+ /// Change position control stat interval.
+ void setIntervalPosStat (int i);
+ /// Change pwm stat interval.
+ void setIntervalPwmStat (int i);
+ /// Change timer stat interval.
+ void setIntervalTimerStat (int i);
+ /// Change input port report interval.
+ void setIntervalInPort (int i);
+ /// Set current position.
+ void setPos (double x, double y, double a);
+ /// Set current x position.
+ void setXPos (double x);
+ /// Set current y position.
+ void setYPos (double y);
+ /// Set current angle.
+ void setAngle (double a);
+ /// Set footing.
+ void setFooting (int f);
+ /// Set acceleration.
+ void setAccel (int t, int a);
+ /// Set maximum speed for automatic movements.
+ void setMaxSpeed (int t, int a, int ts, int as);
+ /// Set motor control coeficients.
+ void setCoef (int tkp, int tki, int tkd, int akp, int aki, int akd,
+ int esat, int isat);
+ /// Set PWM direction.
+ void setPwmDir (bool invertL, bool invertR);
+ /// Store to eeprom.
+ void storeParams (void);
+ /// Clear eeprom.
+ void clearParams (void);
+ /// Implémentation du proto::Receiver.
+ void receive (char command, const Proto::Frame &frame);
+ private:
+ /// Convert mm to steps.
+ int mmToStep (double mm) const;
+ /// Convert steps to mm.
+ double stepToMm (int step) const;
+ /// Convert rad to avr angles.
+ int radToAvr (double a) const;
+ /// Convert avr angles to rad.
+ double avrToRad (int a) const;
+ /// Convert rad to steps.
+ int radToStep (double a) const;
+};
+
+#endif // asserv_hh