Robotsystem of the Robot Group Leipzig: feedbackwiring.h Source File

- Main Page
- Namespaces
- Classes
- Files
- Directories
- Related Pages
- Examples

- Search for |

- File List
- File Members

# 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.3  2008/04/28 11:10:11  guettler
    00024  *   include "matrix.h" from trackable class removed, used forward declaration
    00025  *   instead - this change effectuates that no robot must be recompiled if
    00026  *   matrix.h has changed.
    00027  *
    00028  *   Revision 1.2  2008/04/17 14:54:45  martius
    00029  *   randomGen added, which is a random generator with long period and an
    00030  *    internal state. Each Agent has an instance and passed it to the controller
    00031  *    and the wiring. This is good for
    00032  *   a) repeatability on agent basis,
    00033  *   b) parallel execution as done in ode_robots
    00034  *
    00035  *   Revision 1.1  2007/11/28 10:30:56  martius
    00036  *   wiring with feedback connections
    00037  *
    00038  *                                            *
    00039  *                                                                         *
    00040  ***************************************************************************/
    00041 #ifndef __FEEDBACKWIRING_H
    00042 #define __FEEDBACKWIRING_H
    00043
    00044 #include "abstractwiring.h"
    00045 #include "matrix.h"
    00046
    00047 /** Implements essentionally a one to one wiring with feedback connections.
    00048     The feedback connections from output to input is parameterised
    00049      with a feedback strength.
    00050     It is possible to generate virtual motors for context sensors.
    00051
    00052     In order to change the feedback strength use the following code
    00053      after initialisation of the agent/wiredcontroller
    00054     \code
    00055     matrix::Matrix rs = wiring->getFeedbackRatio();
    00056     double c=ratio;
    00057     rs.toMapP(&c,constant);
    00058     wiring->setFeedbackRatio(rs);
    00059     \endcode
    00060  */
    00061 class FeedbackWiring :public AbstractWiring{
    00062 public:
    00063   typedef enum {Motor=1, Context=2, All=3} Mode;
    00064
    00065   /** constructor
    00066       @param noise NoiseGenerator that is used for adding noise to sensor values
    00067       @param mode Motor|Context|All: Motor: motor outputs send feedback;
    00068            Context: virtual motor outputs for each context sensor with feedback
    00069       @param feedbackratio default ratio used to feed back the output to the input,
    00070          meaning \f[ x_t = 0.1*x_t + 0.9*y_{t-1} \f]
    00071    */
    00072   FeedbackWiring(NoiseGenerator* noise, Mode mode = Context,double feedbackratio=0.9);
    00073   virtual ~FeedbackWiring();
    00074
    00075   virtual bool init(int robotsensornumber, int robotmotornumber, RandGen* randGen=0);
    00076
    00077   virtual bool wireSensors(const sensor* rsensors, int rsensornumber,
    00078                            sensor* csensors, int csensornumber,
    00079                            double noise);
    00080
    00081   virtual bool wireMotors(motor* rmotors, int rmotornumber,
    00082                           const motor* cmotors, int cmotornumber);
    00083
    00084   virtual std::list<iparamkey> getInternalParamNames() const;
    00085   virtual std::list<iparamval> getInternalParams() const;
    00086
    00087   /// return the feedback ratio vector
    00088   virtual matrix::Matrix getFeedbackRatio() const;
    00089   /** sets the feedback ratio vector.
    00090       The size of the vector must be at least as large as feedbackratio*/
    00091   virtual void setFeedbackRatio(const matrix::Matrix&);
    00092
    00093 protected:
    00094
    00095   Mode mode;
    00096   double defaultfeedbackratio;
    00097   matrix::Matrix feedbackratio;
    00098   /// array that stored the values of the motors
    00099   motor *motors;
    00100   int vmotornumber;
    00101
    00102   /// for storing the noise values
    00103   sensor* noisevals;
    00104
    00105   bool initialised;
    00106 };
    00107
    00108 #endif