Robotsystem of the Robot Group Leipzig: invertmotorspace.h Source File

- Main Page
- Namespaces
- Classes
- Files
- Directories
- Examples

- Search for |

- File List
- File Members

# invertmotorspace.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  *                                                                         *
    00007  *   ANY COMMERCIAL USE FORBIDDEN!                                         *
    00008  *   LICENSE:                                                              *
    00009  *   This work is licensed under the Creative Commons                      *
    00010  *   Attribution-NonCommercial-ShareAlike 2.5 License. To view a copy of   *
    00011  *   this license, visit http://creativecommons.org/licenses/by-nc-sa/2.5/ *
    00012  *   or send a letter to Creative Commons, 543 Howard Street, 5th Floor,   *
    00013  *   San Francisco, California, 94105, USA.                                *
    00014  *                                                                         *
    00015  *   This program is distributed in the hope that it will be useful,       *
    00016  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
    00017  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                  *
    00018  *                                                                         *
    00019  *   $Log: invertmotorspace.h,v $
    00020  *   Revision 1.19  2006/07/20 17:14:34  martius
    00021  *   removed std namespace from matrix.h
    00022  *   storable interface
    00023  *   abstract model and invertablemodel as superclasses for networks
    00024  *
    00025  *   Revision 1.18  2006/07/18 15:17:16  martius
    00026  *   buffer operations like delayed values and smoothed values moved to invertmotorcontroller
    00027  *
    00028  *   Revision 1.17  2006/07/14 12:23:58  martius
    00029  *   selforg becomes HEAD
    00030  *
    00031  *   Revision 1.15.6.4  2006/07/10 13:05:16  martius
    00032  *   NON-COMMERICAL LICENSE added to controllers
    00033  *
    00034  *   Revision 1.15.6.3  2006/07/10 11:59:24  martius
    00035  *   Matrixlib now in selforg
    00036  *   no namespace std in header files
    00037  *
    00038  *   Revision 1.15.6.2  2006/01/18 16:48:35  martius
    00039  *   stored and restore
    00040  *
    00041  *   Revision 1.15.6.1  2005/11/14 14:54:30  martius
    00042  *   cpp file is separate now
    00043  *
    00044  *   Revision 1.15  2005/10/27 15:46:38  martius
    00045  *   inspectable interface is expanded to structural information for network visualiser
    00046  *
    00047  *   Revision 1.14  2005/10/06 17:08:40  martius
    00048  *   switched to stl lists
    00049  *   Bias noise
    00050  *   correct error_factor for controller learning
    00051  *
    00052  *   Revision 1.13  2005/08/22 20:32:09  martius
    00053  *   C- initialisation variable
    00054  *
    00055  *   Revision 1.12  2005/08/03 20:31:14  martius
    00056  *   destructor added
    00057  *
    00058  *   Revision 1.11  2005/07/21 11:33:01  fhesse
    00059  *   R as internal parameter instead of C
    00060  *
    00061  *   Revision 1.10  2005/07/21 09:40:48  martius
    00062  *   moved squashing and g to superclass
    00063  *
    00064  *   Revision 1.9  2005/07/05 14:48:18  martius
    00065  *   desens removed
    00066  *   zeta update is continuous
    00067  *
    00068  *   Revision 1.8  2005/07/04 15:23:27  martius
    00069  *   x_smooth used for controller learning
    00070  *
    00071  *   Revision 1.7  2005/06/29 08:30:28  martius
    00072  *   inherited from invertmotorcontroller
    00073  *
    00074  *   Revision 1.6  2005/06/21 15:31:11  martius
    00075  *   getSensorNumber and getMotorMumber added controller interface
    00076  *
    00077  *   Revision 1.5  2005/06/20 09:04:16  martius
    00078  *   init function added to controller-interface
    00079  *
    00080  *   Revision 1.4  2005/06/16 14:23:14  martius
    00081  *   GPL and name member added
    00082  *
    00083  ***************************************************************************/
    00084 #ifndef __INVERTMOTORSPACE_H
    00085 #define __INVERTMOTORSPACE_H
    00086
    00087 #include "invertmotorcontroller.h"
    00088 #include <assert.h>
    00089 #include <math.h>
    00090
    00091 #include <selforg/matrix.h>
    00092 #include <selforg/noisegenerator.h>
    00093
    00094 /**
    00095  * class for robot controller that uses the georg's matrixlib for
    00096  *  direct matrix inversion for n channels
    00097  * (simple one layer networks)
    00098  *
    00099  * Implements standart parameters: eps, rho, mu, stepnumber4avg, stepnumber4delay
    00100  */
    00101 class InvertMotorSpace : public InvertMotorController {
    00102
    00103 public:
    00104   InvertMotorSpace(int buffersize, double cInit = 0.1 , bool someInternalParams = true);
    00105   virtual void init(int sensornumber, int motornumber);
    00106
    00107   virtual ~InvertMotorSpace();
    00108
    00109   /// return the name of the object (with version number) Hint: use insertCVSInfo from Configurable
    00110   virtual paramkey getName() const { return name; }
    00111
    00112   /// returns the number of sensors the controller was initialised with or 0 if not initialised
    00113   virtual int getSensorNumber() const { return number_sensors; }
    00114   /// returns the mumber of motors the controller was initialised with or 0 if not initialised
    00115   virtual int getMotorNumber() const  { return number_motors; }
    00116
    00117   /// performs one step (includes learning).
    00118   /// Calulates motor commands from sensor inputs.
    00119   virtual void step(const sensor* , int number_sensors, motor* , int number_motors);
    00120
    00121   /// performs one step without learning. Calulates motor commands from sensor inputs.
    00122   virtual void stepNoLearning(const sensor* , int number_sensors,
    00123                               motor* , int number_motors);
    00124
    00125   /**** STOREABLE ****/
    00126   /** stores the controller values to a given file (binary).  */
    00127   virtual bool store(FILE* f) const;
    00128   /** loads the controller values from a given file (binary). */
    00129   virtual bool restore(FILE* f);
    00130
    00131   // inspectable interface
    00132   virtual std::list<iparamkey> getInternalParamNames() const;
    00133   virtual std::list<iparamval> getInternalParams() const;
    00134   virtual std::list<ILayer> getStructuralLayers() const;
    00135   virtual std::list<IConnection> getStructuralConnections() const;
    00136
    00137
    00138 protected:
    00139   unsigned short number_sensors;
    00140   unsigned short number_motors;
    00141
    00142   matrix::Matrix A; // Model Matrix
    00143   matrix::Matrix C; // Controller Matrix
    00144   matrix::Matrix R; // C*A
    00145   matrix::Matrix H; // Controller Bias
    00146   matrix::Matrix B; // Model Bias
    00147   NoiseGenerator* BNoiseGen; // Noisegenerator for noisy bias
    00148   matrix::Matrix* x_buffer;
    00149   matrix::Matrix* y_buffer;
    00150   matrix::Matrix x_smooth;
    00151
    00152   bool someInternalParams;
    00153   double cInit;
    00154
    00155   /// puts the sensors in the ringbuffer, generate controller values and put them in the
    00156   //  ringbuffer as well
    00157   void fillBuffersAndControl(const sensor* x_, int number_sensors,
    00158                              motor* y_, int number_motors);
    00159
    00160   /// learn h,C, delayed motors y and corresponding sensors x
    00161   virtual void learnController(const matrix::Matrix& x, const matrix::Matrix& x_smooth, int delay);
    00162
    00163   /// learn A, using motors y and corresponding sensors x
    00164   virtual void learnModel( const matrix::Matrix& x, const matrix::Matrix& y);
    00165
    00166   /// returns controller output for given sensor values
    00167   virtual matrix::Matrix calculateControllerValues(const matrix::Matrix& x_smooth);
    00168
    00169 };
    00170
    00171 #endif