marxbotsensors.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  * *
8  * This program is free software; you can redistribute it and/or modify *
9  * it under the terms of the GNU General Public License as published by *
10  * the Free Software Foundation; either version 2 of the License, or *
11  * (at your option) any later version. *
12  * *
13  * This program is distributed in the hope that it will be useful, *
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16  * GNU General Public License for more details. *
17  * *
18  * You should have received a copy of the GNU General Public License *
19  * along with this program; if not, write to the Free Software *
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
21  ********************************************************************************/
22 
23 #ifndef MARXBOTSENSORS_H
24 #define MARXBOTSENSORS_H
25 
26 #include "experimentsconfig.h"
27 #include "neuroninterfaces.h"
28 #include "world.h"
29 #include "robots.h"
30 #include "phybox.h"
31 #include "phycylinder.h"
32 #include "sensors.h"
33 
34 namespace farsa {
35 
58 class FARSA_EXPERIMENTS_API MarXbotSensor : public Sensor
59 {
60 public:
72  MarXbotSensor(ConfigurationParameters& params, QString prefix);
73 
77  virtual ~MarXbotSensor();
78 
87  virtual void save(ConfigurationParameters& params, QString prefix);
88 
95  static void describe(QString type);
96 
97 protected:
105  virtual void resourceChanged(QString resourceName, ResourceChangeType changeType);
106 
111 
117 };
118 
137 class FARSA_EXPERIMENTS_API MarXbotProximityIRSensor : public MarXbotSensor
138 {
139 public:
147  MarXbotProximityIRSensor(ConfigurationParameters& params, QString prefix);
148 
152  virtual ~MarXbotProximityIRSensor();
153 
162  virtual void save(ConfigurationParameters& params, QString prefix);
163 
169  static void describe(QString type);
170 
175  virtual void update();
176 
182  virtual int size();
183 
184 private:
192  virtual void resourceChanged(QString resourceName, ResourceChangeType changeType);
193 
197  PhyMarXbot* m_robot;
198 
202  NeuronsIterator* m_neuronsIterator;
203 
207  const QVector<bool> m_activeSensors;
208 
214  const int m_numActiveSensors;
215 };
216 
230 class FARSA_EXPERIMENTS_API MarXbotGroundBottomIRSensor : public MarXbotSensor
231 {
232 public:
240  MarXbotGroundBottomIRSensor(ConfigurationParameters& params, QString prefix);
241 
245  virtual ~MarXbotGroundBottomIRSensor();
246 
255  virtual void save(ConfigurationParameters& params, QString prefix);
256 
262  static void describe(QString type);
263 
268  virtual void update();
269 
275  virtual int size();
276 
277 private:
285  virtual void resourceChanged(QString resourceName, ResourceChangeType changeType);
286 
290  PhyMarXbot* m_robot;
291 
295  NeuronsIterator* m_neuronsIterator;
296 };
297 
311 class FARSA_EXPERIMENTS_API MarXbotGroundAroundIRSensor : public MarXbotSensor
312 {
313 public:
321  MarXbotGroundAroundIRSensor(ConfigurationParameters& params, QString prefix);
322 
326  virtual ~MarXbotGroundAroundIRSensor();
327 
336  virtual void save(ConfigurationParameters& params, QString prefix);
337 
343  static void describe(QString type);
344 
349  virtual void update();
350 
356  virtual int size();
357 
358 private:
366  virtual void resourceChanged(QString resourceName, ResourceChangeType changeType);
367 
371  PhyMarXbot* m_robot;
372 
376  NeuronsIterator* m_neuronsIterator;
377 };
378 
414 class FARSA_EXPERIMENTS_API MarXbotLinearCameraSensor : public MarXbotSensor
415 {
416 public:
424  MarXbotLinearCameraSensor(ConfigurationParameters& params, QString prefix);
425 
429  virtual ~MarXbotLinearCameraSensor();
430 
439  virtual void save(ConfigurationParameters& params, QString prefix);
440 
446  static void describe(QString type);
447 
452  virtual void update();
453 
459  virtual int size();
460 
461 private:
469  virtual void resourceChanged(QString resourceName, ResourceChangeType changeType);
470 
474  PhyMarXbot* m_robot;
475 
479  NeuronsIterator* m_neuronsIterator;
480 
488  const int m_numReceptors;
489 
494  const bool m_useRedChannel;
495 
500  const bool m_useGreenChannel;
501 
506  const bool m_useBlueChannel;
507 
511  const int m_usedColorChannels;
512 
519  const real m_aperture;
520 
524  LinearCamera* m_camera;
525 
529  const bool m_drawCamera;
530 };
531 
532 namespace __MarXbotTractionSensor_internal {
533  class TractionSensorGraphic;
534 }
535 
555 class FARSA_EXPERIMENTS_API MarXbotTractionSensor : public MarXbotSensor
556 {
557 public:
565  MarXbotTractionSensor(ConfigurationParameters& params, QString prefix);
566 
570  virtual ~MarXbotTractionSensor();
571 
580  virtual void save(ConfigurationParameters& params, QString prefix);
581 
587  static void describe(QString type);
588 
593  virtual void update();
594 
600  virtual int size();
601 
602 private:
610  virtual void resourceChanged(QString resourceName, ResourceChangeType changeType);
611 
615  PhyMarXbot* m_robot;
616 
620  NeuronsIterator* m_neuronsIterator;
621 
626  const real m_maxForce;
627 
632  const bool m_drawSensor;
633 
638 };
639 
663 class FARSA_EXPERIMENTS_API MarXbotSampledProximityIRSensor : public MarXbotSensor
664 {
665 public:
674 
679 
688  virtual void save(ConfigurationParameters& params, QString prefix);
689 
695  static void describe(QString type);
696 
701  virtual void update();
702 
708  virtual int size();
709 
710 private:
718  virtual void resourceChanged(QString resourceName, ResourceChangeType changeType);
719 
723  MarXbot* m_robot;
724 
728  Arena* m_arena;
729 
733  NeuronsIterator* m_neuronsIterator;
734 
738  const QVector<bool> m_activeSensors;
739 
745  const int m_numActiveSensors;
746 
750  const SampledIRDataLoader m_roundSamples;
751 
755  const SampledIRDataLoader m_smallSamples;
756 
760  const SampledIRDataLoader m_wallSamples;
761 };
762 
801 class FARSA_EXPERIMENTS_API MarXbotAttachmentDeviceSensor : public MarXbotSensor
802 {
803 public:
812 
817 
826  virtual void save(ConfigurationParameters& params, QString prefix);
827 
833  static void describe(QString type);
834 
839  virtual void update();
840 
846  virtual int size();
847 
848 private:
856  virtual void resourceChanged(QString resourceName, ResourceChangeType changeType);
857 
861  MarXbot* m_robot;
862 
866  NeuronsIterator* m_neuronsIterator;
867 
872  const bool m_enablePosition;
873 
878  const bool m_enableStatus;
879 
884  const bool m_enableAttached;
885 
890  const bool m_enableOtherAttached;
891 
897  const int m_numInputs;
898 };
899 
900 }
901 
902 #endif