summaryrefslogtreecommitdiff
path: root/2005/i/robert/src/motor/motor.cc
diff options
context:
space:
mode:
authorhaller2005-04-24 21:27:07 +0000
committerhaller2005-04-24 21:27:07 +0000
commit7d1f86949f4b72895aaf675a1f001d834160369b (patch)
tree1106951bb6dbb634d4ec8b6a510dac3714d6f37e /2005/i/robert/src/motor/motor.cc
parent3fe94413d04df7057ea54e15f3b4dd59565749dd (diff)
Début d'implémentation des fonctions
Y'a encore du boulot
Diffstat (limited to '2005/i/robert/src/motor/motor.cc')
-rw-r--r--2005/i/robert/src/motor/motor.cc153
1 files changed, 153 insertions, 0 deletions
diff --git a/2005/i/robert/src/motor/motor.cc b/2005/i/robert/src/motor/motor.cc
index 6809acd..3b48104 100644
--- a/2005/i/robert/src/motor/motor.cc
+++ b/2005/i/robert/src/motor/motor.cc
@@ -23,3 +23,156 @@
//
// }}}
+#include "motor.hh"
+
+/// Constructeur
+Motor::Motor (const Config & config) // XXX Voir si besoin de config
+ :asserv_(config, *this), idle_(true)
+{
+}
+
+/// Initialise les moteurs
+void Motor::init (void)
+{
+ // on reset la carte
+ asserv_.reset();
+ // On stop le moteur
+ stop();
+ // on règle le rafraichissement des positions
+ asserv_.statPosition(1); /// XXX Le temps combien et réglé ou??
+ asserv_.statMotor(1);
+ // on remet les position à 0 XXX à 0?
+ posX_ = posY_ = posA_ = 0;
+ // on regarde si les moteurs sont idle
+ while (!idle()) {} // XXX humhum?
+}
+
+// Arrête les moteurs
+void Motor::stop(void)
+{
+ asserv_.setSpeed(0,0);
+ // XXX Peut-on lui dire d'oublier une commande?
+ while(!idle()){} ///XXX vaut mieux appeler la commande ou la var?
+}
+
+double Motor::getX(void)
+{
+ sync(); // XXX attendre true??
+ return posX_;
+}
+
+double Motor::getY(void)
+{
+ sync();
+ return posY_;
+}
+
+double Motor::getA(void)
+{
+ sync();
+ return posA_;
+}
+
+void Motor::goTo(double x, double y, double a)
+{
+ // XXX Méthode carré ou pas?
+}
+
+void Motor::recalage(void)
+{
+ // XXX je ne vois pas là
+}
+
+void Motor::setSpeed(double v)
+{
+ asserv_.setSpeed(v,v); /// XXX sur ca?
+ idle_ = false;
+ sync(); // XXX avant ou après?
+}
+
+bool Motor::idle(void)
+{
+ sync();
+ return idle_;
+}
+
+void Motor::linearMove(double d)
+{
+ sync();
+ asserv_.linearMove(d);
+ idle_ = false;
+}
+
+void Motor::rotation(double newA) //Est-ce un nouveau angle asb ou rel??
+{
+ sync();
+ asserv_.angularMove(newA);
+ idle_ = false;
+}
+
+bool Motor::sync(void)
+{
+ return asserv_.sync();
+}
+
+void Motor::receiveCounter (double lMotor, double rMotor)
+{
+ /// XXX que faire
+}
+
+void Motor::receivePosX (double xPos)
+{
+ posX_ = xPos;
+}
+
+void Motor::receivePosY (double yPos)
+{
+ posY_ = yPos;
+}
+
+void Motor::receivePosA (double aPos)
+{
+ posA_ = aPos;
+}
+
+void Motor::receiveSpeedStat (int leftError, int leftInt, int rightError,
+ int rightInt)
+{
+ if(leftInt == 0 && rightInt == 0) // XXX c'est bon ca?
+ idle_ = true;
+ else
+ idle_ = false;
+}
+
+void Motor::receivePwm (double leftPwm, double rightPwm)
+{
+ // XXX que faire??
+}
+
+void Motor::receiveTiming (int motorTimer4,
+ int motorTimer3, int motorTimer2,
+ int motorTimer1, int motorTimer0)
+{
+ // XXX Que faire???
+}
+
+void Motor::receiveInPort (int port)
+{
+ // XXX Que faire?
+}
+
+void Motor::receiveSharp (int sharp1, int sharp2, int sharp3)
+{
+ // XXX Que faire?
+}
+
+void Motor::receiveTazState(int state, int subState)
+{
+ // XXX Que faire?
+}
+
+void Motor::done (void)
+{
+ idle_ = true;
+ asserv_.finishAck();
+}