abstractcontroller.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: abstractcontroller.h,v $
00023  *   Revision 1.12.6.3  2006/03/30 12:35:12  martius
00024  *   documentation updated
00025  *
00026  *   Revision 1.12.6.2  2006/01/18 16:48:10  martius
00027  *   configurables can be stored and reloaded
00028  *
00029  *   Revision 1.12.6.1  2006/01/17 16:58:39  martius
00030  *   loading and storing
00031  *
00032  *   Revision 1.12  2005/08/06 20:47:54  martius
00033  *   Commented
00034  *
00035  *   Revision 1.11  2005/08/03 20:28:57  martius
00036  *   inspectable interface
00037  *
00038  *   Revision 1.10  2005/06/21 15:31:11  martius
00039  *   getSensorNumber and getMotorMumber added controller interface
00040  *
00041  *   Revision 1.9  2005/06/20 09:04:16  martius
00042  *   init function added to controller-interface
00043  *
00044  *   Revision 1.8  2005/06/17 10:45:22  martius
00045  *   GPL added
00046  *                                                                 *
00047  ***************************************************************************/
00048 #ifndef __ABSTRACTCONTROLLER_H
00049 #define __ABSTRACTCONTROLLER_H
00050 
00051 #include <stdio.h>
00052 #include "configurable.h"
00053 #include "inspectable.h"
00054 
00055 typedef double sensor;
00056 typedef double motor;
00057 
00058 /**
00059  * Abstract class (interface) for robot controller.
00060  * The controller gets a number of input sensor values each timestep
00061  *  and has to generate a number of output motor values.
00062  *
00063  * Interface assumes the following usage:
00064  *  - init is called first to initialise the dimension of sensor- and motor space
00065  *  - each time step
00066  *     either step() or stepNoLearning() is called to ask the controller for motor values. 
00067  */
00068 class AbstractController : public Configurable, public Inspectable {
00069 public:
00070   /** initialisation of the controller with the given sensor/ motornumber 
00071       Must be called before use.
00072   */
00073   virtual void init(int sensornumber, int motornumber) ABSTRACT;
00074   
00075   /** @return Number of sensors the controller 
00076       was initialised with or 0 if not initialised */
00077   virtual int getSensorNumber() const ABSTRACT;
00078 
00079   /** @return Number of motors the controller
00080       was initialised with or 0 if not initialised */
00081   virtual int getMotorNumber() const ABSTRACT;
00082 
00083   /** performs one step (includes learning). 
00084       Calculates motor commands from sensor inputs.
00085       @param sensors sensors inputs scaled to [-1,1]
00086       @param sensornumber length of the sensor array
00087       @param motors motors outputs. MUST have enough space for motor values!
00088       @param motornumber length of the provided motor array
00089   */
00090   virtual void step(const sensor* sensors, int sensornumber, 
00091                     motor* motors, int motornumber) ABSTRACT;
00092   /** performs one step without learning. 
00093       @see step
00094   */
00095   virtual void stepNoLearning(const sensor* , int number_sensors, 
00096                               motor* , int number_motors) ABSTRACT;
00097 
00098   /** stores the controller values to a given file. 
00099       This should include internal parameters.
00100   */
00101   virtual bool store(const char* filename) ABSTRACT;
00102 
00103   /** loads the controller values from a given file. 
00104       This should include internal parameters
00105   */
00106   virtual bool restore(const char* filename) ABSTRACT;  
00107 
00108 
00109   
00110 };
00111 
00112 #endif

Generated on Tue Apr 4 19:05:03 2006 for Robotsystem from Robot Group Leipzig by  doxygen 1.4.5