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

Generated on Mon Aug 7 16:40:14 2006 for Robotsystem of the Robot Group Leipzig by  doxygen 1.4.7