Robot Simulator of the Robotics Group for Self-Organization of Control  0.8.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
dinvert3channelcontroller.h
Go to the documentation of this file.
1 /*
2  * LICENSE: *
3  * This work is licensed under the Creative Commons *
4  * Attribution-NonCommercial-ShareAlike 2.5 License. To view a copy of *
5  * this license, visit http://creativecommons.org/licenses/by-nc-sa/2.5/ *
6  * or send a letter to Creative Commons, 543 Howard Street, 5th Floor, *
7  * San Francisco, California, 94105, USA. *
8  * *
9  * This program is distributed in the hope that it will be useful, *
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
12  */
13 
14 #ifndef __DINVERT3CHANNELCONTROLLER_H
15 #define __DINVERT3CHANNELCONTROLLER_H
16 
17 #include "invertcontroller.h"
18 
19 #include <assert.h>
20 #include <cmath>
21 
22 
23 /**
24  * class for robot controller that use naglaa's direct matrix inversion for n channels
25  * (simple one layer networks)
26  *
27  * Implements standart parameters: eps, rho, mu, stepnumber4avg, stepnumber4delay
28  */
30 
31 public:
32 
33  /*
34  Invert3ChannelController();
35 
36  //virtual ~Invert3ChannelController(){}
37 
38 
39  /// performs one step (includes learning). Calulates motor commands from sensor inputs.
40  virtual void step(const sensor*, motor*);
41 
42  /// performs one step without learning. Calulates motor commands from sensor inputs.
43  virtual void stepNoLearning(const sensor*, motor*);
44  */
45 
46 
47 protected:
50 
51  double* x_smooth;
52  double* x_effective;
53  double* y_effective;
54  double** Q_buf1;
55  double** Q_buf2;
56  double** L;
57  double* z;
58 
59 public:
60  double** A; ///< model matrix
61  double** C; ///< controller matrix
62  double* h; ///< bias vector
63 
64  double** x_buffer; ///< buffer for input values, x[t%buffersize]=actual value, x[(t-1+buffersize)%buffersize]=x(t-1)
65  double** y_buffer; ///< buffer for output values, y[t%buffersize]=actual value(if already calculated!), y[(t-1+buffersize)%buffersize]=y(t-1)
66 
67  double* xsi4E;
68  double* xsi4Model;
69 
70  int t; ///< number of steps, needed for ringbuffer x_buffer
71  char name[50];
72 
73 
74  /*
75  virtual void inverseMatrix(double Q[NUMBER_CHANNELS][NUMBER_CHANNELS], double Q_1[NUMBER_CHANNELS][NUMBER_CHANNELS]);
76 
77  virtual double calculateE(double *x_delay, double *y_delay);
78 
79  /// learn values h,C //,A
80  virtual void learn(double *x_delay, double *y_delay);
81 
82  /// learn model parameter (matrix A) by gradient descent
83  virtual void learnModel(double *x_actual, double *y_effective);
84 
85 
86  /// calculate delayed values
87  virtual void calculateDelayedValues(double source[BUFFER_SIZE][NUMBER_CHANNELS], int number_steps_of_delay_, double *target);
88 
89  virtual void calculateSmoothValues(double source[BUFFER_SIZE][NUMBER_CHANNELS], int number_steps_for_averaging_, double *target);
90 
91  /// calculate controller ouptus
92  virtual void calculateControllerValues(double *x_smooth, double *y);
93 
94  // put new value in ring buffer
95  virtual void putInBuffer(double buffer[BUFFER_SIZE][NUMBER_CHANNELS], double *values);
96 
97  */
98  /// neuron transfer function
99  virtual double g(double z)
100  {
101  return tanh(z);
102  };
103 
104 
105  ///
106  virtual double g_s(double z)
107  {
108  /* double k=tanh(z); */
109 /* return 1.0 - k*k; */
110  // return 1.0 - tanh(z)*tanh(z);
111  cout << "do not use this function g_s" << endl;
112  return 0; //1/(1+z*z);
113  };
114 
115  /// squashing function, to protect against to large weight updates
116  virtual double squash(double z)
117  {
118  return z < -0.1 ? -0.1 : ( z > 0.1 ? 0.1 : z );
119  //return 0.1 * tanh(10.0 * z);
120  };
121 
122 
123 #include "dinvert3channelcontroller.hpp"
124 
125 };
126 
127 #endif
virtual double squash(double z)
squashing function, to protect against to large weight updates
Definition: dinvert3channelcontroller.h:116
double * xsi4E
Definition: dinvert3channelcontroller.h:67
double * x_effective
Definition: dinvert3channelcontroller.h:52
virtual double g(double z)
neuron transfer function
Definition: dinvert3channelcontroller.h:99
double ** L
Definition: dinvert3channelcontroller.h:56
double * h
bias vector
Definition: dinvert3channelcontroller.h:62
double ** Q_buf2
Definition: dinvert3channelcontroller.h:55
char name[50]
Definition: dinvert3channelcontroller.h:71
double * x_smooth
Definition: dinvert3channelcontroller.h:51
int t
number of steps, needed for ringbuffer x_buffer
Definition: dinvert3channelcontroller.h:70
int BUFFER_SIZE
Definition: dinvert3channelcontroller.h:49
double * xsi4Model
Definition: dinvert3channelcontroller.h:68
double ** x_buffer
buffer for input values, x[tbuffersize]=actual value, x[(t-1+buffersize)buffersize]=x(t-1) ...
Definition: dinvert3channelcontroller.h:64
virtual double g_s(double z)
Definition: dinvert3channelcontroller.h:106
double ** C
controller matrix
Definition: dinvert3channelcontroller.h:61
double * z
Definition: dinvert3channelcontroller.h:57
int NUMBER_CHANNELS
Definition: dinvert3channelcontroller.h:48
class for robot controller that use naglaa's direct matrix inversion for n channels (simple one layer...
Definition: dinvert3channelcontroller.h:29
double ** A
model matrix
Definition: dinvert3channelcontroller.h:60
double * y_effective
Definition: dinvert3channelcontroller.h:53
Abstract class (interface) for robot controller that use direct matrix inversion and simple one layer...
Definition: invertcontroller.h:33
double ** Q_buf1
Definition: dinvert3channelcontroller.h:54
double ** y_buffer
buffer for output values, y[tbuffersize]=actual value(if already calculated!), y[(t-1+buffersize)buff...
Definition: dinvert3channelcontroller.h:65