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

Generated on Tue Jan 16 02:14:34 2007 for Robotsystem of the Robot Group Leipzig by doxygen 1.3.8