dinvert3channelcontroller.h

Go to the documentation of this file.
00001 /* 00002 * LICENSE: * 00003 * This work is licensed under the Creative Commons * 00004 * Attribution-NonCommercial-ShareAlike 2.5 License. To view a copy of * 00005 * this license, visit http://creativecommons.org/licenses/by-nc-sa/2.5/ * 00006 * or send a letter to Creative Commons, 543 Howard Street, 5th Floor, * 00007 * San Francisco, California, 94105, USA. * 00008 * * 00009 * This program is distributed in the hope that it will be useful, * 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * 00012 */ 00013 00014 #ifndef __DINVERT3CHANNELCONTROLLER_H 00015 #define __DINVERT3CHANNELCONTROLLER_H 00016 00017 #include "invertcontroller.h" 00018 00019 #include <assert.h> 00020 #include <math.h> 00021 00022 00023 /** 00024 * class for robot controller that use naglaa's direct matrix inversion for n channels 00025 * (simple one layer networks) 00026 * 00027 * Implements standart parameters: eps, rho, mu, stepnumber4avg, stepnumber4delay 00028 */ 00029 class DInvert3ChannelController : public InvertController { 00030 00031 public: 00032 00033 /* 00034 Invert3ChannelController(); 00035 00036 //virtual ~Invert3ChannelController(){} 00037 00038 00039 /// performs one step (includes learning). Calulates motor commands from sensor inputs. 00040 virtual void step(const sensor*, motor*); 00041 00042 /// performs one step without learning. Calulates motor commands from sensor inputs. 00043 virtual void stepNoLearning(const sensor*, motor*); 00044 */ 00045 00046 00047 protected: 00048 int NUMBER_CHANNELS; 00049 int BUFFER_SIZE; 00050 00051 double* x_smooth; 00052 double* x_effective; 00053 double* y_effective; 00054 double** Q_buf1; 00055 double** Q_buf2; 00056 double** L; 00057 double* z; 00058 00059 public: 00060 double** A; ///< model matrix 00061 double** C; ///< controller matrix 00062 double* h; ///< bias vector 00063 00064 double** x_buffer; ///< buffer for input values, x[t%buffersize]=actual value, x[(t-1+buffersize)%buffersize]=x(t-1) 00065 double** y_buffer; ///< buffer for output values, y[t%buffersize]=actual value(if already calculated!), y[(t-1+buffersize)%buffersize]=y(t-1) 00066 00067 double* xsi4E; 00068 double* xsi4Model; 00069 00070 int t; ///< number of steps, needed for ringbuffer x_buffer 00071 char name[50]; 00072 00073 00074 /* 00075 virtual void inverseMatrix(double Q[NUMBER_CHANNELS][NUMBER_CHANNELS], double Q_1[NUMBER_CHANNELS][NUMBER_CHANNELS]); 00076 00077 virtual double calculateE(double *x_delay, double *y_delay); 00078 00079 /// learn values h,C //,A 00080 virtual void learn(double *x_delay, double *y_delay); 00081 00082 /// learn model parameter (matrix A) by gradient descent 00083 virtual void learnModel(double *x_actual, double *y_effective); 00084 00085 00086 /// calculate delayed values 00087 virtual void calculateDelayedValues(double source[BUFFER_SIZE][NUMBER_CHANNELS], int number_steps_of_delay_, double *target); 00088 00089 virtual void calculateSmoothValues(double source[BUFFER_SIZE][NUMBER_CHANNELS], int number_steps_for_averaging_, double *target); 00090 00091 /// calculate controller ouptus 00092 virtual void calculateControllerValues(double *x_smooth, double *y); 00093 00094 // put new value in ring buffer 00095 virtual void putInBuffer(double buffer[BUFFER_SIZE][NUMBER_CHANNELS], double *values); 00096 00097 */ 00098 /// neuron transfer function 00099 virtual double g(double z) 00100 { 00101 return tanh(z); 00102 }; 00103 00104 00105 /// 00106 virtual double g_s(double z) 00107 { 00108 double k=tanh(z); 00109 return 1.0 - k*k; 00110 // return 1.0 - tanh(z)*tanh(z); 00111 }; 00112 00113 /// squashing function, to protect against to large weight updates 00114 virtual double squash(double z) 00115 { 00116 return z < -0.1 ? -0.1 : ( z > 0.1 ? 0.1 : z ); 00117 //return 0.1 * tanh(10.0 * z); 00118 }; 00119 00120 00121 #include "dinvert3channelcontroller.hpp" 00122 00123 }; 00124 00125 #endif

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