Robotsystem of the Robot Group Leipzig: datafunc.h Source File

- Main Page
- Namespaces
- Classes
- Files
- Directories
- Related Pages
- Examples

- Search for |

- File List
- File Members

# datafunc.h

Go to the documentation of this file.

    00001 #ifndef __DATAFUNC_H
    00002 #define __DATAFUNC_H
    00003
    00004 #include <vector>
    00005 #include "matrix.h"
    00006
    00007
    00008 /// INPUT / Output Data selectors
    00009 typedef matrix::Matrix (*DataFunc)(const std::vector<matrix::Matrix>& data, int time);
    00010
    00011 matrix::Matrix tm1(const std::vector<matrix::Matrix>& data, int time){
    00012   assert(time>0);
    00013   return data[time-1];
    00014 }
    00015
    00016 matrix::Matrix tm2(const std::vector<matrix::Matrix>& data, int time){
    00017   assert(time>1);
    00018   return data[time-2];
    00019 }
    00020
    00021 matrix::Matrix tm12(const std::vector<matrix::Matrix>& data, int time){
    00022   assert(time>1);
    00023   return data[time-1].above(data[time-2]);
    00024 }
    00025
    00026 matrix::Matrix tm123(const std::vector<matrix::Matrix>& data, int time){
    00027   assert(time>2);
    00028   return data[time-1].above(data[time-2].above(data[time-3]));
    00029 }
    00030
    00031 matrix::Matrix tm125(const std::vector<matrix::Matrix>& data, int time){
    00032   assert(time>4);
    00033   return data[time-1].above(data[time-2].above(data[time-5]));
    00034 }
    00035
    00036
    00037 matrix::Matrix tm12345(const std::vector<matrix::Matrix>& data, int time){
    00038   assert(time>4);
    00039   return data[time-1].above(data[time-2].above(data[time-3].above(data[time-4].above(data[time-5]))));
    00040 }
    00041
    00042 matrix::Matrix tm12358(const std::vector<matrix::Matrix>& data, int time){
    00043   assert(time>7);
    00044   return data[time-1].above(data[time-2].above(data[time-3].above(data[time-5].above(data[time-8]))));
    00045 }
    00046
    00047 matrix::Matrix tm125_10_20(const std::vector<matrix::Matrix>& data, int time){
    00048   assert(time>19);
    00049   return data[time-1].above(data[time-2].above(data[time-5].above(data[time-10].above(data[time-20]))));
    00050 }
    00051
    00052 matrix::Matrix tm1_to_20(const std::vector<matrix::Matrix>& data, int time){
    00053   assert(time>19);
    00054   matrix::Matrix rv=data[time-1];
    00055   for(int i=2; i<=20; i++){
    00056     rv = rv.above(data[time-i]);
    00057   }
    00058   return rv;
    00059 }
    00060
    00061 // more selective filters
    00062
    00063 matrix::Matrix ts01m1_to_10(const std::vector<matrix::Matrix>& data, int time){
    00064   assert(time>9);
    00065   matrix::Matrix rv=data[time].rows(0,1);
    00066   for(int i=1; i<=10; i++){
    00067     rv = rv.above(data[time-i]);
    00068   }
    00069   return rv;
    00070 }
    00071
    00072 matrix::Matrix tm0_to_10s01(const std::vector<matrix::Matrix>& data, int time){
    00073   assert(time>9);
    00074   matrix::Matrix rv=data[time].rows(0,1);
    00075   for(int i=1; i<=10; i++){
    00076     rv = rv.above(data[time-i].rows(0,1));
    00077   }
    00078   return rv;
    00079 }
    00080
    00081
    00082 matrix::Matrix tm1s01_m2(const std::vector<matrix::Matrix>& data, int time){
    00083   assert(time>2);
    00084   return data[time-1].rows(0,1).above(data[time-2]);
    00085 }
    00086
    00087
    00088 matrix::Matrix ts01_m1s23(const std::vector<matrix::Matrix>& data, int time){
    00089   assert(time>2);
    00090   return data[time].rows(0,1).above(data[time-1].rows(2,3));
    00091 }
    00092
    00093 matrix::Matrix tm1s23(const std::vector<matrix::Matrix>& data, int time){
    00094   assert(time>2);
    00095   return data[time-1].rows(2,3);
    00096 }
    00097
    00098
    00099
    00100 // selector for current time only
    00101
    00102 matrix::Matrix t(const std::vector<matrix::Matrix>& data, int time){
    00103   assert(time>=0);
    00104   return data[time];
    00105 }
    00106
    00107 matrix::Matrix ts0(const std::vector<matrix::Matrix>& data, int time){
    00108   assert(time>=0);
    00109   return data[time].rows(0,0);
    00110 }
    00111
    00112 matrix::Matrix ts1(const std::vector<matrix::Matrix>& data, int time){
    00113   assert(time>=0);
    00114   return data[time].rows(1,1);
    00115 }
    00116
    00117 matrix::Matrix ts01(const std::vector<matrix::Matrix>& data, int time){
    00118   assert(time>=0);
    00119   return data[time].rows(0,1);
    00120 }
    00121
    00122 matrix::Matrix ts012(const std::vector<matrix::Matrix>& data, int time){
    00123   assert(time>=0);
    00124   return data[time].rows(0,2);
    00125 }
    00126
    00127 matrix::Matrix ts23(const std::vector<matrix::Matrix>& data, int time){
    00128   assert(time>=0);
    00129   return data[time].rows(2,3);
    00130 }
    00131
    00132 matrix::Matrix tsfrom1(const std::vector<matrix::Matrix>& data, int time){
    00133   assert(time>=0);
    00134   return data[time].rows(1,data[time].getM());
    00135 }
    00136
    00137
    00138 DataFunc datafunctions(const std::string& name){
    00139   if(name=="tm1") return &tm1;
    00140   if(name=="tm1s23") return &tm1s23;
    00141   if(name=="tm2") return &tm2;
    00142   if(name=="tm12") return &tm12;
    00143   if(name=="tm123") return &tm123;
    00144   if(name=="tm125") return &tm125;
    00145   if(name=="tm12345") return &tm12345;
    00146   if(name=="tm12358") return &tm12358;
    00147   if(name=="tm125_10_20") return &tm125_10_20;
    00148   if(name=="tm1-20") return &tm1_to_20;
    00149   if(name=="ts01m1-10") return &ts01m1_to_10;
    00150   if(name=="tm0-10s01") return &tm0_to_10s01;
    00151   if(name=="tm1-10s01") return &tm0_to_10s01;
    00152   if(name=="tm1-10s01") return &tm0_to_10s01;
    00153   if(name=="tm1s01_m2") return &tm1s01_m2;
    00154   if(name=="ts01_m1s23") return &ts01_m1s23;
    00155   if(name=="t") return &t;
    00156   if(name=="ts0") return &ts0;
    00157   if(name=="ts1") return &ts1;
    00158   if(name=="ts01") return &ts01;
    00159   if(name=="ts012") return &ts012;
    00160   if(name=="ts23") return &ts23;
    00161   if(name=="ts1-") return &tsfrom1;
    00162   std::cerr << "Unknown Data-function: " << name << std::endl;
    00163   exit(1);
    00164   return 0;
    00165 }
    00166
    00167 #endif