abstractwiring.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: abstractwiring.h,v $
00023  *   Revision 1.8  2008/09/16 15:37:29  martius
00024  *   added randomgen
00025  *
00026  *   Revision 1.7  2008/04/28 11:14:54  guettler
00027  *   removed include "abstractrobot.h" (not needed)
00028  *
00029  *   Revision 1.6  2008/04/17 14:54:45  martius
00030  *   randomGen added, which is a random generator with long period and an
00031  *    internal state. Each Agent has an instance and passed it to the controller
00032  *    and the wiring. This is good for
00033  *   a) repeatability on agent basis,
00034  *   b) parallel execution as done in ode_robots
00035  *
00036  *   Revision 1.5  2007/11/07 13:40:24  martius
00037  *   sensors and motors also added as type here (not very nice anyway)
00038  *
00039  *   Revision 1.4  2006/12/21 11:44:17  martius
00040  *   commenting style for doxygen //< -> ///<
00041  *   FOREACH and FOREACHC are macros for collection iteration
00042  *
00043  *   Revision 1.3  2006/07/20 17:14:36  martius
00044  *   removed std namespace from matrix.h
00045  *   storable interface
00046  *   abstract model and invertablemodel as superclasses for networks
00047  *
00048  *   Revision 1.2  2006/07/14 12:24:02  martius
00049  *   selforg becomes HEAD
00050  *
00051  *   Revision 1.1.2.1  2005/11/16 11:24:27  martius
00052  *   moved to selforg
00053  *
00054  *   Revision 1.8  2005/11/09 13:55:44  martius
00055  *   *** empty log message ***
00056  *
00057  *   Revision 1.7  2005/10/24 09:52:36  fhesse
00058  *   comments in doxygen
00059  *
00060  *   Revision 1.6  2005/10/06 17:11:36  martius
00061  *   switched to stl lists
00062  *
00063  *   Revision 1.5  2005/08/03 20:34:58  martius
00064  *   use if Inspectable interface
00065  *
00066  *   Revision 1.4  2005/07/21 15:14:47  martius
00067  *   wireSensors and wireMotors get constant fields
00068  *
00069  *   Revision 1.3  2005/07/18 14:44:27  martius
00070  *   noise moved into wiring
00071  *
00072  *   Revision 1.2  2005/07/18 10:14:45  martius
00073  *   noise is added here
00074  *
00075  *   Revision 1.1  2005/07/14 15:57:53  fhesse
00076  *   now agent contains controller, robot and wiring, plotting ability included, therefore plotagent can be removed; ono2onewiring replaces one2oneagent
00077  *                                            *
00078  *                                                                         *
00079  ***************************************************************************/
00080 #ifndef __ABSTRACTWIRING_H
00081 #define __ABSTRACTWIRING_H
00082 
00083 //#include "abstractrobot.h"
00084 #include "noisegenerator.h"
00085 #include "inspectable.h"
00086 #include "randomgenerator.h"
00087 
00088 /** Abstract wiring-object between controller and robot.
00089  *  Implements wiring of robot sensors to inputs of the controller and
00090  *  controller outputs to robot motors.
00091  */
00092 class AbstractWiring : public Inspectable {
00093 public:
00094   typedef double sensor;
00095   typedef double motor;
00096 
00097   /** constructor
00098    *  @param noise NoiseGenerator that is used for adding noise to sensor values
00099    */
00100   AbstractWiring(NoiseGenerator* noise){
00101     rsensornumber = 0;
00102     rmotornumber  = 0;
00103     csensornumber = 0;
00104     cmotornumber  = 0;
00105     noiseGenerator = noise;
00106   }
00107 
00108   /** destructor
00109    */
00110   virtual ~AbstractWiring(){
00111     if(noiseGenerator) delete noiseGenerator;
00112   }
00113 
00114   /** Initializes the  number of sensors and motors from robot
00115    *  (to be precise the internal parameters rsensornumber and rmotornumber!),
00116    *  calculates the number of sensors and motors on controller side.
00117    *  Must be overloaded to calculate and provide the appropriate numbers
00118    *  controllersensornumber (csensornumber), controllermotornumber (cmotornumber),
00119    *  robotsensornumber (rsensornumber) and robotmotornumber (rmotornumber),
00120    *  @param randGen pointer to random generator, if not given then a new one is created
00121    *  @return returns false on error, otherwise true
00122    */
00123   virtual bool init(int robotsensornumber, int robotmotornumber, RandGen* randGen=0) = 0;
00124 
00125   /** Realizes wiring from robot sensors to controller sensors.
00126    *   Must be overloaded in order to implement the appropriate mapping.
00127    *   @param rsensors pointer to array of sensorvalues from robot
00128    *   @param rsensornumber number of sensors from robot
00129    *   @param csensors pointer to array of sensorvalues for controller
00130    *   @param csensornumber number of sensors to controller
00131    *   @param noise size of the noise added to the sensors
00132    *  @return returns false on error, otherwise true
00133    */
00134   virtual bool wireSensors(const sensor* rsensors, int rsensornumber,
00135                            sensor* csensors, int csensornumber,
00136                            double noise) = 0;
00137 
00138   /** Realizes wiring from controller motor outputs to robot motors.
00139    *   Must be overloaded in order to implement the appropriate mapping.
00140    *   @param rmotors pointer to array of motorvalues for robot
00141    *   @param rmotornumber number of robot motors
00142    *   @param cmotors pointer to array of motorvalues from controller
00143    *   @param cmotornumber number of motorvalues from controller
00144    *   @return returns false if error, else true
00145    */
00146   virtual bool wireMotors(motor* rmotors, int rmotornumber,
00147                           const motor* cmotors, int cmotornumber)  = 0;
00148 
00149 
00150 
00151   /** Returns the number of sensors on robot side.
00152    */
00153   virtual int getRobotSensornumber(){return rsensornumber;}
00154 
00155   /** Returns the number of motors on robot side.
00156    */
00157   virtual int getRobotMotornumber() {return rmotornumber;}
00158 
00159   /** Returns the number of sensors on controller side.
00160    */
00161   virtual int getControllerSensornumber(){return csensornumber;}
00162 
00163   /** Returns the number of motors on controller side.
00164    */
00165   virtual int getControllerMotornumber() {return cmotornumber;}
00166 
00167   /** Returns the list of the names of all internal parameters.
00168    */
00169   virtual std::list<iparamkey> getInternalParamNames() const { return std::list<iparamkey>(); };
00170 
00171   /** Returns a list of the values of all internal parameters
00172       (in the order given by getInternalParamNames()).
00173    */
00174   virtual std::list<iparamval>  getInternalParams() const { return std::list<iparamval>(); };
00175 
00176 
00177 protected:
00178   /// number of sensors at robot side
00179   int rsensornumber;
00180 
00181   /// number of motors at robot side
00182   int rmotornumber;
00183 
00184   /// number of sensors at controller side
00185   int csensornumber;
00186 
00187   /// number of motors at controller side
00188   int cmotornumber;
00189 
00190   /// noise generator
00191   NoiseGenerator* noiseGenerator;
00192 
00193 };
00194 
00195 #endif

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