ffnncontroller.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: ffnncontroller.h,v $ 00020 * Revision 1.1 2006/11/29 16:21:35 martius 00021 * controller that uses a fixed feed forward neural network with some history 00022 * 00023 * 00024 ***************************************************************************/ 00025 #ifndef __FFNNCONTROLLER_H 00026 #define __FFNNCONTROLLER_H 00027 00028 #include "abstractcontroller.h" 00029 #include <assert.h> 00030 #include <math.h> 00031 00032 #include <selforg/matrix.h> 00033 #include <selforg/multilayerffnn.h> 00034 /** 00035 * class for robot controller that uses the georg's matrixlib for 00036 * direct matrix inversion for n channels 00037 * (simple one layer networks) 00038 * 00039 * Implements standart parameters: eps, rho, mu, stepnumber4avg, stepnumber4delay 00040 */ 00041 class FFNNController : public AbstractController { 00042 00043 public: 00044 /** networkfilename is the file to load the network from, 00045 and history is the number of time steps the network gets input from (in sensce of dimension of input) 00046 \param input_only_x if true then the input vector is \f[ (x_{t},x_{t-1},...,x_{t-history})^T \f] 00047 if false then also the y values are used: \f[ (x_{t}, y_{t-1}, x_{t-1},y_{t-2},...,x_{t-history})^T \f] 00048 */ 00049 FFNNController(const std::string& networkfilename, int history, bool input_only_x = false); 00050 00051 virtual void init(int sensornumber, int motornumber); 00052 00053 virtual ~FFNNController(); 00054 00055 /// returns the number of sensors the controller was initialised with or 0 if not initialised 00056 virtual int getSensorNumber() const { return number_sensors; } 00057 /// returns the mumber of motors the controller was initialised with or 0 if not initialised 00058 virtual int getMotorNumber() const { return number_motors; } 00059 00060 virtual void step(const sensor* , int number_sensors, motor* , int number_motors); 00061 virtual void stepNoLearning(const sensor* , int number_sensors, 00062 motor* , int number_motors); 00063 00064 /**** STOREABLE ****/ 00065 /** stores the controller values to a given file (binary). */ 00066 virtual bool store(FILE* f) const; 00067 /** loads the controller values from a given file (binary). */ 00068 virtual bool restore(FILE* f); 00069 00070 // inspectable interface 00071 virtual std::list<iparamkey> getInternalParamNames()const { return std::list<iparamkey>(); } 00072 virtual std::list<iparamval> getInternalParams() const { return std::list<iparamval>(); } 00073 00074 // configureable interface 00075 virtual paramval getParam(const paramkey& key) const; 00076 virtual bool setParam(const paramkey& key, paramval val); 00077 virtual paramlist getParamList() const ; 00078 00079 protected: 00080 void putInBuffer(matrix::Matrix* buffer, const matrix::Matrix& vec, int delay = 0); 00081 00082 matrix::Matrix calculateSmoothValues(const matrix::Matrix* buffer, int number_steps_for_averaging_) const; 00083 00084 matrix::Matrix assembleNetworkInputXY(matrix::Matrix* xbuffer, matrix::Matrix* ybuffer) const; 00085 00086 matrix::Matrix assembleNetworkInputX(matrix::Matrix* xbuffer, matrix::Matrix* ybuffer) const; 00087 00088 protected: 00089 unsigned short number_motors; 00090 unsigned short number_sensors; 00091 unsigned short history; 00092 unsigned short buffersize; 00093 bool input_only_x; 00094 unsigned short s4avg; 00095 unsigned int t; 00096 00097 matrix::Matrix* x_buffer; 00098 matrix::Matrix* y_buffer; 00099 matrix::Matrix x_smooth; 00100 00101 MultiLayerFFNN* net; 00102 bool initialised; 00103 00104 }; 00105 00106 #endif

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