// motor.cc // robert - programme du robot 2005 {{{ // // Copyright (C) 2005 Nicolas Haller // // 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 "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(); }