sinecontroller.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2005 by Robot Group Leipzig                             *
00003  *    martius@informatik.uni-leipzig.de                                    *
00004  *    fhesse@informatik.uni-leipzig.de                                     *
00005  *    der@informatik.uni-leipzig.de                                        *
00006  *                                                                         *
00007  *   This program is free software; you can redistribute it and/or modify  *
00008  *   it under the terms of the GNU General Public License as published by  *
00009  *   the Free Software Foundation; either version 2 of the License, or     *
00010  *   (at your option) any later version.                                   *
00011  *                                                                         *
00012  *   This program is distributed in the hope that it will be useful,       *
00013  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00014  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00015  *   GNU General Public License for more details.                          *
00016  *                                                                         *
00017  *   You should have received a copy of the GNU General Public License     *
00018  *   along with this program; if not, write to the                         *
00019  *   Free Software Foundation, Inc.,                                       *
00020  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00021  *                                                                         *
00022  *   $Log: sinecontroller.h,v $
00023  *   Revision 1.12  2008/04/17 14:54:45  martius
00024  *   randomGen added, which is a random generator with long period and an
00025  *    internal state. Each Agent has an instance and passed it to the controller
00026  *    and the wiring. This is good for
00027  *   a) repeatability on agent basis,
00028  *   b) parallel execution as done in ode_robots
00029  *
00030  *   Revision 1.11  2007/03/26 13:13:47  martius
00031  *   store and restore with params
00032  *
00033  *   Revision 1.10  2006/11/29 16:22:43  martius
00034  *   name is a variable of configurable and is used as such
00035  *
00036  *   Revision 1.9  2006/08/02 09:32:03  martius
00037  *   store and restore according to storable interface
00038  *
00039  *   Revision 1.8  2006/07/14 12:23:59  martius
00040  *   selforg becomes HEAD
00041  *
00042  *   Revision 1.6.6.5  2006/06/25 21:56:08  martius
00043  *   configureable has name and revision
00044  *
00045  *   Revision 1.6.6.4  2006/06/25 16:51:36  martius
00046  *   configureable has name and revision
00047  *   a robot is configureable by default
00048  *
00049  *   Revision 1.6.6.3  2006/03/30 12:35:13  martius
00050  *   documentation updated
00051  *
00052  *   Revision 1.6.6.2  2006/01/18 16:48:35  martius
00053  *   stored and restore
00054  *
00055  *   Revision 1.6.6.1  2005/11/14 15:38:17  martius
00056  *   moved to selforg
00057  *
00058  *   Revision 1.6  2005/11/14 12:46:19  martius
00059  *   added number of controlled motors
00060  *
00061  *   Revision 1.5  2005/11/09 13:56:34  martius
00062  *   const in instspectable functions
00063  *
00064  *   Revision 1.4  2005/10/06 17:06:57  martius
00065  *   switched to stl lists
00066  *
00067  *   Revision 1.3  2005/08/06 20:47:54  martius
00068  *   Commented
00069  *
00070  *   Revision 1.2  2005/07/07 10:25:47  martius
00071  *   added Phaseshift
00072  *
00073  *   Revision 1.1  2005/07/06 13:55:33  fhesse
00074  *   initial version, realising sine and cosine outputs
00075  *                                            *
00076  *                                                                         *
00077  ***************************************************************************/
00078 #ifndef __SINECONTROLLER_H
00079 #define __SINECONTROLLER_H
00080 
00081 
00082 #include <stdio.h>
00083 #include "abstractcontroller.h"
00084 
00085 /**
00086  * class for robot control with sine and cosine 
00087  * 
00088  * 
00089  */
00090 class SineController : public AbstractController {
00091 public:
00092 
00093   SineController(int number_controlled=-1);
00094 
00095   /** initialisation of the controller with the given sensor/ motornumber 
00096       Must be called before use.
00097   */
00098   virtual void init(int sensornumber, int motornumber, RandGen* randGen = 0);
00099   
00100   /** @return Number of sensors the controller was initialised 
00101       with or 0 if not initialised */
00102   virtual int getSensorNumber() const {return number_sensors;}
00103 
00104 
00105   /** @return Number of motors the controller was initialised 
00106       with or 0 if not initialised */
00107   virtual int getMotorNumber() const {return number_motors;}
00108 
00109   /** performs one step (includes learning). 
00110       Calculates motor commands from sensor inputs.
00111       @param sensors sensors inputs scaled to [-1,1]
00112       @param sensornumber length of the sensor array
00113       @param motors motors outputs. MUST have enough space for motor values!
00114       @param motornumber length of the provided motor array
00115   */
00116   virtual void step(const sensor* sensors, int sensornumber, 
00117                     motor* motors, int motornumber);
00118   /** performs one step without learning. 
00119       @see step
00120   */
00121   virtual void stepNoLearning(const sensor* , int number_sensors, 
00122                               motor* , int number_motors);
00123   
00124 
00125   virtual std::list<iparamkey> getInternalParamNames()const  { return std::list<iparamkey>(); }
00126 
00127   virtual std::list<iparamval> getInternalParams() const { return std::list<iparamval>(); }
00128   
00129 
00130   virtual paramval getParam(const paramkey& key) const;
00131   virtual bool setParam(const paramkey& key, paramval val);
00132   virtual paramlist getParamList() const ;
00133 
00134   /********* STORABLE INTERFACE ******/
00135   /// @see Storable
00136   virtual bool store(FILE* f) const { 
00137     Configurable::print(f,"");
00138     return true;
00139   }
00140 
00141   /// @see Storable
00142   virtual bool restore(FILE* f) { 
00143     Configurable::parse(f);    
00144     return true;
00145   }
00146 
00147 
00148 protected:
00149 
00150   int t;
00151   std::string name;
00152   int number_sensors;
00153   int number_motors;
00154   int number_controlled; // number of motors that are controlled. The remaining are set to 0;
00155 
00156   paramval sineRate;
00157   paramval phaseShift;
00158 };
00159 
00160 #endif 

Generated on Tue Sep 16 22:00:22 2008 for Robotsystem of the Robot Group Leipzig by  doxygen 1.4.7