selectivenoisewiring.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2005-2011 LpzRobots development team                    *
00003  *    Georg Martius  <georg dot martius at web dot de>                     *
00004  *    Frank Guettler <guettler at informatik dot uni-leipzig dot de        *
00005  *    Frank Hesse    <frank at nld dot ds dot mpg dot de>                  *
00006  *    Ralf Der       <ralfder at mis dot mpg dot de>                       *
00007  *                                                                         *
00008  *   This program is free software; you can redistribute it and/or modify  *
00009  *   it under the terms of the GNU General Public License as published by  *
00010  *   the Free Software Foundation; either version 2 of the License, or     *
00011  *   (at your option) any later version.                                   *
00012  *                                                                         *
00013  *   This program is distributed in the hope that it will be useful,       *
00014  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00015  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00016  *   GNU General Public License for more details.                          *
00017  *                                                                         *
00018  *   You should have received a copy of the GNU General Public License     *
00019  *   along with this program; if not, write to the                         *
00020  *   Free Software Foundation, Inc.,                                       *
00021  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00022  *                                                                         *
00023  ***************************************************************************/
00024 #ifndef __SELECTIVENOISEWIRING_H
00025 #define __SELECTIVENOISEWIRING_H
00026 
00027 #include <selforg/one2onewiring.h>
00028 #include <vector>
00029 
00030 /** 
00031  * Implements a one to one wiring 
00032  *  and allows to select the noise strength per sensor channel
00033  */
00034 class SelectiveNoiseWiring : public One2OneWiring {
00035 public:
00036   /** constructor
00037       @param noise NoiseGenerator that is used for adding noise to motor values  
00038       @param noiseStrengths for each channel the noise strength 
00039        (no noise if channel is out of array bounds)
00040       @param plotMode see AbstractWiring 
00041   */
00042   SelectiveNoiseWiring(NoiseGenerator* noise, std::vector<double> noiseStrengths, 
00043                        int plotMode=Controller)
00044     : One2OneWiring(noise, plotMode), noiseStrengths(noiseStrengths) {    
00045   }
00046   virtual ~SelectiveNoiseWiring(){}
00047   
00048   virtual bool wireSensorsIntern(const sensor* rsensors, int rsensornumber, 
00049                                  sensor* csensors, int csensornumber, double noise){
00050     assert(rsensornumber == this->rsensornumber);
00051     assert(csensornumber == this->csensornumber);
00052     // the noisevals are set in abstractwiring
00053     for(int i=0; i< rsensornumber; i++){
00054       csensors[i] = rsensors[i] + getNoiseStrength(i)*noisevals[i];
00055     }
00056     return true;  
00057   }
00058   
00059 protected:
00060   double getNoiseStrength(unsigned int i){
00061     if(i>=noiseStrengths.size()) return 0;
00062     else return noiseStrengths[i];
00063   }
00064 
00065   std::vector<double> noiseStrengths;
00066 
00067 };
00068 
00069 #endif
Generated on Thu Jun 28 14:45:37 2012 for Robot Simulator of the Robotics Group for Self-Organization of Control by  doxygen 1.6.3