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
motorbabbler.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 __MOTORBABBLER_H
25 #define __MOTORBABBLER_H
26 
27 #include <stdio.h>
28 #include "abstractcontroller.h"
29 #include "matrix.h"
30 
31 /**
32  * class for robot control that does motor babbling, e.g. sine waves
33  * with different frequencies and phaseshift
34  */
36 public:
37  enum function {Sine, SawTooth};
38 
39  /**
40  @param controlmask bitmask to select channels to control (default all)
41  @param function controller function to use
42  */
43  MotorBabbler(function func = Sine );
44 
45  virtual void init(int sensornumber, int motornumber, RandGen* randGen = 0);
46  virtual int getSensorNumber() const {return number_sensors;}
47  virtual int getMotorNumber() const {return number_motors;}
48  virtual void step(const sensor* sensors, int sensornumber,
49  motor* motors, int motornumber){
50  stepNoLearning(sensors, sensornumber, motors, motornumber);
51  }
52  virtual void stepNoLearning(const sensor* , int number_sensors,
53  motor* , int number_motors);
54 
55  // samples a new set of frequencies
56  void sampleFrequencies();
57 
58  /********* STORABLE INTERFACE ******/
59  /// @see Storable
60  virtual bool store(FILE* f) const {
61  Configurable::print(f,"");
62  return true;
63  }
64 
65  /// @see Storable
66  virtual bool restore(FILE* f) {
68  return true;
69  }
70 
71  /// sine
72  static double sine(double x);
73  /// saw tooth shape oscillator
74  static double sawtooth(double x);
75 
76 protected:
79 
85 
87 
88  double (*osci) (double x); // oscillator function
89  int t;
90 };
91 
92 #endif
virtual void step(const sensor *sensors, int sensornumber, motor *motors, int motornumber)
performs one step (includes learning).
Definition: motorbabbler.h:48
Matrix type.
Definition: matrix.h:65
RandGen * randGen
Definition: motorbabbler.h:86
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)
performs one step without learning.
Definition: motorbabbler.cpp:72
static double sine(double x)
sine
Definition: motorbabbler.cpp:88
double sensor
Definition: types.h:29
class for robot control that does motor babbling, e.g.
Definition: motorbabbler.h:35
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: motorbabbler.cpp:53
Definition: motorbabbler.h:37
Definition: motorbabbler.h:37
int number_motors
Definition: motorbabbler.h:78
void print(FILE *f, const char *prefix, int columns=90, bool traverseChildren=true) const
prints the keys, values and descriptions to the file. Each line is prefixed
Definition: configurable.cpp:308
paramval speed
Definition: motorbabbler.h:80
double(* osci)(double x)
Definition: motorbabbler.h:88
virtual bool store(FILE *f) const
Definition: motorbabbler.h:60
double sensor
Definition: abstractcontroller.h:48
double paramval
Definition: configurable.h:88
virtual int getMotorNumber() const
Definition: motorbabbler.h:47
virtual int getSensorNumber() const
Definition: motorbabbler.h:46
paramint resampling
Definition: motorbabbler.h:82
MotorBabbler(function func=Sine)
Definition: motorbabbler.cpp:34
int paramint
Definition: configurable.h:98
paramval amplitude
Definition: motorbabbler.h:81
double motor
Definition: types.h:30
matrix::Matrix frequencies
Definition: motorbabbler.h:84
matrix::Matrix phases
Definition: motorbabbler.h:83
bool parse(FILE *f, const char *prefix=0, bool traverseChildren=true)
parses the configuration from the given file
Definition: configurable.cpp:384
double motor
Definition: abstractcontroller.h:49
int t
Definition: motorbabbler.h:89
void sampleFrequencies()
Definition: motorbabbler.cpp:65
virtual bool restore(FILE *f)
Definition: motorbabbler.h:66
int number_sensors
Definition: motorbabbler.h:77
static double sawtooth(double x)
saw tooth shape oscillator
Definition: motorbabbler.cpp:92