marxbotmotors.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 MARXBOTMOTORS_H
25 #define MARXBOTMOTORS_H
26 
27 #include "experimentsconfig.h"
28 #include "neuroninterfaces.h"
29 #include "robots.h"
30 #include "motors.h"
31 #include <QColor>
32 
33 namespace farsa {
34 
53 class FARSA_EXPERIMENTS_API MarXbotMotor : public Motor
54 {
55 public:
67  MarXbotMotor(ConfigurationParameters& params, QString prefix);
68 
72  virtual ~MarXbotMotor();
73 
82  virtual void save(ConfigurationParameters& params, QString prefix);
83 
90  static void describe(QString type);
91 
92 protected:
100  virtual void resourceChanged(QString resourceName, ResourceChangeType changeType);
101 
106 
112 };
113 
125 class FARSA_EXPERIMENTS_API MarXbotWheelVelocityMotor : public MarXbotMotor
126 {
127 public:
135  MarXbotWheelVelocityMotor(ConfigurationParameters& params, QString prefix);
136 
140  virtual ~MarXbotWheelVelocityMotor();
141 
150  virtual void save(ConfigurationParameters& params, QString prefix);
151 
157  static void describe(QString type);
158 
162  virtual void update();
163 
169  virtual int size();
170 
171 private:
179  virtual void resourceChanged(QString resourceName, ResourceChangeType changeType);
180 
184  PhyMarXbot* m_robot;
185 
189  NeuronsIterator* m_neuronsIterator;
190 };
191 
217 class FARSA_EXPERIMENTS_API MarXbotColorMotor : public MarXbotMotor
218 {
219 public:
227  MarXbotColorMotor(ConfigurationParameters& params, QString prefix);
228 
232  virtual ~MarXbotColorMotor();
233 
242  virtual void save(ConfigurationParameters& params, QString prefix);
243 
249  static void describe(QString type);
250 
254  virtual void update();
255 
261  virtual int size();
262 
263 private:
271  virtual void resourceChanged(QString resourceName, ResourceChangeType changeType);
272 
276  PhyMarXbot* m_robot;
277 
281  NeuronsIterator* m_neuronsIterator;
282 
286  const QColor m_onColor;
287 
291  const QColor m_offColor;
292 
296  const real m_onThreshold;
297 
301  const real m_offThreshold;
302 };
303 
332 class FARSA_EXPERIMENTS_API MarXbotAttachmentDeviceMotor : public MarXbotMotor
333 {
334 private:
340  enum TypeOfClosure {
341  OnlyClose,
342  OnlyHalfClose,
343  Both,
344  Invalid
345  };
346 
347 public:
355  MarXbotAttachmentDeviceMotor(ConfigurationParameters& params, QString prefix);
356 
360  virtual ~MarXbotAttachmentDeviceMotor();
361 
370  virtual void save(ConfigurationParameters& params, QString prefix);
371 
377  static void describe(QString type);
378 
382  virtual void update();
383 
389  virtual int size();
390 
391 private:
399  virtual void resourceChanged(QString resourceName, ResourceChangeType changeType);
400 
407  static TypeOfClosure typeOfClosureFromString(QString value);
408 
414  static QString typeOfClosureToString(TypeOfClosure value);
415 
419  PhyMarXbot* m_robot;
420 
424  NeuronsIterator* m_neuronsIterator;
425 
429  const TypeOfClosure m_typeOfClosure;
430 
435  const real m_noMotionRange;
436 
442  const real m_noMotionRangeLow;
443 
449  const real m_noMotionRangeUp;
450 };
451 
452 }
453 
454 #endif