00001 /*************************************************************************** 00002 * Copyright (C) 2005 by Robot Group Leipzig * 00003 * martius@informatik.uni-leipzig.de * 00004 * fhesse@informatik.uni-leipzig.de * 00005 * der@informatik.uni-leipzig.de * 00006 * guettler@informatik.uni-leipzig.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 * $Log: measureadapter.h,v $ 00024 * Revision 1.3 2009/08/10 07:40:27 guettler 00025 * uses new BackCaller implementation 00026 * 00027 * Revision 1.2 2008/04/17 14:54:45 martius 00028 * randomGen added, which is a random generator with long period and an 00029 * internal state. Each Agent has an instance and passed it to the controller 00030 * and the wiring. This is good for 00031 * a) repeatability on agent basis, 00032 * b) parallel execution as done in ode_robots 00033 * 00034 * Revision 1.1 2008/01/17 10:04:04 der 00035 * first version 00036 * 00037 * 00038 * * 00039 ***************************************************************************/ 00040 #ifndef __MEASUREADAPTER_H 00041 #define __MEASUREADAPTER_H 00042 00043 #include "abstractcontrolleradapter.h" 00044 #include "backcaller.h" 00045 #include "statistictools.h" 00046 #include "complexmeasure.h" 00047 00048 // begin forward declaration 00049 // end forward declaration 00050 00051 /** 00052 * This is a passive controller adapter who is passive and can handle AbstractMeasures. 00053 * Normally the sensor and/or motor values are measured. 00054 * @see AbstractControllerAdapter 00055 */ 00056 class MeasureAdapter : public AbstractControllerAdapter, public BackCaller 00057 { 00058 00059 public: 00060 00061 /** 00062 * Constructs the MeasureAdapter. 00063 * 00064 */ 00065 MeasureAdapter(AbstractController* controller); 00066 00067 virtual ~MeasureAdapter(); 00068 00069 /** 00070 * Adds a ComplexMeasure for measuring sensor values. For each 00071 * sensor a ComplexMeasure is created. 00072 */ 00073 virtual std::list<ComplexMeasure*> addSensorComplexMeasure(char* measureName, ComplexMeasureMode mode,int numberBins, int stepSize); 00074 00075 /****************************************************************************/ 00076 /* BEGIN methods of AbstractController */ 00077 /****************************************************************************/ 00078 00079 /** initialisation of the controller with the given sensor/ motornumber 00080 * Must NORMALLY be called before use. For all ControllerAdapters 00081 * call first AbstractControllerAdapter::init(sensornumber,motornumber) 00082 * if you overwrite this method 00083 */ 00084 virtual void init(int sensornumber, int motornumber, RandGen* randGen = 0); 00085 00086 /** performs one step (includes learning). 00087 Calculates motor commands from sensor inputs. 00088 @param sensors sensors inputs scaled to [-1,1] 00089 @param sensornumber length of the sensor array 00090 @param motors motors outputs. MUST have enough space for motor values! 00091 @param motornumber length of the provided motor array 00092 */ 00093 virtual void step(const sensor* sensors, int sensornumber, 00094 motor* motors, int motornumber); 00095 00096 /** performs one step without learning. 00097 @see step 00098 */ 00099 virtual void stepNoLearning(const sensor* sensors , int sensornumber, 00100 motor* motors, int motornumber); 00101 00102 /****************************************************************************/ 00103 /* END methods of AbstractController */ 00104 /****************************************************************************/ 00105 00106 /****************************************************************************/ 00107 /* BEGIN methods of Storeable */ 00108 /****************************************************************************/ 00109 00110 /** stores the object to the given file stream (binary). 00111 */ 00112 virtual bool store(FILE* f) const; 00113 00114 /** loads the object from the given file stream (binary). 00115 */ 00116 virtual bool restore(FILE* f); 00117 00118 /****************************************************************************/ 00119 /* END methods of Storeable */ 00120 /****************************************************************************/ 00121 00122 /****************************************************************************/ 00123 /* BEGIN methods of Inspectable */ 00124 /****************************************************************************/ 00125 00126 /** The list of the names of all internal parameters given by getInternalParams(). 00127 The naming convention is "v[i]" for vectors 00128 and "A[i][j]" for matrices, where i, j start at 0. 00129 @return: list of keys 00130 */ 00131 virtual iparamkeylist getInternalParamNames() const; 00132 00133 /** @return: list of values 00134 */ 00135 virtual iparamvallist getInternalParams() const; 00136 00137 /****************************************************************************/ 00138 /* END methods of Inspectable */ 00139 /****************************************************************************/ 00140 00141 00142 00143 protected: 00144 StatisticTools* st; 00145 bool initialized; 00146 motor* motorValues; 00147 sensor* sensorValues; 00148 00149 }; 00150 00151 #endif