feedbackwiring.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2007 by Robot Group Leipzig                             *
00003  *    martius@informatik.uni-leipzig.de                                    *
00004  *    fhesse@informatik.uni-leipzig.de                                     *
00005  *    der@informatik.uni-leipzig.de                                        *
00006  *                                                                         *
00007  *   This program is free software; you can redistribute it and/or modify  *
00008  *   it under the terms of the GNU General Public License as published by  *
00009  *   the Free Software Foundation; either version 2 of the License, or     *
00010  *   (at your option) any later version.                                   *
00011  *                                                                         *
00012  *   This program is distributed in the hope that it will be useful,       *
00013  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00014  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00015  *   GNU General Public License for more details.                          *
00016  *                                                                         *
00017  *   You should have received a copy of the GNU General Public License     *
00018  *   along with this program; if not, write to the                         *
00019  *   Free Software Foundation, Inc.,                                       *
00020  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00021  *                                                                         *
00022  *   $Log: feedbackwiring.h,v $
00023  *   Revision 1.5  2009/08/05 22:32:21  martius
00024  *   big change:
00025  *       abstractwiring is responsable for providing sensors and motors
00026  *        and noise to the inspectable interface.
00027  *       external interface: unchanged except plotMode in constructor
00028  *       internal interface: all subclasses have to overload
00029  *         initIntern, wireSensorsIntern, wireMotorsIntern
00030  *       All existing implementation are changed
00031  *
00032  *   Revision 1.4  2009/03/26 19:14:42  martius
00033  *   some comments
00034  *
00035  *   Revision 1.3  2008/04/28 11:10:11  guettler
00036  *   include "matrix.h" from trackable class removed, used forward declaration
00037  *   instead - this change effectuates that no robot must be recompiled if
00038  *   matrix.h has changed.
00039  *
00040  *   Revision 1.2  2008/04/17 14:54:45  martius
00041  *   randomGen added, which is a random generator with long period and an
00042  *    internal state. Each Agent has an instance and passed it to the controller
00043  *    and the wiring. This is good for
00044  *   a) repeatability on agent basis,
00045  *   b) parallel execution as done in ode_robots
00046  *
00047  *   Revision 1.1  2007/11/28 10:30:56  martius
00048  *   wiring with feedback connections
00049  *
00050  *                                            *
00051  *                                                                         *
00052  ***************************************************************************/
00053 #ifndef __FEEDBACKWIRING_H
00054 #define __FEEDBACKWIRING_H
00055 
00056 #include "abstractwiring.h"
00057 #include "matrix.h"
00058 
00059 /** Implements essentionally a one to one wiring with feedback connections.
00060     The feedback connections from output to input are parameterised
00061      with a feedback strength.
00062     It is possible to generate virtual motors for context sensors.
00063 
00064     In order to change the feedback strength after initialisation 
00065     use the following code
00066     \code
00067     matrix::Matrix rs = wiring->getFeedbackRatio();
00068     double c=ratio;
00069     rs.toMapP(&c,constant);
00070     wiring->setFeedbackRatio(rs);
00071     \endcode
00072  */
00073 class FeedbackWiring :public AbstractWiring{
00074 public:
00075   typedef enum {Motor=1, Context=2, All=3} Mode;
00076 
00077   /** constructor
00078       @param noise NoiseGenerator that is used for adding noise to sensor values
00079       @param mode Motor|Context|All: Motor: motor outputs send feedback;
00080            Context: virtual motor outputs for each context sensor with feedback
00081       @param feedbackratio default ratio used to feed back the output to the input,
00082          meaning \f[ x_t = 0.1*x_t + 0.9*y_{t-1} \f]
00083    */
00084   FeedbackWiring(NoiseGenerator* noise, Mode mode = Context,double feedbackratio=0.9);
00085   virtual ~FeedbackWiring();
00086 
00087 protected:
00088   virtual bool initIntern(int robotsensornumber, int robotmotornumber, RandGen* randGen=0);
00089 
00090   virtual bool wireSensorsIntern(const sensor* rsensors, int rsensornumber,
00091                                  sensor* csensors, int csensornumber,
00092                                  double noise);
00093 
00094   virtual bool wireMotorsIntern(motor* rmotors, int rmotornumber,
00095                                 const motor* cmotors, int cmotornumber);
00096 
00097 public:
00098 
00099   virtual std::list<iparamkey> getInternalParamNames() const;
00100   virtual std::list<iparamval> getInternalParams() const;
00101 
00102   /// return the feedback ratio vector
00103   virtual matrix::Matrix getFeedbackRatio() const;
00104   /** sets the feedback ratio vector.
00105       The size of the vector must be at least as large as getFeedbackRatio()*/
00106   virtual void setFeedbackRatio(const matrix::Matrix&);
00107 
00108 protected:
00109 
00110   Mode mode;
00111   double defaultfeedbackratio;
00112   matrix::Matrix feedbackratio;
00113   /// array that stored the values of the motors
00114   motor *motors;
00115   int vmotornumber;
00116 
00117 };
00118 
00119 #endif

Generated on Fri Oct 30 16:29:01 2009 for Robot Simulator of the Robotics Group for Self-Organization of Control by  doxygen 1.4.7