Robot Simulator of the Robotics Group for Self-Organization of Control  0.8.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
feedbackwiring.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005-2011 LpzRobots development team *
3  * Georg Martius <georg dot martius at web dot de> *
4  * Frank Guettler <guettler at informatik dot uni-leipzig dot de *
5  * Frank Hesse <frank at nld dot ds dot mpg dot de> *
6  * Ralf Der <ralfder at mis dot mpg dot de> *
7  * *
8  * This program is free software; you can redistribute it and/or modify *
9  * it under the terms of the GNU General Public License as published by *
10  * the Free Software Foundation; either version 2 of the License, or *
11  * (at your option) any later version. *
12  * *
13  * This program is distributed in the hope that it will be useful, *
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16  * GNU General Public License for more details. *
17  * *
18  * You should have received a copy of the GNU General Public License *
19  * along with this program; if not, write to the *
20  * Free Software Foundation, Inc., *
21  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
22  * *
23  ***************************************************************************/
24 #ifndef __FEEDBACKWIRING_H
25 #define __FEEDBACKWIRING_H
26 
27 #include "abstractwiring.h"
28 #include "matrix.h"
29 
30 /** Implements essentionally a one to one wiring with feedback connections.
31  The feedback connections from output to input are parameterised
32  with a feedback strength.
33  It is possible to generate virtual motors for context sensors.
34 
35  In order to change the feedback strength after initialisation
36  use the following code
37  \code
38  matrix::Matrix rs = wiring->getFeedbackRatio();
39  double c=ratio;
40  rs.toMapP(&c,constant);
41  wiring->setFeedbackRatio(rs);
42  \endcode
43  */
45 public:
46  typedef enum {Motor=1, Context=2, All=3} Mode;
47 
48  /** constructor
49  @param noise NoiseGenerator that is used for adding noise to sensor values
50  @param mode Motor|Context|All: Motor: motor outputs send feedback;
51  Context: virtual motor outputs for each context sensor with feedback
52  @param feedbackratio default ratio used to feed back the output to the input,
53  meaning \f[ x_t = 0.1*x_t + 0.9*y_{t-1} \f]
54  */
55  FeedbackWiring(NoiseGenerator* noise, Mode mode = Context,double feedbackratio=0.9, const std::string& name = "FeedBackWiring");
56  virtual ~FeedbackWiring();
57 
58 protected:
59  virtual bool initIntern();
60 
61  virtual bool wireSensorsIntern(const sensor* rsensors, int rsensornumber,
62  sensor* csensors, int csensornumber,
63  double noise);
64 
65  virtual bool wireMotorsIntern(motor* rmotors, int rmotornumber,
66  const motor* cmotors, int cmotornumber);
67 
68 public:
69 
70  virtual std::list<iparamkey> getInternalParamNames() const;
71  virtual std::list<iparamval> getInternalParams() const;
72 
73  /// return the feedback ratio vector
74  virtual matrix::Matrix getFeedbackRatio() const;
75  /** sets the feedback ratio vector.
76  The size of the vector must be at least as large as getFeedbackRatio()*/
77  virtual void setFeedbackRatio(const matrix::Matrix&);
78 
79 protected:
80 
84  /// array that stored the values of the motors
87 
88 };
89 
90 #endif
Matrix type.
Definition: matrix.h:65
int rmotornumber
number of motors at robot side
Definition: abstractwiring.h:182
FeedbackWiring(NoiseGenerator *noise, Mode mode=Context, double feedbackratio=0.9, const std::string &name="FeedBackWiring")
constructor
Definition: feedbackwiring.cpp:32
int csensornumber
number of sensors at controller side
Definition: abstractwiring.h:187
double sensor
Definition: types.h:29
iparamkey name
Definition: inspectable.h:251
motor * motors
array that stored the values of the motors
Definition: feedbackwiring.h:85
Definition: feedbackwiring.h:46
Definition: feedbackwiring.h:46
Abstract wiring-object between controller and robot.
Definition: abstractwiring.h:39
Implements essentionally a one to one wiring with feedback connections.
Definition: feedbackwiring.h:44
virtual bool wireSensorsIntern(const sensor *rsensors, int rsensornumber, sensor *csensors, int csensornumber, double noise)
to be overloaded by subclasses
Definition: feedbackwiring.cpp:72
double defaultfeedbackratio
Definition: feedbackwiring.h:82
virtual std::list< iparamval > getInternalParams() const
Definition: feedbackwiring.cpp:135
virtual std::list< iparamkey > getInternalParamNames() const
The list of the names of all internal parameters given by getInternalParams().
Definition: feedbackwiring.cpp:125
virtual matrix::Matrix getFeedbackRatio() const
return the feedback ratio vector
Definition: feedbackwiring.cpp:113
Mode
Definition: feedbackwiring.h:46
Mode mode
Definition: feedbackwiring.h:81
double motor
Definition: types.h:30
virtual ~FeedbackWiring()
Definition: feedbackwiring.cpp:40
virtual bool initIntern()
to be overloaded by subclasses The rsensornumber and rmotornumber are already stored in the member va...
Definition: feedbackwiring.cpp:47
int cmotornumber
number of motors at controller side
Definition: abstractwiring.h:192
int rsensornumber
number of sensors at robot side
Definition: abstractwiring.h:177
matrix::Matrix feedbackratio
Definition: feedbackwiring.h:83
virtual void setFeedbackRatio(const matrix::Matrix &)
sets the feedback ratio vector.
Definition: feedbackwiring.cpp:118
Definition: feedbackwiring.h:46
int vmotornumber
Definition: feedbackwiring.h:86
virtual bool wireMotorsIntern(motor *rmotors, int rmotornumber, const motor *cmotors, int cmotornumber)
to be overloaded by subclasses
Definition: feedbackwiring.cpp:101
Interface and basic class for noise generator.
Definition: noisegenerator.h:37