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 __MEASUREADAPTER_H 00025 #define __MEASUREADAPTER_H 00026 00027 #include "abstractcontrolleradapter.h" 00028 #include "backcaller.h" 00029 #include "statistictools.h" 00030 #include "complexmeasure.h" 00031 00032 // begin forward declaration 00033 // end forward declaration 00034 00035 /** 00036 * This is a passive controller adapter who is passive and can handle AbstractMeasures. 00037 * Normally the sensor and/or motor values are measured. 00038 * @see AbstractControllerAdapter 00039 */ 00040 class MeasureAdapter : public AbstractControllerAdapter 00041 { 00042 00043 public: 00044 00045 /** 00046 * Constructs the MeasureAdapter. 00047 * 00048 */ 00049 MeasureAdapter(AbstractController* controller, const std::string& name = "MeasureAdapter", const std::string& revision = "$ID$"); 00050 00051 virtual ~MeasureAdapter(); 00052 00053 /** 00054 * Adds a ComplexMeasure for measuring sensor values. For each 00055 * sensor a ComplexMeasure is created. 00056 */ 00057 virtual std::list<ComplexMeasure*> addSensorComplexMeasure(char* measureName, ComplexMeasureMode mode,int numberBins, int stepSize); 00058 00059 /****************************************************************************/ 00060 /* BEGIN methods of AbstractController */ 00061 /****************************************************************************/ 00062 00063 /** initialisation of the controller with the given sensor/ motornumber 00064 * Must NORMALLY be called before use. For all ControllerAdapters 00065 * call first AbstractControllerAdapter::init(sensornumber,motornumber) 00066 * if you overwrite this method 00067 */ 00068 virtual void init(int sensornumber, int motornumber, RandGen* randGen = 0); 00069 00070 /** performs one step (includes learning). 00071 Calculates motor commands from sensor inputs. 00072 @param sensors sensors inputs scaled to [-1,1] 00073 @param sensornumber length of the sensor array 00074 @param motors motors outputs. MUST have enough space for motor values! 00075 @param motornumber length of the provided motor array 00076 */ 00077 virtual void step(const sensor* sensors, int sensornumber, 00078 motor* motors, int motornumber); 00079 00080 /** performs one step without learning. 00081 @see step 00082 */ 00083 virtual void stepNoLearning(const sensor* sensors , int sensornumber, 00084 motor* motors, int motornumber); 00085 00086 /****************************************************************************/ 00087 /* END methods of AbstractController */ 00088 /****************************************************************************/ 00089 00090 /****************************************************************************/ 00091 /* BEGIN methods of Storeable */ 00092 /****************************************************************************/ 00093 00094 /****************************************************************************/ 00095 /* END methods of Storeable */ 00096 /****************************************************************************/ 00097 00098 /****************************************************************************/ 00099 /* BEGIN methods of Inspectable */ 00100 /****************************************************************************/ 00101 00102 // nothing to overwrite 00103 00104 /****************************************************************************/ 00105 /* END methods of Inspectable */ 00106 /****************************************************************************/ 00107 00108 00109 virtual StatisticTools* getStatisticTools() { return st; } 00110 00111 protected: 00112 StatisticTools* st; 00113 bool initialized; 00114 motor* motorValues; 00115 sensor* sensorValues; 00116 00117 }; 00118 00119 #endif