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 
126 class FARSA_EXPERIMENTS_API MarXbotWheelVelocityMotor : public MarXbotMotor
127 {
128 public:
136  MarXbotWheelVelocityMotor(ConfigurationParameters& params, QString prefix);
137 
141  virtual ~MarXbotWheelVelocityMotor();
142 
151  virtual void save(ConfigurationParameters& params, QString prefix);
152 
158  static void describe(QString type);
159 
163  virtual void update();
164 
170  virtual int size();
171 
172 private:
180  virtual void resourceChanged(QString resourceName, ResourceChangeType changeType);
181 
185  PhyMarXbot* m_robot;
186 
190  NeuronsIterator* m_neuronsIterator;
191 };
192 
207 class FARSA_EXPERIMENTS_API MarXbotWheelVelOrient : public MarXbotMotor
208 {
209 public:
217  MarXbotWheelVelOrient(ConfigurationParameters& params, QString prefix);
218 
222  virtual ~MarXbotWheelVelOrient();
223 
232  virtual void save(ConfigurationParameters& params, QString prefix);
233 
239  static void describe(QString type);
240 
244  virtual void update();
245 
251  virtual int size();
252 
253 private:
261  virtual void resourceChanged(QString resourceName, ResourceChangeType changeType);
262 
266  PhyMarXbot* m_robot;
267 
271  NeuronsIterator* m_neuronsIterator;
272 };
273 
299 class FARSA_EXPERIMENTS_API MarXbotColorMotor : public MarXbotMotor
300 {
301 public:
309  MarXbotColorMotor(ConfigurationParameters& params, QString prefix);
310 
314  virtual ~MarXbotColorMotor();
315 
324  virtual void save(ConfigurationParameters& params, QString prefix);
325 
331  static void describe(QString type);
332 
336  virtual void update();
337 
343  virtual int size();
344 
345 private:
353  virtual void resourceChanged(QString resourceName, ResourceChangeType changeType);
354 
358  PhyMarXbot* m_robot;
359 
363  NeuronsIterator* m_neuronsIterator;
364 
368  const QColor m_onColor;
369 
373  const QColor m_offColor;
374 
378  const real m_onThreshold;
379 
383  const real m_offThreshold;
384 };
385 
415 class FARSA_EXPERIMENTS_API MarXbotAttachmentDeviceMotor : public MarXbotMotor
416 {
417 private:
423  enum TypeOfClosure {
424  OnlyClose,
425  OnlyHalfClose,
426  Both,
427  Invalid
428  };
429 
430 public:
438  MarXbotAttachmentDeviceMotor(ConfigurationParameters& params, QString prefix);
439 
443  virtual ~MarXbotAttachmentDeviceMotor();
444 
453  virtual void save(ConfigurationParameters& params, QString prefix);
454 
460  static void describe(QString type);
461 
465  virtual void update();
466 
472  virtual int size();
473 
474 private:
482  virtual void resourceChanged(QString resourceName, ResourceChangeType changeType);
483 
490  static TypeOfClosure typeOfClosureFromString(QString value);
491 
497  static QString typeOfClosureToString(TypeOfClosure value);
498 
502  PhyMarXbot* m_robot;
503 
507  NeuronsIterator* m_neuronsIterator;
508 
512  const TypeOfClosure m_typeOfClosure;
513 
518  const real m_noMotionRange;
519 
525  const real m_noMotionRangeLow;
526 
532  const real m_noMotionRangeUp;
533 };
534 
535 }
536 
537 #endif