feedbackwiring.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2005-2011 LpzRobots development team                    *
00003  *    Georg Martius  <georg dot martius at web dot de>                     *
00004  *    Frank Guettler <guettler at informatik dot uni-leipzig dot de        *
00005  *    Frank Hesse    <frank at nld dot ds dot mpg dot de>                  *
00006  *    Ralf Der       <ralfder at mis dot mpg dot de>                       *
00007  *                                                                         *
00008  *   This program is free software; you can redistribute it and/or modify  *
00009  *   it under the terms of the GNU General Public License as published by  *
00010  *   the Free Software Foundation; either version 2 of the License, or     *
00011  *   (at your option) any later version.                                   *
00012  *                                                                         *
00013  *   This program is distributed in the hope that it will be useful,       *
00014  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00015  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00016  *   GNU General Public License for more details.                          *
00017  *                                                                         *
00018  *   You should have received a copy of the GNU General Public License     *
00019  *   along with this program; if not, write to the                         *
00020  *   Free Software Foundation, Inc.,                                       *
00021  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00022  *                                                                         *
00023  ***************************************************************************/
00024 #ifndef __FEEDBACKWIRING_H
00025 #define __FEEDBACKWIRING_H
00026 
00027 #include "abstractwiring.h"
00028 #include "matrix.h"
00029 
00030 /** Implements essentionally a one to one wiring with feedback connections.
00031     The feedback connections from output to input are parameterised
00032      with a feedback strength.
00033     It is possible to generate virtual motors for context sensors.
00034 
00035     In order to change the feedback strength after initialisation 
00036     use the following code
00037     \code
00038     matrix::Matrix rs = wiring->getFeedbackRatio();
00039     double c=ratio;
00040     rs.toMapP(&c,constant);
00041     wiring->setFeedbackRatio(rs);
00042     \endcode
00043  */
00044 class FeedbackWiring :public AbstractWiring{
00045 public:
00046   typedef enum {Motor=1, Context=2, All=3} Mode;
00047 
00048   /** constructor
00049       @param noise NoiseGenerator that is used for adding noise to sensor values
00050       @param mode Motor|Context|All: Motor: motor outputs send feedback;
00051            Context: virtual motor outputs for each context sensor with feedback
00052       @param feedbackratio default ratio used to feed back the output to the input,
00053          meaning \f[ x_t = 0.1*x_t + 0.9*y_{t-1} \f]
00054    */
00055   FeedbackWiring(NoiseGenerator* noise, Mode mode = Context,double feedbackratio=0.9, const std::string& name = "FeedBackWiring");
00056   virtual ~FeedbackWiring();
00057 
00058 protected:
00059   virtual bool initIntern();
00060 
00061   virtual bool wireSensorsIntern(const sensor* rsensors, int rsensornumber,
00062                                  sensor* csensors, int csensornumber,
00063                                  double noise);
00064 
00065   virtual bool wireMotorsIntern(motor* rmotors, int rmotornumber,
00066                                 const motor* cmotors, int cmotornumber);
00067 
00068 public:
00069 
00070   virtual std::list<iparamkey> getInternalParamNames() const;
00071   virtual std::list<iparamval> getInternalParams() const;
00072 
00073   /// return the feedback ratio vector
00074   virtual matrix::Matrix getFeedbackRatio() const;
00075   /** sets the feedback ratio vector.
00076       The size of the vector must be at least as large as getFeedbackRatio()*/
00077   virtual void setFeedbackRatio(const matrix::Matrix&);
00078 
00079 protected:
00080 
00081   Mode mode;
00082   double defaultfeedbackratio;
00083   matrix::Matrix feedbackratio;
00084   /// array that stored the values of the motors
00085   motor *motors;
00086   int vmotornumber;
00087 
00088 };
00089 
00090 #endif
Generated on Thu Jun 28 14:45:36 2012 for Robot Simulator of the Robotics Group for Self-Organization of Control by  doxygen 1.6.3