00001 /**************************************************************** 00002 * 00003 * Copyright (c) 2010 00004 * 00005 * Fraunhofer Institute for Manufacturing Engineering 00006 * and Automation (IPA) 00007 * 00008 * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 00009 * 00010 * Project name: care-o-bot 00011 * ROS stack name: cob_driver 00012 * ROS package name: cob_powercube_chain 00013 * Description: This class simulates a PowerCube. 00014 * 00015 * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 00016 * 00017 * Author: Felix Geibel, email:Felix.Geibel@gmx.de 00018 * Supervised by: Alexander Bubeck, email:alexander.bubeck@ipa.fhg.de 00019 * 00020 * Date of creation: Aug 2007 00021 * ToDo: 00022 * 00023 * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 00024 * 00025 * Redistribution and use in source and binary forms, with or without 00026 * modification, are permitted provided that the following conditions are met: 00027 * 00028 * * Redistributions of source code must retain the above copyright 00029 * notice, this list of conditions and the following disclaimer. 00030 * * Redistributions in binary form must reproduce the above copyright 00031 * notice, this list of conditions and the following disclaimer in the 00032 * documentation and/or other materials provided with the distribution. 00033 * * Neither the name of the Fraunhofer Institute for Manufacturing 00034 * Engineering and Automation (IPA) nor the names of its 00035 * contributors may be used to endorse or promote products derived from 00036 * this software without specific prior written permission. 00037 * 00038 * This program is free software: you can redistribute it and/or modify 00039 * it under the terms of the GNU Lesser General Public License LGPL as 00040 * published by the Free Software Foundation, either version 3 of the 00041 * License, or (at your option) any later version. 00042 * 00043 * This program is distributed in the hope that it will be useful, 00044 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00045 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00046 * GNU Lesser General Public License LGPL for more details. 00047 * 00048 * You should have received a copy of the GNU Lesser General Public 00049 * License LGPL along with this program. 00050 * If not, see <http://www.gnu.org/licenses/>. 00051 * 00052 ****************************************************************/ 00053 00054 #ifndef _SIMULATED_MOTOR_H_ 00055 #define _SIMULATED_MOTOR_H_ 00056 00057 #include <cob_powercube_chain/moveCommand.h> 00058 #include <string> 00059 00060 class simulatedMotor 00061 { 00062 public: 00063 00064 simulatedMotor(double lowLimit, double upLimit, double maxAcc, double maxVel); 00065 ~simulatedMotor() {;} 00066 00068 virtual bool init() { return true; } 00069 00071 virtual std::string getErrorMessage() { return std::string("No Errors."); } 00072 00074 // virtual void setDebugOutput(ostream* os) { deb = os; } 00075 00077 // Zunächst die Steuerungs-Funktionen: // 00079 00081 virtual void moveRamp(double targetAngle, double vmax, double amax); 00082 00084 virtual void moveVel(double vel); 00085 00087 virtual void movePos(double pos); 00088 00090 virtual void stop(); 00091 00093 // Funktionen zum setzen und auslesen von Parametern: // 00095 00098 virtual void setMaxVelocity(double radpersec) { m_vmax = radpersec; } 00099 virtual double getMaxVelocity() { return m_vmax; } 00100 00103 virtual void setMaxAcceleration(double radPerSecSquared) { m_amax = radPerSecSquared; } 00104 virtual double getMaxAcceleration() { return m_amax; } 00105 00107 virtual void setLimits(double lowerLimit, double upperLimit) 00108 { m_ul = upperLimit; m_ll = lowerLimit; } 00109 virtual double getUpperLimit() { return m_ul; } 00110 virtual double getLowerLimit() { return m_ll; } 00111 00113 virtual void setTimeConstant(double T) { T0 = T; } 00114 virtual double getTimeConstant() const { return T0; } 00115 00117 // hier die Funktionen zur Statusabfrage: // 00119 00121 virtual RampCommand getRampMove(double targetAngle, double v, double a); 00122 00124 virtual RampCommand getRampMove(double targetAngle) { return getRampMove(targetAngle, m_vmax, m_amax); } 00125 00127 virtual double getAngle() { return m_lastMove.getPos(); } 00128 00130 virtual double getVelocity() { return m_lastMove.getVel(); } 00131 00134 virtual bool statusMoving() { return m_lastMove.isActive(); } 00135 00137 virtual bool statusDec() { return m_lastMove.inPhase3(); } 00138 00140 virtual bool statusAcc() { return m_lastMove.inPhase1(); } 00141 00142 private: 00143 00144 RampCommand m_lastMove; 00145 00146 double m_ul, m_ll; // upper limit and lower limit 00147 double m_amax, m_vmax; // Never mover faster than this! 00148 00149 double T0; // Zeitkonstante für Annäherung der Sprungantwort durch Rampe 00150 00151 //ostream * deb; 00152 }; 00153 00154 00155 #endif