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
remotecontrolled.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005-2012 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 __REMOTECONTROLLED_H
25 #define __REMOTECONTROLLED_H
26 
27 #include "abstractcontroller.h"
28 
29 #include <selforg/matrix.h>
30 
31 /**
32  * Controller that is explicity controlled remotely (no own intelligence).
33  * Call remoteControl() each step to set the motor values
34  */
36 public:
38  : AbstractController("RemoteControlled", "1.0")
39  {
40  }
41 
42  virtual void init(int sensornumber, int motornumber, RandGen* randGen = 0){
43  number_sensors = sensornumber;
44  number_motors = motornumber;
45  x.set(number_sensors,1);
46  y.set(number_motors,1);
47  }
48 
49  virtual int getSensorNumber() const { return number_sensors;};
50 
51  virtual int getMotorNumber() const { return number_motors; };
52 
53  virtual void step(const sensor* sensors, int sensornumber,
54  motor* motors, int motornumber){
55  stepNoLearning(sensors,sensornumber, motors, motornumber);
56  }
57 
58  virtual void stepNoLearning(const sensor* sensors, int number_sensors,
59  motor* motors, int number_motors){
60  assert(this->number_motors<=number_motors);
61  assert(this->number_sensors<=number_sensors);
62  x.set(sensors);
63  y.convertToBuffer(motors, this->number_motors);
64  }
65 
66  virtual void remoteControl(const matrix::Matrix& motors){
67  assert(motors.getN() == 1 && motors.getM() == y.getM());
68  y=motors;
69  }
70 
72  return x;
73  }
74 
75  virtual bool store(FILE* f) const { return true;};
76 
77  /** loads the object from the given file stream (binary).
78  */
79  virtual bool restore(FILE* f){ return true; };
80 
81 
82 protected:
83  unsigned short number_sensors;
84  unsigned short number_motors;
85  matrix::Matrix x; // current sensor value vector
86  matrix::Matrix y; // current motor value vector
87 };
88 
89 #endif
virtual bool restore(FILE *f)
loads the object from the given file stream (binary).
Definition: remotecontrolled.h:79
Matrix type.
Definition: matrix.h:65
virtual int getSensorNumber() const
Definition: remotecontrolled.h:49
I getM() const
Definition: matrix.h:88
Abstract class for robot controller (with some basic functionality).
Definition: abstractcontroller.h:46
virtual void remoteControl(const matrix::Matrix &motors)
Definition: remotecontrolled.h:66
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: remotecontrolled.h:42
virtual bool store(FILE *f) const
stores the object to the given file stream (ASCII preferred).
Definition: remotecontrolled.h:75
random generator with 48bit integer arithmentic
Definition: randomgenerator.h:34
virtual int getMotorNumber() const
Definition: remotecontrolled.h:51
unsigned short number_motors
Definition: remotecontrolled.h:84
I getN() const
Definition: matrix.h:90
int convertToBuffer(D *buffer, I len) const
stores the content of the matrix (row-wise) in the given buffer
Definition: matrix.cpp:160
double sensor
Definition: abstractcontroller.h:48
RemoteControlled()
Definition: remotecontrolled.h:37
matrix::Matrix x
Definition: remotecontrolled.h:85
Controller that is explicity controlled remotely (no own intelligence).
Definition: remotecontrolled.h:35
virtual matrix::Matrix getLastSensorValues()
Definition: remotecontrolled.h:71
void set(I _m, I _n, const D *_data=0)
sets the size of the matrix and maybe the data if given (row-wise).
Definition: matrix.cpp:147
matrix::Matrix y
Definition: remotecontrolled.h:86
virtual void stepNoLearning(const sensor *sensors, int number_sensors, motor *motors, int number_motors)
performs one step without learning.
Definition: remotecontrolled.h:58
unsigned short number_sensors
Definition: remotecontrolled.h:79
double motor
Definition: abstractcontroller.h:49
virtual void step(const sensor *sensors, int sensornumber, motor *motors, int motornumber)
performs one step (includes learning).
Definition: remotecontrolled.h:53