motors.h
1 /********************************************************************************
2  * FARSA Experimentes Library *
3  * Copyright (C) 2007-2012 *
4  * Gianluca Massera <emmegian@yahoo.it> *
5  * Stefano Nolfi <stefano.nolfi@istc.cnr.it> *
6  * Tomassino Ferrauto <tomassino.ferrauto@istc.cnr.it> *
7  * Onofrio Gigliotta <onofrio.gigliotta@istc.cnr.it> *
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  * This program is distributed in the hope that it will be useful, *
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
17  * GNU General Public License for more details. *
18  * *
19  * You should have received a copy of the GNU General Public License *
20  * along with this program; if not, write to the Free Software *
21  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
22  ********************************************************************************/
23 
24 #ifndef MOTORS_H
25 #define MOTORS_H
26 
27 #include "experimentsconfig.h"
28 #include "neuroninterfaces.h"
29 #include "musclepair.h"
30 #include "robots.h"
31 
32 namespace farsa {
33 
38 class FARSA_EXPERIMENTS_API FakeMotor : public Motor {
39 public:
44  FakeMotor( ConfigurationParameters& params, QString prefix );
46  ~FakeMotor();
51  void save( ConfigurationParameters& params, QString prefix );
53  static void describe( QString type );
55  void update();
60  int size();
61 protected:
67  void resourceChanged(QString resourceName, ResourceChangeType changeType);
70 };
71 
76 class FARSA_EXPERIMENTS_API ProportionalController
77 {
78 public:
81  void setControlParameters(double k = -1.0f, double maxvel = -1.0f);
82  double getK() const;
83  void setK(double k);
84  void setMaxVelocity(double maxVel);
85  double getMaxVelocity();
86  double velocityForJoint(double desired, double current);
87 
88 protected:
89  double m_maxvel;
90  double m_k;
91 };
92 
93 } // end namespace farsa
94 
95 #endif