kheperasensors.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 KHEPERASENSORS_H
24 #define KHEPERASENSORS_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 KheperaSensor : public Sensor
59 {
60 public:
72  KheperaSensor(ConfigurationParameters& params, QString prefix);
73 
77  virtual ~KheperaSensor();
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 
132 class FARSA_EXPERIMENTS_API KheperaProximityIRSensor : public KheperaSensor
133 {
134 public:
142  KheperaProximityIRSensor(ConfigurationParameters& params, QString prefix);
143 
147  virtual ~KheperaProximityIRSensor();
148 
157  virtual void save(ConfigurationParameters& params, QString prefix);
158 
164  static void describe(QString type);
165 
170  virtual void update();
171 
177  virtual int size();
178 
179 private:
187  virtual void resourceChanged(QString resourceName, ResourceChangeType changeType);
188 
192  PhyKhepera* m_robot;
193 
197  NeuronsIterator* m_neuronsIterator;
198 };
199 
224 class FARSA_EXPERIMENTS_API KheperaSampledProximityIRSensor : public KheperaSensor
225 {
226 public:
235 
240 
249  virtual void save(ConfigurationParameters& params, QString prefix);
250 
256  static void describe(QString type);
257 
262  virtual void update();
263 
269  virtual int size();
270 
271 private:
279  virtual void resourceChanged(QString resourceName, ResourceChangeType changeType);
280 
284  Khepera* m_robot;
285 
289  Arena* m_arena;
290 
294  NeuronsIterator* m_neuronsIterator;
295 
299  const QVector<bool> m_activeSensors;
300 
306  const int m_numActiveSensors;
307 
311  const SampledIRDataLoader m_roundSamples;
312 
316  const SampledIRDataLoader m_smallSamples;
317 
321  const SampledIRDataLoader m_wallSamples;
322 };
323 
346 class FARSA_EXPERIMENTS_API KheperaSampledLightSensor : public KheperaSensor
347 {
348 public:
356  KheperaSampledLightSensor(ConfigurationParameters& params, QString prefix);
357 
361  virtual ~KheperaSampledLightSensor();
362 
371  virtual void save(ConfigurationParameters& params, QString prefix);
372 
378  static void describe(QString type);
379 
384  virtual void update();
385 
391  virtual int size();
392 
393 private:
401  virtual void resourceChanged(QString resourceName, ResourceChangeType changeType);
402 
406  Khepera* m_robot;
407 
411  Arena* m_arena;
412 
416  NeuronsIterator* m_neuronsIterator;
417 
421  const QVector<bool> m_activeSensors;
422 
428  const int m_numActiveSensors;
429 
433  const SampledIRDataLoader m_lightSamples;
434 
435 };
436 
449 class FARSA_EXPERIMENTS_API KheperaGroundSensor : public KheperaSensor
450 {
451 public:
459  KheperaGroundSensor(ConfigurationParameters& params, QString prefix);
460 
464  virtual ~KheperaGroundSensor();
465 
474  virtual void save(ConfigurationParameters& params, QString prefix);
475 
481  static void describe(QString type);
482 
487  virtual void update();
488 
494  virtual int size();
495 
496 private:
504  virtual void resourceChanged(QString resourceName, ResourceChangeType changeType);
505 
509  Khepera* m_robot;
510 
514  Arena* m_arena;
515 
519  NeuronsIterator* m_neuronsIterator;
520 
521 };
522 
523 
542 class FARSA_EXPERIMENTS_API KheperaWheelSpeedsSensor : public KheperaSensor
543 {
544 public:
548  enum Mode {
549  AbsoluteMode,
551  DeltaMode,
554  UnknownMode
555  };
556 
563  static QString modeToString(Mode mode);
564 
572  static Mode stringToMode(QString mode);
573 
574 public:
582  KheperaWheelSpeedsSensor(ConfigurationParameters& params, QString prefix);
583 
587  virtual ~KheperaWheelSpeedsSensor();
588 
597  virtual void save(ConfigurationParameters& params, QString prefix);
598 
604  static void describe(QString type);
605 
610  virtual void update();
611 
617  virtual int size();
618 
619 private:
627  virtual void resourceChanged(QString resourceName, ResourceChangeType changeType);
628 
632  PhyKhepera* m_robot;
633 
637  NeuronsIterator* m_neuronsIterator;
638 
642  const Mode m_mode;
643 };
644 
645 
646 
647 }
648 
649 #endif
QString m_neuronsIteratorResource
The name of th resource associated with the neural network iterator.
An helper class to load sampled data from file.
Definition: sensors.h:849
The base abstract class for khepera sensors.
The class modelling an arena.
Definition: arena.h:50
The base abstract class for iterating over neurons of a neural network.
This file contains the common type defitions used on the whole framework.
The sensor reporting the actual velocity of the wheels of the Khepera.
The base abstract class for the Sensor hierarchy.
Mode
The enum of different modalities for this sensor.
QString m_kheperaResource
The name of the resource associated with the e-puck robot.
The ground sensor of the Khepera.
The sampled proximity infrared sensors of the Khepera.
The sampled light sensors of the Khepera.
The infrared proximity sensors of the khepera.
The class modelling the Khepera robot.
Definition: robots.h:526