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
discretisizer.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 DISCRETISIZER_H
25 #define DISCRETISIZER_H
26 
27 /**
28 Use this class to get discrete values.
29 
30 If no intervalCount is set, the count=1.
31 If no intervalRange is set, the range is automatically adjusted.
32 
33 There are three possibilities:
34 1. automaticRange=true
35  --> mapping is always disabled
36 2. automaticRange=false, mapToInterval=true
37  --> real (found) range is mapped to specified range
38 3. automaticRange=false, mapToInterval=false
39  --> no mapping, no range adjustment, values outside the specified
40  range are set to minRange respectively maxRange
41 
42 */
44 public:
45 
46 
47  /**
48  * call this constructor if you don't like to decide which range for
49  * the values are used, therefore the range ist found automatically.
50  *
51  *
52  * Note: The adjustment of the range is enabled, if this method is called.
53  *
54  * @param numberBins the number of bins "created"
55  */
57 
58  /**
59  * call this constructor if you like to decide yourself which range for
60  * the values are used.
61  *
62  * The third parameter decides if the originally range should be completely
63  * mapped to the given interval range. If not, the values outside the given
64  * interval range are set to minRange respectively maxRange.
65  *
66  * Note: The adjustment of the range is disabled, if this method is called.
67  *
68  * @param numberBins the number of bins "created"
69  * @param minRange the minimum of the interval
70  * @param maxRange the maximum of the interval
71  * @param mapToInterval decides if all values are mapped to the given
72  */
73  Discretisizer(int numberBins, double minRange, double maxRange, bool mapToInterval);
74 
75  virtual ~Discretisizer();
76 
77  /**
78  returns the given value as an discretisized integer.
79  this method returns a value between 0...numberbins-1.
80  @param value the value to discretisize
81  @return the bin number
82  */
83  virtual int getBinNumber(double value);
84 
85  /**
86  returns the given value as an discretisized double.
87  this method returns returns a value between minRange and maxRange
88  @param value the value to discretisize
89  @return discretisized value between minRange and maxRange
90  */
91  virtual double get
92  (double value);
93 
94  virtual double getMinRange();
95 
96  virtual double getMaxRange();
97 
98 
99 
100 protected:
103  double minRange;
104  double maxRange;
105  double minValue;
106  double maxValue;
108  bool firstStep;
109 
110 
111  /**
112  is used for automaticRange, sets min and max range.
113  */
114  virtual void findMinAndMaxRange(double value);
115 
116  /**
117  is used for mapToInterval, sets min and max values.
118  */
119  virtual void findMinAndMaxValues(double value);
120 
121  /**
122  is used for discretisizing values
123  */
124  virtual int discretisizeValue(double valueToDiscretisize);
125 
126  virtual int roundValue(double valueToRound);
127 };
128 
129 #endif
virtual void findMinAndMaxValues(double value)
is used for mapToInterval, sets min and max values.
Definition: discretisizer.cpp:79
virtual int roundValue(double valueToRound)
Definition: discretisizer.cpp:113
Discretisizer(int numberBins)
call this constructor if you don't like to decide which range for the values are used, therefore the range ist found automatically.
Definition: discretisizer.cpp:28
virtual ~Discretisizer()
Definition: discretisizer.cpp:40
double minRange
Definition: discretisizer.h:103
virtual double getMinRange()
Definition: discretisizer.cpp:56
virtual int discretisizeValue(double valueToDiscretisize)
is used for discretisizing values
Definition: discretisizer.cpp:92
double maxRange
Definition: discretisizer.h:104
int numberBins
Definition: discretisizer.h:101
bool automaticRange
Definition: discretisizer.h:102
virtual double getMaxRange()
Definition: discretisizer.cpp:60
bool firstStep
Definition: discretisizer.h:108
virtual int getBinNumber(double value)
returns the given value as an discretisized integer.
Definition: discretisizer.cpp:42
double maxValue
Definition: discretisizer.h:106
Use this class to get discrete values.
Definition: discretisizer.h:43
bool mapToInterval
Definition: discretisizer.h:107
virtual void findMinAndMaxRange(double value)
is used for automaticRange, sets min and max range.
Definition: discretisizer.cpp:65
double minValue
Definition: discretisizer.h:105