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
datafunc.h
Go to the documentation of this file.
1 #ifndef __DATAFUNC_H
2 #define __DATAFUNC_H
3 
4 #include <vector>
5 #include "matrix.h"
6 
7 
8 /// INPUT / Output Data selectors
9 typedef matrix::Matrix (*DataFunc)(const std::vector<matrix::Matrix>& data, int time);
10 
11 matrix::Matrix tm1(const std::vector<matrix::Matrix>& data, int time){
12  assert(time>0);
13  return data[time-1];
14 }
15 
16 matrix::Matrix tm2(const std::vector<matrix::Matrix>& data, int time){
17  assert(time>1);
18  return data[time-2];
19 }
20 
21 matrix::Matrix tm12(const std::vector<matrix::Matrix>& data, int time){
22  assert(time>1);
23  return data[time-1].above(data[time-2]);
24 }
25 
26 matrix::Matrix tm123(const std::vector<matrix::Matrix>& data, int time){
27  assert(time>2);
28  return data[time-1].above(data[time-2].above(data[time-3]));
29 }
30 
31 matrix::Matrix tm125(const std::vector<matrix::Matrix>& data, int time){
32  assert(time>4);
33  return data[time-1].above(data[time-2].above(data[time-5]));
34 }
35 
36 
37 matrix::Matrix tm12345(const std::vector<matrix::Matrix>& data, int time){
38  assert(time>4);
39  return data[time-1].above(data[time-2].above(data[time-3].above(data[time-4].above(data[time-5]))));
40 }
41 
42 matrix::Matrix tm12358(const std::vector<matrix::Matrix>& data, int time){
43  assert(time>7);
44  return data[time-1].above(data[time-2].above(data[time-3].above(data[time-5].above(data[time-8]))));
45 }
46 
47 matrix::Matrix tm125_10_20(const std::vector<matrix::Matrix>& data, int time){
48  assert(time>19);
49  return data[time-1].above(data[time-2].above(data[time-5].above(data[time-10].above(data[time-20]))));
50 }
51 
52 matrix::Matrix tm1_to_20(const std::vector<matrix::Matrix>& data, int time){
53  assert(time>19);
54  matrix::Matrix rv=data[time-1];
55  for(int i=2; i<=20; i++){
56  rv = rv.above(data[time-i]);
57  }
58  return rv;
59 }
60 
61 // more selective filters
62 
63 matrix::Matrix ts01m1_to_10(const std::vector<matrix::Matrix>& data, int time){
64  assert(time>9);
65  matrix::Matrix rv=data[time].rows(0,1);
66  for(int i=1; i<=10; i++){
67  rv = rv.above(data[time-i]);
68  }
69  return rv;
70 }
71 
72 matrix::Matrix tm0_to_10s01(const std::vector<matrix::Matrix>& data, int time){
73  assert(time>9);
74  matrix::Matrix rv=data[time].rows(0,1);
75  for(int i=1; i<=10; i++){
76  rv = rv.above(data[time-i].rows(0,1));
77  }
78  return rv;
79 }
80 
81 
82 matrix::Matrix tm1s01_m2(const std::vector<matrix::Matrix>& data, int time){
83  assert(time>2);
84  return data[time-1].rows(0,1).above(data[time-2]);
85 }
86 
87 
88 matrix::Matrix ts01_m1s23(const std::vector<matrix::Matrix>& data, int time){
89  assert(time>2);
90  return data[time].rows(0,1).above(data[time-1].rows(2,3));
91 }
92 
93 matrix::Matrix tm1s23(const std::vector<matrix::Matrix>& data, int time){
94  assert(time>2);
95  return data[time-1].rows(2,3);
96 }
97 
98 
99 
100 // selector for current time only
101 
102 matrix::Matrix t(const std::vector<matrix::Matrix>& data, int time){
103  assert(time>=0);
104  return data[time];
105 }
106 
107 matrix::Matrix ts0(const std::vector<matrix::Matrix>& data, int time){
108  assert(time>=0);
109  return data[time].rows(0,0);
110 }
111 
112 matrix::Matrix ts1(const std::vector<matrix::Matrix>& data, int time){
113  assert(time>=0);
114  return data[time].rows(1,1);
115 }
116 
117 matrix::Matrix ts01(const std::vector<matrix::Matrix>& data, int time){
118  assert(time>=0);
119  return data[time].rows(0,1);
120 }
121 
122 matrix::Matrix ts012(const std::vector<matrix::Matrix>& data, int time){
123  assert(time>=0);
124  return data[time].rows(0,2);
125 }
126 
127 matrix::Matrix ts23(const std::vector<matrix::Matrix>& data, int time){
128  assert(time>=0);
129  return data[time].rows(2,3);
130 }
131 
132 matrix::Matrix tsfrom1(const std::vector<matrix::Matrix>& data, int time){
133  assert(time>=0);
134  return data[time].rows(1,data[time].getM());
135 }
136 
137 
138 DataFunc datafunctions(const std::string& name){
139  if(name=="tm1") return &tm1;
140  if(name=="tm1s23") return &tm1s23;
141  if(name=="tm2") return &tm2;
142  if(name=="tm12") return &tm12;
143  if(name=="tm123") return &tm123;
144  if(name=="tm125") return &tm125;
145  if(name=="tm12345") return &tm12345;
146  if(name=="tm12358") return &tm12358;
147  if(name=="tm125_10_20") return &tm125_10_20;
148  if(name=="tm1-20") return &tm1_to_20;
149  if(name=="ts01m1-10") return &ts01m1_to_10;
150  if(name=="tm0-10s01") return &tm0_to_10s01;
151  if(name=="tm1-10s01") return &tm0_to_10s01;
152  if(name=="tm1-10s01") return &tm0_to_10s01;
153  if(name=="tm1s01_m2") return &tm1s01_m2;
154  if(name=="ts01_m1s23") return &ts01_m1s23;
155  if(name=="t") return &t;
156  if(name=="ts0") return &ts0;
157  if(name=="ts1") return &ts1;
158  if(name=="ts01") return &ts01;
159  if(name=="ts012") return &ts012;
160  if(name=="ts23") return &ts23;
161  if(name=="ts1-") return &tsfrom1;
162  std::cerr << "Unknown Data-function: " << name << std::endl;
163  exit(1);
164  return 0;
165 }
166 
167 #endif
Matrix type.
Definition: matrix.h:65
matrix::Matrix ts23(const std::vector< matrix::Matrix > &data, int time)
Definition: datafunc.h:127
matrix::Matrix tm123(const std::vector< matrix::Matrix > &data, int time)
Definition: datafunc.h:26
matrix::Matrix ts01m1_to_10(const std::vector< matrix::Matrix > &data, int time)
Definition: datafunc.h:63
matrix::Matrix tm12345(const std::vector< matrix::Matrix > &data, int time)
Definition: datafunc.h:37
matrix::Matrix ts012(const std::vector< matrix::Matrix > &data, int time)
Definition: datafunc.h:122
Matrixd Matrix
Definition: osgforwarddecl.h:47
matrix::Matrix t(const std::vector< matrix::Matrix > &data, int time)
Definition: datafunc.h:102
matrix::Matrix tm12358(const std::vector< matrix::Matrix > &data, int time)
Definition: datafunc.h:42
matrix::Matrix tm125_10_20(const std::vector< matrix::Matrix > &data, int time)
Definition: datafunc.h:47
matrix::Matrix ts01_m1s23(const std::vector< matrix::Matrix > &data, int time)
Definition: datafunc.h:88
matrix::Matrix tm1s01_m2(const std::vector< matrix::Matrix > &data, int time)
Definition: datafunc.h:82
matrix::Matrix tm1(const std::vector< matrix::Matrix > &data, int time)
Definition: datafunc.h:11
matrix::Matrix tm12(const std::vector< matrix::Matrix > &data, int time)
Definition: datafunc.h:21
Matrix above(const Matrix &a) const
returns a matrix that consists of this matrix above A (number of rows is getM + a.getM())
Definition: matrix.cpp:700
matrix::Matrix tm0_to_10s01(const std::vector< matrix::Matrix > &data, int time)
Definition: datafunc.h:72
Matrix rows(I startindex, I endindex) const
Definition: matrix.cpp:116
matrix::Matrix ts01(const std::vector< matrix::Matrix > &data, int time)
Definition: datafunc.h:117
matrix::Matrix ts0(const std::vector< matrix::Matrix > &data, int time)
Definition: datafunc.h:107
DataFunc datafunctions(const std::string &name)
Definition: datafunc.h:138
matrix::Matrix tm1s23(const std::vector< matrix::Matrix > &data, int time)
Definition: datafunc.h:93
matrix::Matrix tsfrom1(const std::vector< matrix::Matrix > &data, int time)
Definition: datafunc.h:132
matrix::Matrix(* DataFunc)(const std::vector< matrix::Matrix > &data, int time)
INPUT / Output Data selectors.
Definition: datafunc.h:9
matrix::Matrix tm125(const std::vector< matrix::Matrix > &data, int time)
Definition: datafunc.h:31
matrix::Matrix tm1_to_20(const std::vector< matrix::Matrix > &data, int time)
Definition: datafunc.h:52
matrix::Matrix tm2(const std::vector< matrix::Matrix > &data, int time)
Definition: datafunc.h:16
matrix::Matrix ts1(const std::vector< matrix::Matrix > &data, int time)
Definition: datafunc.h:112