Robot Simulator of the Robotics Group for Self-Organization of Control: discretisizer.h Source File

# discretisizer.h

Go to the documentation of this file.

    00001 /***************************************************************************
    00002  *   Copyright (C) 2005-2011 LpzRobots development team                    *
    00003  *    Georg Martius  <georg dot martius at web dot de>                     *
    00004  *    Frank Guettler <guettler at informatik dot uni-leipzig dot de        *
    00005  *    Frank Hesse    <frank at nld dot ds dot mpg dot de>                  *
    00006  *    Ralf Der       <ralfder at mis dot mpg dot de>                       *
    00007  *                                                                         *
    00008  *   This program is free software; you can redistribute it and/or modify  *
    00009  *   it under the terms of the GNU General Public License as published by  *
    00010  *   the Free Software Foundation; either version 2 of the License, or     *
    00011  *   (at your option) any later version.                                   *
    00012  *                                                                         *
    00013  *   This program is distributed in the hope that it will be useful,       *
    00014  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
    00015  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
    00016  *   GNU General Public License for more details.                          *
    00017  *                                                                         *
    00018  *   You should have received a copy of the GNU General Public License     *
    00019  *   along with this program; if not, write to the                         *
    00020  *   Free Software Foundation, Inc.,                                       *
    00021  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
    00022  *                                                                         *
    00023  ***************************************************************************/
    00024 #ifndef DISCRETISIZER_H
    00025 #define DISCRETISIZER_H
    00026
    00027 /**
    00028 Use this class to get discrete values.
    00029
    00030 If no intervalCount is set, the count=1.
    00031 If no intervalRange is set, the range is automatically adjusted.
    00032
    00033 There are three possibilities:
    00034 1. automaticRange=true
    00035  --> mapping is always disabled
    00036 2. automaticRange=false, mapToInterval=true
    00037  --> real (found) range is mapped to specified range
    00038 3. automaticRange=false, mapToInterval=false
    00039  --> no mapping, no range adjustment, values outside the specified
    00040      range are set to minRange respectively maxRange
    00041
    00042 */
    00043 class Discretisizer {
    00044 public:
    00045
    00046
    00047     /**
    00048     * call this constructor if you don't like to decide which range for
    00049     * the values are used, therefore the range ist found automatically.
    00050     *
    00051     *
    00052     * Note: The adjustment of the range is enabled, if this method is called.
    00053     *
    00054     * @param numberBins the number of bins "created"
    00055     */
    00056     Discretisizer(int numberBins);
    00057
    00058     /**
    00059     * call this constructor if you like to decide yourself which range for
    00060     * the values are used.
    00061     *
    00062     * The third parameter decides if the originally range should be completely
    00063     * mapped to the given interval range. If not, the values outside the given
    00064     * interval range are set to minRange respectively maxRange.
    00065     *
    00066     * Note: The adjustment of the range is disabled, if this method is called.
    00067     *
    00068     * @param numberBins the number of bins "created"
    00069     * @param minRange the minimum of the interval
    00070     * @param maxRange the maximum of the interval
    00071     * @param mapToInterval decides if all values are mapped to the given
    00072     */
    00073   Discretisizer(int numberBins, double minRange, double maxRange, bool mapToInterval);
    00074
    00075     virtual ~Discretisizer();
    00076
    00077     /**
    00078       returns the given value as an discretisized integer.
    00079       this method returns a value between 0...numberbins-1.
    00080       @param value the value to discretisize
    00081       @return the bin number
    00082     */
    00083     virtual int getBinNumber(double value);
    00084
    00085     /**
    00086       returns the given value as an discretisized double.
    00087       this method returns returns a value between minRange and maxRange
    00088       @param value the value to discretisize
    00089       @return discretisized value between minRange and maxRange
    00090     */
    00091     virtual double get
    00092         (double value);
    00093
    00094     virtual double getMinRange();
    00095
    00096     virtual double getMaxRange();
    00097
    00098
    00099
    00100 protected:
    00101     int numberBins;
    00102     bool automaticRange;
    00103     double minRange;
    00104     double maxRange;
    00105     double minValue;
    00106     double maxValue;
    00107     bool mapToInterval;
    00108     bool firstStep;
    00109
    00110
    00111     /**
    00112     is used for automaticRange, sets min and max range.
    00113     */
    00114     virtual void findMinAndMaxRange(double value);
    00115
    00116     /**
    00117     is used for mapToInterval, sets min and max values.
    00118     */
    00119     virtual void findMinAndMaxValues(double value);
    00120
    00121     /**
    00122     is used for discretisizing values
    00123     */
    00124     virtual int discretisizeValue(double valueToDiscretisize);
    00125
    00126     virtual int roundValue(double valueToRound);
    00127 };
    00128
    00129 #endif