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
selectiveone2onewiring.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 __SELECTIVEONE2ONEWIRING_H
25 #define __SELECTIVEONE2ONEWIRING_H
26 
27 #include "one2onewiring.h"
28 #include <functional>
29 
30 /** predicate to select sensors.
31  First parameter is the index
32  and the second parameter is the length (or number of sensors).
33 */
34 struct select_predicate : public std::binary_function< int, int, bool> {
35  virtual ~select_predicate(){}
36  virtual bool operator()( int index, int len) { return true; }
37 };
38 
39 struct select_all : public select_predicate { };
40 
42  virtual ~select_firsthalf(){}
43  virtual bool operator()( int index, int len) { return index < len/2; }
44 };
45 
46 /// select sensors in the range \f[ [from, to] \f] (inclusively)
48  virtual ~select_from_to(){}
49  select_from_to( int from, int to) : from(from), to(to) {}
50  virtual bool operator()( int index, int len) { return (index >= from) && (index <= to); }
51  int from;
52  int to;
53 };
54 
55 /**
56  * Implements a selective one to one wiring of robot sensors to inputs of the controller
57  * and controller outputs to robot motors.
58  */
60 public:
61  /** constructor
62  @param noise NoiseGenerator that is used for adding noise to sensor values
63  @param sel_sensor binary predicate taking the index and the length (number of sensors)
64  and decides which sensor to select
65  */
66  SelectiveOne2OneWiring(NoiseGenerator* noise, select_predicate* sel_sensor, int plotMode = Controller, const std::string& name = "SelectiveOne2OneWiring");
67  virtual ~SelectiveOne2OneWiring();
68 
69 protected:
70  virtual bool initIntern();
71 
72  virtual bool wireSensorsIntern(const sensor* rsensors, int rsensornumber,
73  sensor* csensors, int csensornumber,
74  double noise);
75 
76 protected:
78 
79 };
80 
81 #endif
predicate to select sensors.
Definition: selectiveone2onewiring.h:34
Implements one to one wiring of robot sensors to inputs of the controller and controller outputs to r...
Definition: one2onewiring.h:32
select sensors in the range (inclusively)
Definition: selectiveone2onewiring.h:47
virtual bool operator()(int index, int len)
Definition: selectiveone2onewiring.h:36
virtual ~select_predicate()
Definition: selectiveone2onewiring.h:35
int csensornumber
number of sensors at controller side
Definition: abstractwiring.h:187
select_predicate * sel_sensor
Definition: selectiveone2onewiring.h:77
Definition: selectiveone2onewiring.h:39
Implements a selective one to one wiring of robot sensors to inputs of the controller and controller ...
Definition: selectiveone2onewiring.h:59
int plotMode
using plotTypes this variables defines what is plotted
Definition: abstractwiring.h:168
iparamkey name
Definition: inspectable.h:251
virtual ~select_firsthalf()
Definition: selectiveone2onewiring.h:42
virtual ~select_from_to()
Definition: selectiveone2onewiring.h:48
virtual bool wireSensorsIntern(const sensor *rsensors, int rsensornumber, sensor *csensors, int csensornumber, double noise)
Realizes selective one to one wiring from robot sensors to controller sensors.
Definition: selectiveone2onewiring.cpp:61
SelectiveOne2OneWiring(NoiseGenerator *noise, select_predicate *sel_sensor, int plotMode=Controller, const std::string &name="SelectiveOne2OneWiring")
constructor
Definition: selectiveone2onewiring.cpp:30
int to
Definition: selectiveone2onewiring.h:52
int from
Definition: selectiveone2onewiring.h:51
virtual bool initIntern()
initializes the number of sensors and motors on robot side, calculate
Definition: selectiveone2onewiring.cpp:44
virtual ~SelectiveOne2OneWiring()
Definition: selectiveone2onewiring.cpp:37
Definition: abstractwiring.h:44
Definition: selectiveone2onewiring.h:41
int rsensornumber
number of sensors at robot side
Definition: abstractwiring.h:177
double sensor
Definition: abstractwiring.h:41
select_from_to(int from, int to)
Definition: selectiveone2onewiring.h:49
virtual bool operator()(int index, int len)
Definition: selectiveone2onewiring.h:43
virtual bool operator()(int index, int len)
Definition: selectiveone2onewiring.h:50
Interface and basic class for noise generator.
Definition: noisegenerator.h:37