Robot Simulator of the Robotics Group for Self-Organization of Control  0.8.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
soundsensor.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005-2011 LpzRobots development team *
3  * Georg Martius <georg dot martius at web dot de> *
4  * Frank Guettler <guettler at informatik dot uni-leipzig dot de *
5  * Frank Hesse <frank at nld dot ds dot mpg dot de> *
6  * Ralf Der <ralfder at mis dot mpg dot de> *
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 *
20  * Free Software Foundation, Inc., *
21  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
22  * *
23  ***************************************************************************/
24 #ifndef SOUNDSENSOR_H_
25 # define SOUNDSENSOR_H_
26 
27 #include "sensor.h"
28 
29 namespace lpzrobots {
30 
31  /** Sound sensor
32  with possible direction and frequency detection and also
33  distance dependence (Not implemented yet)
34  This works, but is not very well tested and documented.
35  The angle detection also works without sound and so on.
36  Take a look at the code before using it.
37  */
38  class SoundSensor: public Sensor {
39  public:
40  /** Segments: for each segement and level we get the
41  Angle: for each level we get a triple (intensity, sin(angle), cos(angle))
42  multiple sound sources are averaged (weighted by intensity)
43  AngleVel: for each level we get a tuple (intensity, angle-velocity)
44  */
46 
47  /** @param dim Up-axis of the robot (sometimes it is not Z)
48  @param measure what to measure @see Measure
49  */
50  SoundSensor(Dimensions dim = Z, Measure measure = Angle,
51  int segments=1, int levels=1, double maxDistance=50, double noisestrength=0.1);
52  virtual ~SoundSensor();
53 
54  virtual void init(Primitive* own, Joint* joint = 0) override { this->own = own;}
55 
56  virtual bool sense(const GlobalData& globaldata) override;
57 
58  /// default implementation is a linear decrease in intensity until it is 0 at maxDistance
59  virtual float distanceDependency(const Sound& s, double distance);
60 
61  virtual int getSensorNumber() const override;
62 
63  virtual std::list<sensor> getList() const override;
64 
65  virtual int get(sensor* sensors, int length) const override;
66 
67  private:
68  short dim; ///< the axis in which the sensor is selective around
69  Measure measure; ///< how to measure
70  int segments;
71  int levels;
72  double maxDistance;
73  double noisestrength;
74 
75  double* val;
76  double* oldangle;
77 
78  Primitive* own;
79 
80  };
81 
82 
83 
84 
85 }
86 
87 #endif /* !SOUNDSENSOR_H_ */
Definition: sensor.h:46
virtual std::list< sensor > getList() const override
returns a list of sensor values (usually in the range [-1,1] ) This function should be overloaded...
Definition: soundsensor.cpp:136
Definition: joint.h:41
double sensor
Definition: types.h:29
Sound sensor with possible direction and frequency detection and also distance dependence (Not implem...
Definition: soundsensor.h:38
Abstract class for sensors that can be plugged into a robot.
Definition: sensor.h:43
virtual int getSensorNumber() const override
returns the number of sensors values produced by this sensor
Definition: soundsensor.cpp:124
Definition: soundsensor.h:45
Interface class for primitives represented in the physical and graphical world.
Definition: primitive.h:80
Data structure holding all essential global information.
Definition: globaldata.h:57
Dimensions
defines which dimensions should be count.
Definition: trackablemeasure.h:42
Measure
Segments: for each segement and level we get the Angle: for each level we get a triple (intensity...
Definition: soundsensor.h:45
Object that represents a sound signal in the simulator.
Definition: sound.h:35
virtual bool sense(const GlobalData &globaldata) override
performs sense action
Definition: soundsensor.cpp:56
virtual ~SoundSensor()
Definition: soundsensor.cpp:47
virtual void init(Primitive *own, Joint *joint=0) override
initialises sensor with a body of robot and optionally with a joint.
Definition: soundsensor.h:54
Definition: soundsensor.h:45
SoundSensor(Dimensions dim=Z, Measure measure=Angle, int segments=1, int levels=1, double maxDistance=50, double noisestrength=0.1)
Definition: soundsensor.cpp:33
virtual float distanceDependency(const Sound &s, double distance)
default implementation is a linear decrease in intensity until it is 0 at maxDistance ...
Definition: soundsensor.cpp:52
Definition: soundsensor.h:45