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 #include "sensorcontrollers.h"
34 
35 namespace farsa {
36 
59 class FARSA_EXPERIMENTS_API MarXbotSensor : public Sensor
60 {
61 public:
73  MarXbotSensor(ConfigurationParameters& params, QString prefix);
74 
78  virtual ~MarXbotSensor();
79 
88  virtual void save(ConfigurationParameters& params, QString prefix);
89 
96  static void describe(QString type);
97 
98 protected:
106  virtual void resourceChanged(QString resourceName, ResourceChangeType changeType);
107 
112 
118 };
119 
139 class FARSA_EXPERIMENTS_API MarXbotProximityIRSensor : public MarXbotSensor
140 {
141 public:
149  MarXbotProximityIRSensor(ConfigurationParameters& params, QString prefix);
150 
154  virtual ~MarXbotProximityIRSensor();
155 
164  virtual void save(ConfigurationParameters& params, QString prefix);
165 
171  static void describe(QString type);
172 
177  virtual void update();
178 
184  virtual int size();
185 
186 private:
194  virtual void resourceChanged(QString resourceName, ResourceChangeType changeType);
195 
199  PhyMarXbot* m_robot;
200 
204  NeuronsIterator* m_neuronsIterator;
205 
209  const QVector<bool> m_activeSensors;
210 
216  const int m_numActiveSensors;
217 };
218 
235 class FARSA_EXPERIMENTS_API MarXbotGroundBottomIRSensor : public MarXbotSensor
236 {
237 public:
245  MarXbotGroundBottomIRSensor(ConfigurationParameters& params, QString prefix);
246 
250  virtual ~MarXbotGroundBottomIRSensor();
251 
260  virtual void save(ConfigurationParameters& params, QString prefix);
261 
267  static void describe(QString type);
268 
273  virtual void update();
274 
280  virtual int size();
281 
282  bool invertActivation() const
283  {
284  return m_invertActivation;
285  }
286 
287 private:
295  virtual void resourceChanged(QString resourceName, ResourceChangeType changeType);
296 
300  PhyMarXbot* m_robot;
301 
305  NeuronsIterator* m_neuronsIterator;
306 
310  Arena* m_arena;
311 
315  const bool m_invertActivation;
316 };
317 
332 class FARSA_EXPERIMENTS_API MarXbotGroundAroundIRSensor : public MarXbotSensor
333 {
334 public:
342  MarXbotGroundAroundIRSensor(ConfigurationParameters& params, QString prefix);
343 
347  virtual ~MarXbotGroundAroundIRSensor();
348 
357  virtual void save(ConfigurationParameters& params, QString prefix);
358 
364  static void describe(QString type);
365 
370  virtual void update();
371 
377  virtual int size();
378 
379 private:
387  virtual void resourceChanged(QString resourceName, ResourceChangeType changeType);
388 
392  PhyMarXbot* m_robot;
393 
397  NeuronsIterator* m_neuronsIterator;
398 
402  Arena* m_arena;
403 };
404 
441 class FARSA_EXPERIMENTS_API MarXbotLinearCameraSensor : public MarXbotSensor
442 {
443 public:
451  MarXbotLinearCameraSensor(ConfigurationParameters& params, QString prefix);
452 
456  virtual ~MarXbotLinearCameraSensor();
457 
466  virtual void save(ConfigurationParameters& params, QString prefix);
467 
473  static void describe(QString type);
474 
479  virtual void update();
480 
486  virtual int size();
487 
494  {
495  return m_camera;
496  }
497 
498 private:
506  virtual void resourceChanged(QString resourceName, ResourceChangeType changeType);
507 
511  PhyMarXbot* m_robot;
512 
516  NeuronsIterator* m_neuronsIterator;
517 
525  const int m_numReceptors;
526 
531  const bool m_useRedChannel;
532 
537  const bool m_useGreenChannel;
538 
543  const bool m_useBlueChannel;
544 
548  const int m_usedColorChannels;
549 
556  const real m_aperture;
557 
562  const real m_maxDistance;
563 
567  LinearCamera* m_camera;
568 
572  const bool m_drawCamera;
573 };
574 
625 class FARSA_EXPERIMENTS_API MarXbotLinearCameraSensorNew : public MarXbotSensor
626 {
627 public:
635  MarXbotLinearCameraSensorNew(ConfigurationParameters& params, QString prefix);
636 
640  virtual ~MarXbotLinearCameraSensorNew();
641 
650  virtual void save(ConfigurationParameters& params, QString prefix);
651 
657  static void describe(QString type);
658 
663  virtual void update();
664 
670  virtual int size();
671 
678  {
679  return m_camera;
680  }
681 
682 private:
690  virtual void resourceChanged(QString resourceName, ResourceChangeType changeType);
691 
695  PhyMarXbot* m_robot;
696 
700  NeuronsIterator* m_neuronsIterator;
701 
711  int m_numReceptors;
712 
717  const bool m_useRedChannel;
718 
723  const bool m_useGreenChannel;
724 
729  const bool m_useBlueChannel;
730 
734  const int m_usedColorChannels;
735 
742  const real m_aperture;
743 
748  const real m_maxDistance;
749 
753  QVector<SimpleInterval> m_receptorsRanges;
754 
759 
763  const bool m_drawCamera;
764 };
765 
766 namespace __MarXbotTractionSensor_internal {
767  class TractionSensorGraphic;
768 }
769 
791 class FARSA_EXPERIMENTS_API MarXbotTractionSensor : public MarXbotSensor
792 {
793 public:
801  MarXbotTractionSensor(ConfigurationParameters& params, QString prefix);
802 
806  virtual ~MarXbotTractionSensor();
807 
816  virtual void save(ConfigurationParameters& params, QString prefix);
817 
823  static void describe(QString type);
824 
829  virtual void update();
830 
836  virtual int size();
837 
838 private:
846  virtual void resourceChanged(QString resourceName, ResourceChangeType changeType);
847 
851  PhyMarXbot* m_robot;
852 
856  NeuronsIterator* m_neuronsIterator;
857 
862  const real m_maxForce;
863 
868  const real m_minForce;
869 
874  const bool m_drawSensor;
875 
880 };
881 
913 class FARSA_EXPERIMENTS_API MarXbotSampledProximityIRSensor : public MarXbotSensor
914 {
915 public:
924 
929 
938  virtual void save(ConfigurationParameters& params, QString prefix);
939 
945  static void describe(QString type);
946 
951  virtual void update();
952 
958  virtual int size();
959 
960  const SampledIRDataLoader& getRoundSamples() const
961  {
962  return m_roundSamples;
963  }
964 
965  const SampledIRDataLoader& getSmallSamples() const
966  {
967  return m_smallSamples;
968  }
969 
970  const QVector<bool>& getActiveSensors() const
971  {
972  return m_activeSensors;
973  }
974 
975  int getNumActiveSensors() const
976  {
977  return m_numActiveSensors;
978  }
979 
980  int getAverageNum() const
981  {
982  return m_averageNum;
983  }
984 
985 private:
993  virtual void resourceChanged(QString resourceName, ResourceChangeType changeType);
994 
998  MarXbot* m_robot;
999 
1003  Arena* m_arena;
1004 
1008  NeuronsIterator* m_neuronsIterator;
1009 
1013  const QVector<bool> m_activeSensors;
1014 
1020  const int m_averageNum;
1021 
1027  const int m_numActiveSensors;
1028 
1032  const SampledIRDataLoader m_roundSamples;
1033 
1037  const SampledIRDataLoader m_smallSamples;
1038 
1042  const SampledIRDataLoader m_wallSamples;
1043 };
1044 
1083 class FARSA_EXPERIMENTS_API MarXbotAttachmentDeviceSensor : public MarXbotSensor
1084 {
1085 public:
1093  MarXbotAttachmentDeviceSensor(ConfigurationParameters& params, QString prefix);
1094 
1098  virtual ~MarXbotAttachmentDeviceSensor();
1099 
1108  virtual void save(ConfigurationParameters& params, QString prefix);
1109 
1115  static void describe(QString type);
1116 
1121  virtual void update();
1122 
1128  virtual int size();
1129 
1130 private:
1138  virtual void resourceChanged(QString resourceName, ResourceChangeType changeType);
1139 
1143  MarXbot* m_robot;
1144 
1148  NeuronsIterator* m_neuronsIterator;
1149 
1154  const bool m_enablePosition;
1155 
1160  const bool m_enableStatus;
1161 
1166  const bool m_enableAttached;
1167 
1172  const bool m_enableOtherAttached;
1173 
1179  const int m_numInputs;
1180 };
1181 
1200 class FARSA_EXPERIMENTS_API MarXbotWheelSpeedsSensor : public MarXbotSensor
1201 {
1202 public:
1206  enum Mode {
1207  AbsoluteMode,
1209  DeltaMode,
1212  UnknownMode
1213  };
1214 
1221  static QString modeToString(Mode mode);
1222 
1230  static Mode stringToMode(QString mode);
1231 
1232 public:
1240  MarXbotWheelSpeedsSensor(ConfigurationParameters& params, QString prefix);
1241 
1245  virtual ~MarXbotWheelSpeedsSensor();
1246 
1255  virtual void save(ConfigurationParameters& params, QString prefix);
1256 
1262  static void describe(QString type);
1263 
1268  virtual void update();
1269 
1275  virtual int size();
1276 
1277 private:
1285  virtual void resourceChanged(QString resourceName, ResourceChangeType changeType);
1286 
1290  PhyMarXbot* m_robot;
1291 
1295  NeuronsIterator* m_neuronsIterator;
1296 
1300  const Mode m_mode;
1301 };
1302 
1322 class FARSA_EXPERIMENTS_API MarXbotLaserFrontDistanceSensor : public MarXbotSensor
1323 {
1324 public:
1333 
1338 
1347  virtual void save(ConfigurationParameters& params, QString prefix);
1348 
1354  static void describe(QString type);
1355 
1360  virtual void update();
1361 
1367  virtual int size();
1368 
1369 private:
1377  virtual void resourceChanged(QString resourceName, ResourceChangeType changeType);
1378 
1382  PhyMarXbot* m_robot;
1383 
1387  NeuronsIterator* m_neuronsIterator;
1388 
1392  SingleIR* m_sensorLeft;
1393 
1397  SingleIR* m_sensorCenter;
1398 
1402  SingleIR* m_sensorRight;
1403 
1404 
1408  const real m_maxDistance;
1409 
1413  real m_aperture;
1414 
1418  const bool m_drawSensors;
1419 
1423  const bool m_drawRays;
1424 
1428  const bool m_drawRaysRange;
1429 
1430 };
1431 
1432 
1450 class FARSA_EXPERIMENTS_API MarXbotLaserOmniDistanceSensor : public MarXbotSensor
1451 {
1452 public:
1461 
1465  virtual ~MarXbotLaserOmniDistanceSensor();
1466 
1475  virtual void save(ConfigurationParameters& params, QString prefix);
1476 
1482  static void describe(QString type);
1483 
1488  virtual void update();
1489 
1495  virtual int size();
1496 
1497 private:
1505  virtual void resourceChanged(QString resourceName, ResourceChangeType changeType);
1506 
1510  PhyMarXbot* m_robot;
1511 
1515  NeuronsIterator* m_neuronsIterator;
1516 
1520  SingleIR* m_sensorLeft;
1521 
1525  SingleIR* m_sensorCenter;
1526 
1530  SingleIR* m_sensorRight;
1531 
1535  SingleIR* m_sensorRearLeft;
1536 
1540  SingleIR* m_sensorRear;
1541 
1545  SingleIR* m_sensorRearRight;
1546 
1550  const real m_maxDistance;
1551 
1555  const bool m_drawSensors;
1556 
1560  const bool m_drawRays;
1561 
1565  const bool m_drawRaysRange;
1566 
1570  const bool m_avgSensors;
1571 };
1572 
1573 }
1574 
1575 
1576 #endif
The linear camera sensor of the MarXbot.
Mode
The enum of different modalities for this sensor.
The infrared ground around sensors of the MarXbot.
An helper class to load sampled data from file.
Definition: sensors.h:849
QString m_marxbotResource
The name of the resource associated with the MarXbot robot.
The infrared ground bottom sensors of the MarXbot.
An Omnidirectional distance sensor for long distances.
The class modelling an arena.
Definition: arena.h:50
The infrared proximity sensors of the MarXbot.
The base abstract class for iterating over neurons of a neural network.
The sampled proximity infrared sensors of the MarXbot.
The graphical representation of the MarXbot traction sensor.
const LinearCamera * getLinearCamera() const
Returns a const pointer to the inner Linear camera object.
This file contains the common type defitions used on the whole framework.
The base abstract class for the Sensor hierarchy.
The traction sensors of the MarXbot.
A frontal distance sensor for long distances.
The base abstract class for MarXbot sensors.
An helper class for linear camera sensors of various robots.
Definition: sensors.h:232
The sensor providing the attachment device proprioception.
QString m_neuronsIteratorResource
The name of th resource associated with the neural network iterator.
float real
The class modelling the marXbot robot.
Definition: robots.h:268
The linear camera sensor of the MarXbot (new implementation)
An helper class for linear camera sensors of various robots.
Definition: sensors.h:487
The sensor reporting the actual velocity of the wheels of the MarXbot.
const LinearCameraNew::LinearCamera * getLinearCamera() const
Returns a const pointer to the inner Linear camera object.