// 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) :asserv_(config, *this), idle_(true) { pStatPosition = config.get("motor.pStatPosition"); pStatMotor = config.get("motor.pStatMotor"); } /// 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(pStatPosition); asserv_.statMotor(pStatMotor); // on remet les position à 0 XXX à 0? dns ai en dur posX_ = posY_ = posA_ = 0; } // Arrête les moteurs void Motor::stop(void) { asserv_.setSpeed(); while(!idle()){} ///XXX } double Motor::getX(void) { return posX_; } double Motor::getY(void) { return posY_; } double Motor::getA(void) { 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à } bool Motor::idle(void) { return idle_; } void Motor::linearMove(double d) { asserv_.linearMove(d); idle_ = false; } void Motor::rotation(double newA) { asserv_.angularMove(newA); idle_ = false; } bool Motor::sync(void) { return asserv_.sync(); } void Motor::wait(int timeout) { asserv_.wait(timeout); } void Motor::receiveCounter (double lMotor, double rMotor) { } 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) { } void Motor::receiveTiming (int motorTimer4, int motorTimer3, int motorTimer2, int motorTimer1, int motorTimer0) { } void Motor::receiveInPort (int port) { } void Motor::receiveSharp (int sharp1, int sharp2, int sharp3) { } void Motor::receiveTazState(int state, int subState) { } void Motor::done (void) { idle_ = true; asserv_.finishAck(); }