Robotsystem from Robot Group Leipzig: dinvert3channelcontroller.h Source File

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

- File List
- File Members

# dinvert3channelcontroller.h

Go to the documentation of this file.

    00001 #ifndef __DINVERT3CHANNELCONTROLLER_H
    00002 #define __DINVERT3CHANNELCONTROLLER_H
    00003
    00004 #include "invertcontroller.h"
    00005
    00006 #include <assert.h>
    00007 #include <math.h>
    00008
    00009
    00010 /**
    00011  * class for robot controller that use naglaa's direct matrix inversion for n channels
    00012  * (simple one layer networks)
    00013  *
    00014  * Implements standart parameters: eps, rho, mu, stepnumber4avg, stepnumber4delay
    00015  */
    00016 class DInvert3ChannelController : public InvertController {
    00017
    00018 public:
    00019
    00020   /*
    00021     Invert3ChannelController();
    00022
    00023     //virtual ~Invert3ChannelController(){}
    00024
    00025
    00026     /// performs one step (includes learning). Calulates motor commands from sensor inputs.
    00027     virtual void step(const sensor*, motor*);
    00028
    00029     /// performs one step without learning. Calulates motor commands from sensor inputs.
    00030     virtual void stepNoLearning(const sensor*, motor*);
    00031   */
    00032
    00033
    00034 protected:
    00035   int NUMBER_CHANNELS;
    00036   int BUFFER_SIZE;
    00037
    00038   double* x_smooth;
    00039   double* x_effective;
    00040   double* y_effective;
    00041   double** Q_buf1;
    00042   double** Q_buf2;
    00043   double** L;
    00044   double* z;
    00045
    00046 public:
    00047   double** A;    ///< model matrix
    00048   double** C;    ///< controller matrix
    00049   double* h;       ///< bias vector
    00050
    00051   double** x_buffer; ///< buffer for input values, x[t%buffersize]=actual value, x[(t-1+buffersize)%buffersize]=x(t-1)
    00052   double** y_buffer; ///< buffer for output values, y[t%buffersize]=actual value(if already calculated!), y[(t-1+buffersize)%buffersize]=y(t-1)
    00053
    00054   double* xsi4E;
    00055   double* xsi4Model;
    00056
    00057   int    t;       ///< number of steps, needed for ringbuffer x_buffer
    00058   char name[50];
    00059
    00060
    00061   /*
    00062     virtual void inverseMatrix(double Q[NUMBER_CHANNELS][NUMBER_CHANNELS], double Q_1[NUMBER_CHANNELS][NUMBER_CHANNELS]);
    00063
    00064     virtual double calculateE(double *x_delay, double *y_delay);
    00065
    00066     /// learn values h,C   //,A
    00067     virtual void learn(double *x_delay, double *y_delay);
    00068
    00069     /// learn model parameter (matrix A) by gradient descent
    00070     virtual void learnModel(double *x_actual, double *y_effective);
    00071
    00072
    00073     /// calculate delayed values
    00074     virtual void calculateDelayedValues(double source[BUFFER_SIZE][NUMBER_CHANNELS], int number_steps_of_delay_, double *target);
    00075
    00076     virtual void calculateSmoothValues(double source[BUFFER_SIZE][NUMBER_CHANNELS], int number_steps_for_averaging_, double *target);
    00077
    00078     /// calculate controller ouptus
    00079     virtual void calculateControllerValues(double *x_smooth, double *y);
    00080
    00081     // put new value in ring buffer
    00082     virtual void putInBuffer(double buffer[BUFFER_SIZE][NUMBER_CHANNELS], double *values);
    00083
    00084   */
    00085   /// neuron transfer function
    00086   virtual double g(double z)
    00087   {
    00088     return tanh(z);
    00089   };
    00090
    00091
    00092   ///
    00093   virtual double g_s(double z)
    00094   {
    00095     double k=tanh(z);
    00096     return 1.0 - k*k;
    00097     //    return 1.0 - tanh(z)*tanh(z);
    00098   };
    00099
    00100   /// squashing function, to protect against to large weight updates
    00101   virtual double squash(double z)
    00102   {
    00103     return z < -0.1 ? -0.1 : ( z > 0.1 ? 0.1 : z );
    00104     //return 0.1 * tanh(10.0 * z);
    00105   };
    00106
    00107
    00108 #include "dinvert3channelcontroller.hpp"
    00109
    00110 };
    00111
    00112 #endif