Robot Simulator of the Robotics Group for Self-Organization of Control  0.8.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
selectivenoisewiring.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005-2011 LpzRobots development team *
3  * Georg Martius <georg dot martius at web dot de> *
4  * Frank Guettler <guettler at informatik dot uni-leipzig dot de *
5  * Frank Hesse <frank at nld dot ds dot mpg dot de> *
6  * Ralf Der <ralfder at mis dot mpg dot de> *
7  * *
8  * This program is free software; you can redistribute it and/or modify *
9  * it under the terms of the GNU General Public License as published by *
10  * the Free Software Foundation; either version 2 of the License, or *
11  * (at your option) any later version. *
12  * *
13  * This program is distributed in the hope that it will be useful, *
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16  * GNU General Public License for more details. *
17  * *
18  * You should have received a copy of the GNU General Public License *
19  * along with this program; if not, write to the *
20  * Free Software Foundation, Inc., *
21  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
22  * *
23  ***************************************************************************/
24 #ifndef __SELECTIVENOISEWIRING_H
25 #define __SELECTIVENOISEWIRING_H
26 
27 #include <selforg/one2onewiring.h>
28 #include <vector>
29 
30 /**
31  * Implements a one to one wiring
32  * and allows to select the noise strength per sensor channel
33  */
35 public:
36  /** constructor
37  @param noise NoiseGenerator that is used for adding noise to motor values
38  @param noiseStrengths for each channel the noise strength
39  (no noise if channel is out of array bounds)
40  @param plotMode see AbstractWiring
41  */
42  SelectiveNoiseWiring(NoiseGenerator* noise, std::vector<double> noiseStrengths,
43  int plotMode=Controller)
44  : One2OneWiring(noise, plotMode), noiseStrengths(noiseStrengths) {
45  }
47 
48  virtual bool wireSensorsIntern(const sensor* rsensors, int rsensornumber,
49  sensor* csensors, int csensornumber, double noise){
50  assert(rsensornumber == this->rsensornumber);
51  assert(csensornumber == this->csensornumber);
52  // the noisevals are set in abstractwiring
53  for(int i=0; i< rsensornumber; i++){
54  csensors[i] = rsensors[i] + getNoiseStrength(i)*noisevals[i];
55  }
56  return true;
57  }
58 
59 protected:
60  double getNoiseStrength(unsigned int i){
61  if(i>=noiseStrengths.size()) return 0;
62  else return noiseStrengths[i];
63  }
64 
65  std::vector<double> noiseStrengths;
66 
67 };
68 
69 #endif
Implements one to one wiring of robot sensors to inputs of the controller and controller outputs to r...
Definition: one2onewiring.h:32
int csensornumber
number of sensors at controller side
Definition: abstractwiring.h:187
int plotMode
using plotTypes this variables defines what is plotted
Definition: abstractwiring.h:168
virtual bool wireSensorsIntern(const sensor *rsensors, int rsensornumber, sensor *csensors, int csensornumber, double noise)
Realizes one to one wiring from robot sensors to controller sensors.
Definition: selectivenoisewiring.h:48
Implements a one to one wiring and allows to select the noise strength per sensor channel...
Definition: selectivenoisewiring.h:34
double getNoiseStrength(unsigned int i)
Definition: selectivenoisewiring.h:60
sensor * noisevals
Definition: abstractwiring.h:172
SelectiveNoiseWiring(NoiseGenerator *noise, std::vector< double > noiseStrengths, int plotMode=Controller)
constructor
Definition: selectivenoisewiring.h:42
Definition: abstractwiring.h:44
int rsensornumber
number of sensors at robot side
Definition: abstractwiring.h:177
virtual ~SelectiveNoiseWiring()
Definition: selectivenoisewiring.h:46
double sensor
Definition: abstractwiring.h:41
std::vector< double > noiseStrengths
Definition: selectivenoisewiring.h:65
Interface and basic class for noise generator.
Definition: noisegenerator.h:37