sensors.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 SENSORS_H
24 #define SENSORS_H
25 
26 #include "experimentsconfig.h"
27 #include "neuroninterfaces.h"
28 #include "world.h"
29 #include "robots.h"
30 #include "wheeledexperimenthelper.h"
31 
32 namespace farsa {
33 
37 class FARSA_EXPERIMENTS_API ObjectPositionSensor : public Sensor {
38 public:
43  ObjectPositionSensor( ConfigurationParameters& params, QString prefix );
50  void save( ConfigurationParameters& params, QString prefix );
52  static void describe( QString type );
54  void update();
56  int size();
57 protected:
63  void resourceChanged(QString resourceName, ResourceChangeType changeType);
67  QString objectName;
69  bool linearize;
71  wVector bbMin;
73  wVector bbMax;
74 };
75 
76 namespace __LinearCamera_internal {
77  class LinearCameraGraphic;
78 }
79 
106 class FARSA_EXPERIMENTS_API LinearCamera : public ConcurrentResourcesUser
107 {
108 public:
122  LinearCamera(WObject* obj, wMatrix mtr, double aperture, unsigned int numReceptors, QColor backgroundColor);
123 
127  virtual ~LinearCamera();
128 
132  void update();
133 
140  const QColor& colorForReceptor(int i) const
141  {
142  return m_receptors[i];
143  }
144 
150  double getAperture() const
151  {
152  return m_aperture;
153  }
154 
160  unsigned int getNumReceptors() const
161  {
162  return m_numReceptors;
163  }
164 
171  QColor getBackgroundColor() const
172  {
173  return m_backgroundColor;
174  }
175 
182  void setBackgroundColor(QColor color)
183  {
184  m_backgroundColor = color;
185  }
186 
192  void drawCamera(bool d);
193 
194 private:
202  virtual void resourceChanged(QString resourceName, ResourceChangeType changeType);
203 
207  QVector<QColor> m_receptors;
208 
213  WObject* const m_object;
214 
222  const wMatrix m_transformation;
223 
227  const double m_aperture;
228 
232  const unsigned int m_numReceptors;
233 
239  QColor m_backgroundColor;
240 
246  const double m_apertureMin;
247 
253  const double m_apertureMax;
254 
260  const double m_receptorRange;
261 
265  Arena* m_arena;
266 
270  bool m_drawCamera;
271 
278 };
279 
280 } // end namespace farsa
281 
282 #endif