measureadapter.h

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

Generated on Tue Sep 16 22:00:22 2008 for Robotsystem of the Robot Group Leipzig by  doxygen 1.4.7