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
switchcontroller.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 __SWITCHCONTROLLER_H
25 #define __SWITCHCONTROLLER_H
26 
27 #include "abstractcontroller.h"
28 
29 /**
30  * meta controller for switching control between
31  * different subcontrollers.
32  */
34 public:
35 
36  SwitchController(const std::list<AbstractController*>& controllers, const std::string& name = "SwitchController", const std::string& revision = "1.0");
37 
38  virtual ~SwitchController();
39 
40  virtual void init(int sensornumber, int motornumber, RandGen* randGen = 0);
41  virtual void step(const sensor* sensors, int sensornumber,
42  motor* motors, int motornumber);
43  virtual void stepNoLearning(const sensor* sensors , int sensornumber,
44  motor* motors, int motornumber);
45 
46  virtual int getSensorNumber() const { return controllers.front()->getSensorNumber();};
47 
48  virtual int getMotorNumber() const { return controllers.front()->getMotorNumber();};
49 
50 
51  virtual bool store(FILE* f) const { return controllers.front()->store(f);};
52  virtual bool restore(FILE* f) { return controllers.front()->restore(f);};
53 
54 protected:
55  int activecontroller;
56  std::list<AbstractController*> controllers;
57 };
58 
59 #endif
SwitchController(const std::list< AbstractController * > &controllers, const std::string &name="SwitchController", const std::string &revision="1.0")
Definition: switchcontroller.cpp:29
Abstract class for robot controller (with some basic functionality).
Definition: abstractcontroller.h:46
virtual bool store(FILE *f) const
stores the object to the given file stream (ASCII preferred).
Definition: switchcontroller.h:51
virtual ~SwitchController()
Definition: switchcontroller.cpp:41
std::list< AbstractController * > controllers
Definition: switchcontroller.h:56
iparamkey name
Definition: inspectable.h:251
random generator with 48bit integer arithmentic
Definition: randomgenerator.h:34
virtual void init(int sensornumber, int motornumber, RandGen *randGen=0)
initialisation of the controller with the given sensor/ motornumber Must be called before use...
Definition: switchcontroller.cpp:43
virtual int getMotorNumber() const
Definition: switchcontroller.h:48
virtual int getSensorNumber() const
Definition: switchcontroller.h:46
double sensor
Definition: abstractcontroller.h:48
meta controller for switching control between different subcontrollers.
Definition: switchcontroller.h:33
virtual bool restore(FILE *f)
loads the object from the given file stream (ASCII preferred).
Definition: switchcontroller.h:52
virtual void step(const sensor *sensors, int sensornumber, motor *motors, int motornumber)
performs one step (includes learning).
Definition: switchcontroller.cpp:50
double motor
Definition: abstractcontroller.h:49
virtual void stepNoLearning(const sensor *sensors, int sensornumber, motor *motors, int motornumber)
performs one step without learning.
Definition: switchcontroller.cpp:65
int activecontroller
Definition: switchcontroller.h:52