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.20 2006/11/29 16:22:43 martius 00021 * name is a variable of configurable and is used as such 00022 * 00023 * Revision 1.19 2006/07/20 17:14:34 martius 00024 * removed std namespace from matrix.h 00025 * storable interface 00026 * abstract model and invertablemodel as superclasses for networks 00027 * 00028 * Revision 1.18 2006/07/18 15:17:16 martius 00029 * buffer operations like delayed values and smoothed values moved to invertmotorcontroller 00030 * 00031 * Revision 1.17 2006/07/14 12:23:58 martius 00032 * selforg becomes HEAD 00033 * 00034 * Revision 1.15.6.4 2006/07/10 13:05:16 martius 00035 * NON-COMMERICAL LICENSE added to controllers 00036 * 00037 * Revision 1.15.6.3 2006/07/10 11:59:24 martius 00038 * Matrixlib now in selforg 00039 * no namespace std in header files 00040 * 00041 * Revision 1.15.6.2 2006/01/18 16:48:35 martius 00042 * stored and restore 00043 * 00044 * Revision 1.15.6.1 2005/11/14 14:54:30 martius 00045 * cpp file is separate now 00046 * 00047 * Revision 1.15 2005/10/27 15:46:38 martius 00048 * inspectable interface is expanded to structural information for network visualiser 00049 * 00050 * Revision 1.14 2005/10/06 17:08:40 martius 00051 * switched to stl lists 00052 * Bias noise 00053 * correct error_factor for controller learning 00054 * 00055 * Revision 1.13 2005/08/22 20:32:09 martius 00056 * C- initialisation variable 00057 * 00058 * Revision 1.12 2005/08/03 20:31:14 martius 00059 * destructor added 00060 * 00061 * Revision 1.11 2005/07/21 11:33:01 fhesse 00062 * R as internal parameter instead of C 00063 * 00064 * Revision 1.10 2005/07/21 09:40:48 martius 00065 * moved squashing and g to superclass 00066 * 00067 * Revision 1.9 2005/07/05 14:48:18 martius 00068 * desens removed 00069 * zeta update is continuous 00070 * 00071 * Revision 1.8 2005/07/04 15:23:27 martius 00072 * x_smooth used for controller learning 00073 * 00074 * Revision 1.7 2005/06/29 08:30:28 martius 00075 * inherited from invertmotorcontroller 00076 * 00077 * Revision 1.6 2005/06/21 15:31:11 martius 00078 * getSensorNumber and getMotorMumber added controller interface 00079 * 00080 * Revision 1.5 2005/06/20 09:04:16 martius 00081 * init function added to controller-interface 00082 * 00083 * Revision 1.4 2005/06/16 14:23:14 martius 00084 * GPL and name member added 00085 * 00086 ***************************************************************************/ 00087 #ifndef __INVERTMOTORSPACE_H 00088 #define __INVERTMOTORSPACE_H 00089 00090 #include "invertmotorcontroller.h" 00091 #include <assert.h> 00092 #include <math.h> 00093 00094 #include <selforg/matrix.h> 00095 #include <selforg/noisegenerator.h> 00096 00097 /** 00098 * class for robot controller that uses the georg's matrixlib for 00099 * direct matrix inversion for n channels 00100 * (simple one layer networks) 00101 * 00102 * Implements standart parameters: eps, rho, mu, stepnumber4avg, stepnumber4delay 00103 */ 00104 class InvertMotorSpace : public InvertMotorController { 00105 00106 public: 00107 InvertMotorSpace(int buffersize, double cInit = 0.1 , bool someInternalParams = true); 00108 virtual void init(int sensornumber, int motornumber); 00109 00110 virtual ~InvertMotorSpace(); 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

Generated on Tue Jan 16 02:14:36 2007 for Robotsystem of the Robot Group Leipzig by doxygen 1.3.8