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 #include "helperresources.h"
32 
33 namespace farsa {
34 
60 class FARSA_EXPERIMENTS_API FakeMotor : public Motor
61 {
62 public:
69  FakeMotor(ConfigurationParameters& params, QString prefix);
70 
74  ~FakeMotor();
75 
83  virtual void save(ConfigurationParameters& params, QString prefix);
84 
90  static void describe(QString type);
91 
95  virtual void update();
96 
102  virtual int size();
103 
115  virtual void shareResourcesWith(ResourcesUser* other);
116 
117 protected:
125  void resourceChanged(QString resourceName, ResourceChangeType changeType);
126 
131 
137 
143 
148 };
149 
158 class FARSA_EXPERIMENTS_API ProportionalController
159 {
160 public:
169 
176  ProportionalController(double k, double maxVelocity);
177 
184 
191  ProportionalController& operator=(const ProportionalController& other);
192 
197 
203  real getK() const
204  {
205  return m_k;
206  }
207 
213  void setK(double k)
214  {
215  m_k = k;
216  }
217 
223  real getMaxVelocity() const
224  {
225  return m_maxVelocity;
226  }
227 
233  void setMaxVelocity(double maxVelocity)
234  {
235  m_maxVelocity = maxVelocity;
236  }
237 
246  real velocityForJoint(real desired, real current) const;
247 
248 protected:
252  real m_k;
253 
258 };
259 
260 } // end namespace farsa
261 
262 #endif