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

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