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
abstractmulticontroller.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 __ABSTRACTMULTICONTROLLER_H
25 #define __ABSTRACTMULTICONTROLLER_H
26 
28 
29 /**
30  * Abstract class (interface) for using multiple controller.
31  * A controller gets a number of input sensor values each timestep
32  * and has to generate a number of output motor values
33  *
34  *
35  * This is an abstract class, it's useful for implementing multicontrollers such as the
36  * OneActiveMultiPassiveController, which can be used with all Controllers.
37  *
38  * Any MulitController implementing this class should overwrite the methods step(...) and
39  * stepNoLearning(...).
40  */
42 public:
43 
44  /// contructor (hint: use $ID$ for revision)
45  AbstractMultiController(AbstractController* controller, const std::string& name, const std::string& revision);
46 
47  virtual ~AbstractMultiController();
48 
49  /**
50  * Adds a passive controller to this MultiController. If the Agent calls step(..)
51  * or stepNoLearning(..), the MultiController calls not only the active controllers
52  * step(...) but also the step(...) of all the passive controllers. (same for
53  * stepNoLearning(..) ).
54  *
55  * Note: The initialisation of the MultiController with init(sensornumber, motornumber)
56  * must be called after all passive controllers are added, otherwise you must
57  * init the passive controller yourself (not recommended and can generate problems)
58  */
59  virtual void addPassiveController(AbstractController* passiveController);
60 
61 /****************************************************************************/
62 /* AbstractMultiController should implement the following classes: */
63 /* AbstractController, Configurable, Inspectable, Storeable */
64 /****************************************************************************/
65 
66 
67 /****************************************************************************/
68 /* BEGIN methods of AbstractController */
69 /****************************************************************************/
70 
71 
72  /** initialisation of the controller with the given sensor/ motornumber
73  * Must NORMALLY be called before use. For all multicontroller
74  * call first AbstractMultiController::init(sensornumber,motornumber)
75  * if you overwrite this method
76  */
77  virtual void init(int sensornumber, int motornumber, RandGen* randGen = 0);
78 
79  /** performs one step (includes learning).
80  Calculates motor commands from sensor inputs.
81  @param sensors sensors inputs scaled to [-1,1]
82  @param sensornumber length of the sensor array
83  @param motors motors outputs. MUST have enough space for motor values!
84  @param motornumber length of the provided motor array
85  */
86  virtual void step(const sensor* sensors, int sensornumber,
87  motor* motors, int motornumber)=0;
88 
89  /** performs one step without learning.
90  @see step
91  */
92  virtual void stepNoLearning(const sensor* sensors , int sensornumber,
93  motor* motors, int motornumber)=0;
94 
95 
96 /****************************************************************************/
97 /* END methods of AbstractController */
98 /****************************************************************************/
99 
100 /****************************************************************************/
101 /* BEGIN methods of Configurable */
102 /****************************************************************************/
103 
104 
105 
106 /****************************************************************************/
107 /* END methods of Configurable */
108 /****************************************************************************/
109 
110 /****************************************************************************/
111 /* BEGIN methods of Inspectable */
112 /****************************************************************************/
113 
114 // nothing to overwrite
115 
116 
117 /****************************************************************************/
118 /* END methods of Inspectable */
119 /****************************************************************************/
120 
121 /****************************************************************************/
122 /* BEGIN methods of Storeable */
123 /****************************************************************************/
124 
125  /** stores the object to the given file stream (binary).
126  */
127  virtual bool store(FILE* f) const;
128 
129  /** loads the object from the given file stream (binary).
130  */
131  virtual bool restore(FILE* f);
132 
133 
134 /****************************************************************************/
135 /* END methods of Storeable */
136 /****************************************************************************/
137 
138 protected:
139  // The AbstractController* controller is defined in AbstractControllerAdapter!
140  std::list<AbstractController*> controllerList; // stores the other controllers
141  std::list<std::string> controllerNameList; // stores the names of the controllers
142 
143 };
144 
145 #endif
virtual void addPassiveController(AbstractController *passiveController)
Adds a passive controller to this MultiController.
Definition: abstractmulticontroller.cpp:36
std::list< std::string > controllerNameList
Definition: abstractmulticontroller.h:141
Abstract class for robot controller (with some basic functionality).
Definition: abstractcontroller.h:46
Abstract adapter class (interface) for robot controller.
Definition: abstractcontrolleradapter.h:52
virtual ~AbstractMultiController()
Definition: abstractmulticontroller.cpp:33
virtual void stepNoLearning(const sensor *sensors, int sensornumber, motor *motors, int motornumber)=0
performs one step without learning.
Abstract class (interface) for using multiple controller.
Definition: abstractmulticontroller.h:41
iparamkey name
Definition: inspectable.h:251
random generator with 48bit integer arithmentic
Definition: randomgenerator.h:34
AbstractController * controller
Definition: abstractcontrolleradapter.h:158
double sensor
Definition: abstractcontroller.h:48
AbstractMultiController(AbstractController *controller, const std::string &name, const std::string &revision)
contructor (hint: use $ID$ for revision)
Definition: abstractmulticontroller.cpp:28
std::list< AbstractController * > controllerList
Definition: abstractmulticontroller.h:140
virtual void step(const sensor *sensors, int sensornumber, motor *motors, int motornumber)=0
performs one step (includes learning).
virtual bool store(FILE *f) const
stores the object to the given file stream (binary).
Definition: abstractmulticontroller.cpp:68
virtual void init(int sensornumber, int motornumber, RandGen *randGen=0)
initialisation of the controller with the given sensor/ motornumber Must NORMALLY be called before us...
Definition: abstractmulticontroller.cpp:45
virtual bool restore(FILE *f)
loads the object from the given file stream (binary).
Definition: abstractmulticontroller.cpp:76
double motor
Definition: abstractcontroller.h:49