selectivenoisewiring.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: selectivenoisewiring.h,v $
00023  *   Revision 1.1  2010/04/01 14:54:10  martius
00024  *   wiring to add noise only to some sensor values
00025  *
00026  *                                                                         *
00027  ***************************************************************************/
00028 #ifndef __SELECTIVENOISEWIRING_H
00029 #define __SELECTIVENOISEWIRING_H
00030 
00031 #include <selforg/one2onewiring.h>
00032 #include <vector>
00033 
00034 /** 
00035  * Implements a one to one wiring 
00036  *  and allows to select the noise strength per sensor channel
00037  */
00038 class SelectiveNoiseWiring : public One2OneWiring {
00039 public:
00040   /** constructor
00041       @param noise NoiseGenerator that is used for adding noise to motor values  
00042       @param noiseStrengths for each channel the noise strength 
00043        (no noise if channel is out of array bounds)
00044       @param plotMode see AbstractWiring 
00045   */
00046   SelectiveNoiseWiring(NoiseGenerator* noise, std::vector<double> noiseStrengths, 
00047                        int plotMode=Controller)
00048     : One2OneWiring(noise, plotMode), noiseStrengths(noiseStrengths) {    
00049   }
00050   virtual ~SelectiveNoiseWiring(){}
00051   
00052   virtual bool wireSensorsIntern(const sensor* rsensors, int rsensornumber, 
00053                                  sensor* csensors, int csensornumber, double noise){
00054     assert(rsensornumber == this->rsensornumber);
00055     assert(csensornumber == this->csensornumber);
00056     // the noisevals are set in abstractwiring
00057     for(int i=0; i< rsensornumber; i++){
00058       csensors[i] = rsensors[i] + getNoiseStrength(i)*noisevals[i];
00059     }
00060     return true;  
00061   }
00062   
00063 protected:
00064   double getNoiseStrength(unsigned int i){
00065     if(i>=noiseStrengths.size()) return 0;
00066     else return noiseStrengths[i];
00067   }
00068 
00069   std::vector<double> noiseStrengths;
00070 
00071 };
00072 
00073 #endif
Generated on Fri Nov 4 10:59:39 2011 for Robot Simulator of the Robotics Group for Self-Organization of Control by  doxygen 1.6.3