selectiveone2onewiring.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: selectiveone2onewiring.h,v $ 00023 * Revision 1.3 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.2 2006/07/14 12:24:02 martius 00028 * selforg becomes HEAD 00029 * 00030 * Revision 1.1.2.1 2005/11/16 11:24:28 martius 00031 * moved to selforg 00032 * 00033 * Revision 1.2 2005/10/24 13:32:07 fhesse 00034 * comments adjusted and in doxygen style 00035 * 00036 * Revision 1.1 2005/08/22 17:28:13 martius 00037 * a 1 to 1 wiring that supports the selection of some sensors only 00038 * 00039 * * 00040 ***************************************************************************/ 00041 #ifndef __SELECTIVEONE2ONEWIRING_H 00042 #define __SELECTIVEONE2ONEWIRING_H 00043 00044 #include "one2onewiring.h" 00045 #include <functional> 00046 00047 /** predicate to select sensors. 00048 First parameter is the index 00049 and the second parameter is the length (or number of sensors). 00050 */ 00051 struct select_predicate : public std::binary_function< int, int, bool> { 00052 virtual ~select_predicate(){} 00053 virtual bool operator()( int index, int len) { return true; } 00054 }; 00055 00056 struct select_all : public select_predicate { }; 00057 00058 struct select_firsthalf : public select_predicate { 00059 virtual ~select_firsthalf(){} 00060 virtual bool operator()( int index, int len) { return index < len/2; } 00061 }; 00062 00063 /// select sensors in the range \f[ [from, to] \f] (inclusively) 00064 struct select_from_to : public select_predicate { 00065 virtual ~select_from_to(){} 00066 select_from_to( int from, int to) : from(from), to(to) {} 00067 virtual bool operator()( int index, int len) { return (index >= from) && (index <= to); } 00068 int from; 00069 int to; 00070 }; 00071 00072 /** 00073 * Implements a selective one to one wireing of robot sensors to inputs of the controller 00074 * and controller outputs to robot motors. 00075 */ 00076 class SelectiveOne2OneWiring : public One2OneWiring{ 00077 public: 00078 /** constructor 00079 @param noise NoiseGenerator that is used for adding noise to sensor values 00080 @param sel_sensor binary predicate taking the index and the length (number of sensors) 00081 and decides which sensor to select 00082 */ 00083 SelectiveOne2OneWiring(NoiseGenerator* noise, select_predicate* sel_sensor); 00084 virtual ~SelectiveOne2OneWiring(); 00085 00086 /** initializes the number of sensors and motors on robot side, calculate 00087 number of sensors and motors on controller side 00088 */ 00089 virtual bool init(int robotsensornumber, int robotmotornumber); 00090 00091 /// Realizes one to one wiring from robot sensors to controller sensors. 00092 // @param rsensors pointer to array of sensorvalues from robot 00093 // @param rsensornumber number of sensors from robot 00094 // @param csensors pointer to array of sensorvalues for controller 00095 // @param csensornumber number of sensors to controller 00096 // @param noise size of the noise added to the sensors 00097 virtual bool wireSensors(const sensor* rsensors, int rsensornumber, 00098 sensor* csensors, int csensornumber, 00099 double noise); 00100 00101 protected: 00102 select_predicate* sel_sensor; 00103 00104 }; 00105 00106 #endif

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