Robotsystem from Robot Group Leipzig: invertmotorspace.h Source File

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

- 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  *   This program is free software; you can redistribute it and/or modify  *
    00008  *   it under the terms of the GNU General Public License as published by  *
    00009  *   the Free Software Foundation; either version 2 of the License, or     *
    00010  *   (at your option) any later version.                                   *
    00011  *                                                                         *
    00012  *   This program is distributed in the hope that it will be useful,       *
    00013  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
    00014  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
    00015  *   GNU General Public License for more details.                          *
    00016  *                                                                         *
    00017  *   You should have received a copy of the GNU General Public License     *
    00018  *   along with this program; if not, write to the                         *
    00019  *   Free Software Foundation, Inc.,                                       *
    00020  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
    00021  *                                                                         *
    00022  *   $Log: invertmotorspace.h,v $
    00023  *   Revision 1.15.6.2  2006/01/18 16:48:35  martius
    00024  *   stored and restore
    00025  *
    00026  *   Revision 1.15.6.1  2005/11/14 14:54:30  martius
    00027  *   cpp file is separate now
    00028  *
    00029  *   Revision 1.15  2005/10/27 15:46:38  martius
    00030  *   inspectable interface is expanded to structural information for network visualiser
    00031  *
    00032  *   Revision 1.14  2005/10/06 17:08:40  martius
    00033  *   switched to stl lists
    00034  *   Bias noise
    00035  *   correct error_factor for controller learning
    00036  *
    00037  *   Revision 1.13  2005/08/22 20:32:09  martius
    00038  *   C- initialisation variable
    00039  *
    00040  *   Revision 1.12  2005/08/03 20:31:14  martius
    00041  *   destructor added
    00042  *
    00043  *   Revision 1.11  2005/07/21 11:33:01  fhesse
    00044  *   R as internal parameter instead of C
    00045  *
    00046  *   Revision 1.10  2005/07/21 09:40:48  martius
    00047  *   moved squashing and g to superclass
    00048  *
    00049  *   Revision 1.9  2005/07/05 14:48:18  martius
    00050  *   desens removed
    00051  *   zeta update is continuous
    00052  *
    00053  *   Revision 1.8  2005/07/04 15:23:27  martius
    00054  *   x_smooth used for controller learning
    00055  *
    00056  *   Revision 1.7  2005/06/29 08:30:28  martius
    00057  *   inherited from invertmotorcontroller
    00058  *
    00059  *   Revision 1.6  2005/06/21 15:31:11  martius
    00060  *   getSensorNumber and getMotorMumber added controller interface
    00061  *
    00062  *   Revision 1.5  2005/06/20 09:04:16  martius
    00063  *   init function added to controller-interface
    00064  *
    00065  *   Revision 1.4  2005/06/16 14:23:14  martius
    00066  *   GPL and name member added
    00067  *
    00068  ***************************************************************************/
    00069 #ifndef __INVERTMOTORSPACE_H
    00070 #define __INVERTMOTORSPACE_H
    00071
    00072 #include "invertmotorcontroller.h"
    00073 #include <assert.h>
    00074 #include <math.h>
    00075
    00076 #include "matrix.h"
    00077 using namespace matrix;
    00078 #include "noisegenerator.h"
    00079
    00080 /**
    00081  * class for robot controller that uses the georg's matrixlib for
    00082  *  direct matrix inversion for n channels
    00083  * (simple one layer networks)
    00084  *
    00085  * Implements standart parameters: eps, rho, mu, stepnumber4avg, stepnumber4delay
    00086  */
    00087 class InvertMotorSpace : public InvertMotorController {
    00088
    00089 public:
    00090   InvertMotorSpace(int buffersize, double cInit = 0.1 , bool someInternalParams = true);
    00091   virtual void init(int sensornumber, int motornumber);
    00092
    00093   virtual ~InvertMotorSpace();
    00094
    00095   /// return the name of the object (with version number) Hint: use insertCVSInfo from Configurable
    00096   virtual paramkey getName() const { return name; }
    00097
    00098   /// returns the number of sensors the controller was initialised with or 0 if not initialised
    00099   virtual int getSensorNumber() const { return number_sensors; }
    00100   /// returns the mumber of motors the controller was initialised with or 0 if not initialised
    00101   virtual int getMotorNumber() const  { return number_motors; }
    00102
    00103   /// performs one step (includes learning).
    00104   /// Calulates motor commands from sensor inputs.
    00105   virtual void step(const sensor* , int number_sensors, motor* , int number_motors);
    00106
    00107   /// performs one step without learning. Calulates motor commands from sensor inputs.
    00108   virtual void stepNoLearning(const sensor* , int number_sensors,
    00109                               motor* , int number_motors);
    00110
    00111   /** stores the controller values to a given file. */
    00112   virtual bool store(const char* filename);
    00113   /** loads the controller values from a given file. */
    00114   virtual bool restore(const char* filename);
    00115
    00116   // inspectable interface
    00117   virtual list<iparamkey> getInternalParamNames() const;
    00118   virtual list<iparamval> getInternalParams() const;
    00119   virtual list<ILayer> getStructuralLayers() const;
    00120   virtual list<IConnection> getStructuralConnections() const;
    00121
    00122
    00123 protected:
    00124   unsigned short number_sensors;
    00125   unsigned short number_motors;
    00126
    00127   Matrix A; // Model Matrix
    00128   Matrix C; // Controller Matrix
    00129   Matrix R; // C*A
    00130   Matrix H; // Controller Bias
    00131   Matrix B; // Model Bias
    00132   NoiseGenerator* BNoiseGen; // Noisegenerator for noisy bias
    00133   Matrix* x_buffer;
    00134   Matrix* y_buffer;
    00135   Matrix x_smooth;
    00136
    00137   bool someInternalParams;
    00138   double cInit;
    00139
    00140   /// puts the sensors in the ringbuffer, generate controller values and put them in the
    00141   //  ringbuffer as well
    00142   void fillBuffersAndControl(const sensor* x_, int number_sensors,
    00143                              motor* y_, int number_motors);
    00144
    00145   /// learn h,C, delayed motors y and corresponding sensors x
    00146   virtual void learnController(const Matrix& x, const Matrix& x_smooth, int delay);
    00147
    00148   /// learn A, using motors y and corresponding sensors x
    00149   virtual void learnModel( const Matrix& x, const Matrix& y);
    00150
    00151   /// calculate delayed values
    00152   virtual Matrix calculateDelayedValues(const Matrix* buffer,
    00153                                         int number_steps_of_delay_);
    00154   virtual Matrix calculateSmoothValues(const Matrix* buffer,
    00155                                        int number_steps_for_averaging_);
    00156
    00157   Matrix calculateControllerValues(const Matrix& x_smooth);
    00158
    00159 };
    00160
    00161 #endif