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
irsensor.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 __IRSENSOR_H
25 #define __IRSENSOR_H
26 
27 #include "raysensor.h"
28 
29 namespace lpzrobots {
30 
31  /** Class for IR sensors.
32  IR sensors are based on distance measurements using the ODE geom class Ray.
33  The sensor value is obtained by collisions, which are handled by the simulation
34  environement. The information of a collision comes to the sensor via the
35  collision callback of the substance used for the ray (actually for the transform).
36  If no collision is detected the value should be zero, so that a stamp is used.
37  The length measured in this way is modified by the 'characteristic' of the IR sensor
38  */
39  class IRSensor : public RaySensor {
40  public:
41  /**
42  @param exponent exponent of the sensor characteritic (default: 1 (linear))
43  @param size size of sensor in simulation
44  @param range maximum range of the IR sensor
45  @param drawMode draw mode of the sensor
46  */
47  IRSensor(double exponent = 1, double size = 0.05, double range = 2,
49 
50  //Override sense to include characteristic
51  virtual bool sense(const GlobalData& globaldata) override;
52 
53  //Override to return value given by characteristic
54  virtual int get(sensor* sensors, int length) const override;
55  virtual std::list<sensor> getList() const override;
56 
57  //Directly return value (needed for backward compatibility
58  virtual double getValue();
59 
60  /// returns the exponent of the sensor characteritic (default: 1 (linear))
61  virtual double getExponent () const { return exponent;}
62 
63  /// sets the exponent of the sensor characteritic (default: 1 (linear))
64  virtual void setExponent (double exp) { exponent = exp;}
65 
66  protected:
67  /** describes the sensor characteritic
68  An exponential curve is used.
69  @see setExponent()
70  */
71  virtual double characteritic(double len);
72 
73  double exponent; // exponent of the sensor characteritic
74 
75  double value; // actual sensor value
76  };
77 
78 }
79 
80 #endif
double len
Definition: raysensor.h:104
virtual double getValue()
Definition: irsensor.cpp:42
IRSensor(double exponent=1, double size=0.05, double range=2, rayDrawMode drawMode=drawSensor)
Definition: irsensor.cpp:28
rayDrawMode
Definition: raysensor.h:56
double sensor
Definition: types.h:29
Class for IR sensors.
Definition: irsensor.h:39
double value
Definition: irsensor.h:75
virtual double characteritic(double len)
describes the sensor characteritic An exponential curve is used.
Definition: irsensor.cpp:56
Data structure holding all essential global information.
Definition: globaldata.h:57
rayDrawMode drawMode
Definition: raysensor.h:102
virtual void setExponent(double exp)
sets the exponent of the sensor characteritic (default: 1 (linear))
Definition: irsensor.h:64
double size
Definition: raysensor.h:100
double range
Definition: raysensor.h:101
virtual bool sense(const GlobalData &globaldata) override
performs sense action
Definition: irsensor.cpp:36
virtual double getExponent() const
returns the exponent of the sensor characteritic (default: 1 (linear))
Definition: irsensor.h:61
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: irsensor.cpp:52
double exponent
Definition: irsensor.h:73
Class for Ray-based sensors.
Definition: raysensor.h:54
Definition: raysensor.h:56