Robotsystem from Robot Group Leipzig: sinecontroller.h Source File

- Main Page
- Modules
- Namespaces
- Classes
- Files
- Directories
- Examples

- File List
- File Members

# 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.6.6.3  2006/03/30 12:35:13  martius
    00024  *   documentation updated
    00025  *
    00026  *   Revision 1.6.6.2  2006/01/18 16:48:35  martius
    00027  *   stored and restore
    00028  *
    00029  *   Revision 1.6.6.1  2005/11/14 15:38:17  martius
    00030  *   moved to selforg
    00031  *
    00032  *   Revision 1.6  2005/11/14 12:46:19  martius
    00033  *   added number of controlled motors
    00034  *
    00035  *   Revision 1.5  2005/11/09 13:56:34  martius
    00036  *   const in instspectable functions
    00037  *
    00038  *   Revision 1.4  2005/10/06 17:06:57  martius
    00039  *   switched to stl lists
    00040  *
    00041  *   Revision 1.3  2005/08/06 20:47:54  martius
    00042  *   Commented
    00043  *
    00044  *   Revision 1.2  2005/07/07 10:25:47  martius
    00045  *   added Phaseshift
    00046  *
    00047  *   Revision 1.1  2005/07/06 13:55:33  fhesse
    00048  *   initial version, realising sine and cosine outputs
    00049  *                                            *
    00050  *                                                                         *
    00051  ***************************************************************************/
    00052 #ifndef __SINECONTROLLER_H
    00053 #define __SINECONTROLLER_H
    00054
    00055
    00056 #include <stdio.h>
    00057 #include "abstractcontroller.h"
    00058
    00059 /**
    00060  * class for robot control with sine and cosine
    00061  *
    00062  *
    00063  */
    00064 class SineController : public AbstractController {
    00065 public:
    00066
    00067   SineController(int number_controlled=-1);
    00068
    00069   /** initialisation of the controller with the given sensor/ motornumber
    00070       Must be called before use.
    00071   */
    00072   virtual void init(int sensornumber, int motornumber);
    00073
    00074   /// returns the name of the object (with version number)
    00075   virtual paramkey getName() const {return name; }
    00076
    00077   /** @return Number of sensors the controller was initialised
    00078       with or 0 if not initialised */
    00079   virtual int getSensorNumber() const {return number_sensors;}
    00080
    00081
    00082   /** @return Number of motors the controller was initialised
    00083       with or 0 if not initialised */
    00084   virtual int getMotorNumber() const {return number_motors;}
    00085
    00086   /** performs one step (includes learning).
    00087       Calculates motor commands from sensor inputs.
    00088       @param sensors sensors inputs scaled to [-1,1]
    00089       @param sensornumber length of the sensor array
    00090       @param motors motors outputs. MUST have enough space for motor values!
    00091       @param motornumber length of the provided motor array
    00092   */
    00093   virtual void step(const sensor* sensors, int sensornumber,
    00094                     motor* motors, int motornumber);
    00095   /** performs one step without learning.
    00096       @see step
    00097   */
    00098   virtual void stepNoLearning(const sensor* , int number_sensors,
    00099                               motor* , int number_motors);
    00100
    00101
    00102   /** The list of the names of all internal parameters given by getInternalParams().
    00103       @return list of names
    00104    */
    00105   virtual list<iparamkey> getInternalParamNames()const  { return list<iparamkey>(); }
    00106
    00107   /** The list of the names of all internal parameters given by getInternalParams().
    00108    */
    00109   virtual list<iparamval> getInternalParams() const { return list<iparamval>(); }
    00110
    00111
    00112   virtual paramval getParam(const paramkey& key) const;
    00113   virtual bool setParam(const paramkey& key, paramval val);
    00114   virtual paramlist getParamList() const ;
    00115
    00116   /** stores the controller values to a given file.
    00117       This should include internal parameters as well as configurable values
    00118   */
    00119   virtual bool store(const char* filename) { return true;};
    00120
    00121   /** loads the controller values from a given file.
    00122       This should include internal parameters as well as configurable values
    00123   */
    00124   virtual bool restore(const char* filename) { return true;};
    00125
    00126
    00127 protected:
    00128
    00129   int t;
    00130   string name;
    00131   int number_sensors;
    00132   int number_motors;
    00133   int number_controlled; // number of motors that are controlled. The remaining are set to 0;
    00134
    00135   paramval sineRate;
    00136   paramval phaseShift;
    00137 };
    00138
    00139 #endif