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
basiccontroller.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005-2013 LpzRobots development team *
3  * Authors: *
4  * Simón Smith <artificialsimon at ed dot ac dot uk> *
5  * *
6  * This program is free software; you can redistribute it and/or modify *
7  * it under the terms of the GNU General Public License as published by *
8  * the Free Software Foundation; either version 2 of the License, or *
9  * (at your option) any later version. *
10  * *
11  * This program is distributed in the hope that it will be useful, *
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14  * GNU General Public License for more details. *
15  * *
16  * You should have received a copy of the GNU General Public License *
17  * along with this program; if not, write to the *
18  * Free Software Foundation, Inc., *
19  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
20  * *
21  ***************************************************************************/
22 
23 // Header guard
24 #ifndef __BASIC_CONTROLLER_H
25 #define __BASIC_CONTROOLER_H
26 
27 #include <selforg/abstractcontroller.h>
28 
30  public:
31 
32  BasicController(const std::string& name);
33 
34  /** initialisation of the controller with the given sensor/ motornumber
35  Must be called before use. The random generator is optional.
36  */
37  virtual void init(int sensornumber, int motornumber, RandGen* randGen = 0) override;
38 
39  /** @return Number of sensors the controller
40  was initialised with or 0 if not initialised */
41  virtual int getSensorNumber() const override;
42 
43  /** @return Number of motors the controller
44  was initialised with or 0 if not initialised */
45  virtual int getMotorNumber() const override;
46 
47  /** performs one step.
48  Calculates motor commands from sensor inputs.
49  @param sensors sensors inputs scaled to [-1,1]
50  @param sensornumber length of the sensor array
51  @param motors motors outputs. MUST have enough space for motor values!
52  @param motornumber length of the provided motor array
53  */
54  virtual void step(const sensor* sensors, int sensornumber,
55  motor* motors, int motornumber) override;
56 
57 
58  /** performs one step without learning.
59  @see step
60  */
61  virtual void stepNoLearning(const sensor* , int number_sensors,
62  motor* , int number_motors) override;
63 
64  /** stores the object to the given file stream (binary).
65  */
66  virtual bool store(FILE* f) const override;
67 
68  /** loads the object from the given file stream (binary).
69  */
70  virtual bool restore(FILE* f) override;
71 
72  protected:
73  double nSensors;
74  double nMotors;
76  double threshold;
77 
78 };
79 
80 #endif // Header guard
Abstract class for robot controller (with some basic functionality).
Definition: abstractcontroller.h:46
virtual void stepNoLearning(const sensor *, int number_sensors, motor *, int number_motors) override
performs one step without learning.
Definition: basiccontroller.cpp:39
BasicController(const std::string &name)
Definition: basiccontroller.cpp:30
double threshold
Definition: basiccontroller.h:76
iparamkey name
Definition: inspectable.h:251
random generator with 48bit integer arithmentic
Definition: randomgenerator.h:34
double nSensors
Definition: basiccontroller.h:73
double sensor
Definition: abstractcontroller.h:48
virtual int getSensorNumber() const override
Definition: basiccontroller.cpp:82
virtual void init(int sensornumber, int motornumber, RandGen *randGen=0) override
initialisation of the controller with the given sensor/ motornumber Must be called before use...
Definition: basiccontroller.cpp:73
virtual void step(const sensor *sensors, int sensornumber, motor *motors, int motornumber) override
performs one step.
Definition: basiccontroller.cpp:67
virtual int getMotorNumber() const override
Definition: basiccontroller.cpp:86
double nMotors
Definition: basiccontroller.h:74
virtual bool restore(FILE *f) override
loads the object from the given file stream (binary).
Definition: basiccontroller.cpp:96
virtual bool store(FILE *f) const override
stores the object to the given file stream (binary).
Definition: basiccontroller.cpp:90
double motor
Definition: abstractcontroller.h:49
bool initialised
Definition: basiccontroller.h:75
Definition: basiccontroller.h:29