experiments/include/motors.h

00001 /********************************************************************************
00002  *  FARSA Experimentes Library                                                  *
00003  *  Copyright (C) 2007-2012                                                     *
00004  *  Gianluca Massera <emmegian@yahoo.it>                                        *
00005  *  Stefano Nolfi <stefano.nolfi@istc.cnr.it>                                   *
00006  *  Tomassino Ferrauto <tomassino.ferrauto@istc.cnr.it>                         *
00007  *  Onofrio Gigliotta <onofrio.gigliotta@istc.cnr.it>                           * 
00008  *                                                                              *
00009  *  This program is free software; you can redistribute it and/or modify        *
00010  *  it under the terms of the GNU General Public License as published by        *
00011  *  the Free Software Foundation; either version 2 of the License, or           *
00012  *  (at your option) any later version.                                         *
00013  *                                                                              *
00014  *  This program is distributed in the hope that it will be useful,             *
00015  *  but WITHOUT ANY WARRANTY; without even the implied warranty of              *
00016  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               *
00017  *  GNU General Public License for more details.                                *
00018  *                                                                              *
00019  *  You should have received a copy of the GNU General Public License           *
00020  *  along with this program; if not, write to the Free Software                 *
00021  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA  *
00022  ********************************************************************************/
00023 
00024 #ifndef MOTORS_H
00025 #define MOTORS_H
00026 
00027 #include "experimentsconfig.h"
00028 #include "neuroninterfaces.h"
00029 #include "musclepair.h"
00030 #include "robots.h"
00031 
00032 namespace farsa {
00033 
00038 class FARSA_EXPERIMENTS_API FakeMotor : public Motor {
00039 public:
00044     FakeMotor( ConfigurationParameters& params, QString prefix );
00046     ~FakeMotor();
00051     void save( ConfigurationParameters& params, QString prefix );
00053     static void describe( QString type );
00055     void update();
00060     int size();
00061 protected:
00067     void resourceChanged(QString resourceName, ResourceChangeType changeType);
00069     int nFakeMotors;
00070 };
00071 
00076 class FARSA_EXPERIMENTS_API ProportionalController
00077 {
00078 public:
00079     ProportionalController();
00080     ~ProportionalController();
00081     void setControlParameters(double k = -1.0f, double maxvel = -1.0f);
00082     double getK() const;
00083     void setK(double k);
00084     void setMaxVelocity(double maxVel);
00085     double getMaxVelocity();
00086     double velocityForJoint(double desired, double current);
00087 
00088 protected:
00089     double m_maxvel; 
00090     double m_k; 
00091 };
00092 
00093 } // end namespace farsa
00094 
00095 #endif