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 Class Reference

Sound sensor with possible direction and frequency detection and also distance dependence (Not implemented yet) This works, but is not very well tested and documented. More...

#include <soundsensor.h>

Inheritance diagram for SoundSensor:
Collaboration diagram for SoundSensor:

Public Types

enum  Measure { Segments, Angle, AngleVel }
 Segments: for each segement and level we get the Angle: for each level we get a triple (intensity, sin(angle), cos(angle)) multiple sound sources are averaged (weighted by intensity) AngleVel: for each level we get a tuple (intensity, angle-velocity) More...
 
- Public Types inherited from Sensor
enum  Dimensions {
  X = 1, Y = 2, Z = 4, XY = X | Y,
  XZ = X | Z, YZ = Y | Z, XYZ = X | Y | Z
}
 defines which dimensions should be sensed. The meaning is sensor specific. More...
 
- Public Types inherited from SensorMotorInfoAble
typedef std::function
< std::string(int)> 
NamingFunction
 function that returns the name given the index More...
 

Public Member Functions

 SoundSensor (Dimensions dim=Z, Measure measure=Angle, int segments=1, int levels=1, double maxDistance=50, double noisestrength=0.1)
 
virtual ~SoundSensor ()
 
virtual void init (Primitive *own, Joint *joint=0) override
 initialises sensor with a body of robot and optionally with a joint. More...
 
virtual bool sense (const GlobalData &globaldata) override
 performs sense action More...
 
virtual float distanceDependency (const Sound &s, double distance)
 default implementation is a linear decrease in intensity until it is 0 at maxDistance More...
 
virtual int getSensorNumber () const override
 returns the number of sensors values produced by this sensor More...
 
virtual std::list< sensorgetList () const override
 returns a list of sensor values (usually in the range [-1,1] ) This function should be overloaded. More...
 
virtual int get (sensor *sensors, int length) const override
 writes the sensor values (usually in the range [-1,1] ) into the given sensor array and returns the number of sensors written. More...
 
- Public Member Functions inherited from Sensor
 Sensor ()
 
virtual ~Sensor ()
 
virtual std::list
< SensorMotorInfo
getSensorInfos () const
 returns a list of sensor infos ( More...
 
virtual void update ()
 to update any visual appearance More...
 
std::list< sensorgetListOfArray () const
 helper function for performance implementation of list<> get() based on array-get More...
 
- Public Member Functions inherited from SensorMotorInfoAble
 SensorMotorInfoAble ()
 
void setBaseName (const std::string &basename)
 
void setBaseInfo (const SensorMotorInfo &baseinfo)
 
SensorMotorInfo getBaseInfo ()
 
void setNamingFunc (const NamingFunction &func)
 
NamingFunction getNamingFunc () const
 
void setNames (const std::vector< std::string > &names)
 set names explicitly (basename is anyway suffixed) More...
 
std::string getName (int index) const
 returns the name of a single item. Typically called from within Sensor and Motor class. More...
 
std::list< SensorMotorInfogetInfos (int number) const
 get all infos. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from Sensor
static std::list< sensorselectrows (const matrix::Matrix &m, short dimensions)
 selects the rows specified by dimensions (X->0, Y->1, Z->2) More...
 
static int selectrows (sensor *sensors, int length, const matrix::Matrix &m, short dimensions)
 selects the rows specified by dimensions (X->0, Y->1, Z->2) More...
 
static Dimensions parseSensorDimension (char *str)
 
static std::string dimensions2String (short dimensions)
 
- Static Public Member Functions inherited from SensorMotorInfoAble
static std::string defaultNameing (int index)
 the default implementation is for index==0: basename, otherwise basename + (index+1) More...
 
- Protected Attributes inherited from SensorMotorInfoAble
NamingFunction func
 
SensorMotorInfo baseinfo
 

Detailed Description

Sound sensor with possible direction and frequency detection and also distance dependence (Not implemented yet) This works, but is not very well tested and documented.

The angle detection also works without sound and so on. Take a look at the code before using it.

Member Enumeration Documentation

enum Measure

Segments: for each segement and level we get the Angle: for each level we get a triple (intensity, sin(angle), cos(angle)) multiple sound sources are averaged (weighted by intensity) AngleVel: for each level we get a tuple (intensity, angle-velocity)

Enumerator
Segments 
Angle 
AngleVel 

Constructor & Destructor Documentation

SoundSensor ( Dimensions  dim = Z,
Measure  measure = Angle,
int  segments = 1,
int  levels = 1,
double  maxDistance = 50,
double  noisestrength = 0.1 
)
Parameters
dimUp-axis of the robot (sometimes it is not Z)
measurewhat to measure
See Also
Measure
~SoundSensor ( )
virtual

Member Function Documentation

float distanceDependency ( const Sound s,
double  distance 
)
virtual

default implementation is a linear decrease in intensity until it is 0 at maxDistance

int get ( sensor sensors,
int  length 
) const
overridevirtual

writes the sensor values (usually in the range [-1,1] ) into the given sensor array and returns the number of sensors written.

A default implementation based on get() is provided. Only if performance matters overwrite this function.

Parameters
sensorscall by refernce array which received the values
lengthcapacity of sensors array
Returns
number of sensor values written

Reimplemented from Sensor.

std::list< sensor > getList ( ) const
overridevirtual

returns a list of sensor values (usually in the range [-1,1] ) This function should be overloaded.

If performance matters, implement get(double*, int) and use getListOfArray to implement this.

Implements Sensor.

int getSensorNumber ( ) const
overridevirtual

returns the number of sensors values produced by this sensor

Implements Sensor.

virtual void init ( Primitive own,
Joint joint = 0 
)
inlineoverridevirtual

initialises sensor with a body of robot and optionally with a joint.

This is usually done by the robot itself (or using the Attachment())

Implements Sensor.

bool sense ( const GlobalData globaldata)
overridevirtual

performs sense action

Implements Sensor.


The documentation for this class was generated from the following files: