iCub-main
Loading...
Searching...
No Matches
expected_values.cpp
Go to the documentation of this file.
1#include "expected_values.h"
2#include <fstream>
3#include <string>
4
5using namespace std;
6
8{
9 for (int i=0; i<6;i++)
10 {
11 this->dat[i]=val.dat[i];
12 }
13}
14
15
17{
18 if (this != &rhs)
19 {
20 for (int i=0; i<6;i++)
21 {
22 this->dat[i]=rhs.dat[i];
23 }
24 }
25 return *this;
26 }
27
29{
30 for (int i=0; i<6;i++)
31 {
32 this->dat[i]=val.dat[i];
33 }
34}
35
37{
38 if (this != &rhs)
39 {
40 for (int i=0; i<6;i++)
41 {
42 this->dat[i]=rhs.dat[i];
43 }
44 }
45 return *this;
46}
47
49{
50 return serialnumber;
51}
52
54{
55 low = threshold1;
56 high = threshold2;
57 return true;
58}
59
60bool expected_values_handler_class::init (const char* filename)
61{
62 fstream filestr;
63 filestr.open (filename, fstream::in);
64 if (!filestr.is_open())
65 {
66 printf ("ERR: Error opening calibration file!\n");
67 return false;
68 }
69 string dummy;
70 getline(filestr,dummy);
71 filestr >> serialnumber;
72 for (int iy=0; iy<24; iy++)
73 for (int ix=0; ix<6; ix++)
74 {
75 filestr >> expected_values[ix][iy] ;
76 }
77 filestr >> threshold1;
78 filestr >> threshold2;
79 filestr.close();
80 return true;
81}
82
83const int expected_values_handler_class::def_expected_values[24][6] =
84{
85 { 931, -507, -307, 14885, -12784, -343},
86 { 16631, 230, 136, -7092, -6761, 411},
87 { 993, 498, 306, -12746, 14284, 305},
88 { -14751, -192, -157, 8300, 9075, -318},
89 { 1878, -11736, -12750, -1082, -1094, -10751},
90 { 21743, 34, -1466, -10741, -11008, 1930},
91 { 2412, 11706, 10117, -1084, -1100, 13498 },
92 { 165, -13228, -10733, -1710, 1244, -11357 },
93 { 317, 104, 2290, -19036, 18501, 2058 },
94 { -197, 10213, 12250, -1024, 1475, 12757 },
95 { -1667, -11801, -10300, 529, 861, -13321 },
96 { -21130, -548, 715, 10458, 10580, -1909 },
97 { -1823, 11652, 12624, 1238, 850, 10776 },
98 { -126, -10361, -12255, 1081, -1241, -12982 },
99 { -248, 1125, -770, 19444, -18813, -1028 },
100 { -40, 13101, 10689, 1579, -1282, 11221 },
101 { -4547, -67, 127, -4147, -3907, -58 },
102 { 3606, 9, -113, 5524, 3660, -4 },
103 { 5998, -175, -6057, -3030, -2944, 5825 },
104 { -6024, -671, 5128, 3146, 3065, -6575 },
105 { -3555, 5211, -781, 6951, -3239, -6910 },
106 { 3410, -5896, 75, -6527, 3191, 6047 },
107 { -3013, -6115, 5825, -3059, 6219, -53 },
108 { 3143, 5366, -6349, 3156, -6222, -691 }
109};
110
111const int expected_values_handler_class::def_expected_values_thresholds[2] =
112{
113 2000,
114 4000
115};
116
118{
119 serialnumber = std::string("default");
120
121 for(int iy=0; iy<24; iy++)
122 {
123 for(int ix=0; ix<6; ix++)
124 {
125 expected_values[ix][iy] = def_expected_values[iy][ix];
126 }
127 }
128
129 threshold1 = def_expected_values_thresholds[0];
130 threshold2 = def_expected_values_thresholds[1];
131
132 return true;
133}
134
138
140{
141 if (trial<0 || trial>=25) trial=0;
142
143 int count=0;
144 for (int i=0; i<6; i++)
145 {
146 in_bound.dat[i]=0;
147 diff.dat[i]=(values.dat[i]-expected_values[i][trial]);
148 if (abs(diff.dat[i])< threshold1)
149 {
150 in_bound.dat[i]=1; //green condition
151 count++;
152 }
153 else if (abs(diff.dat[i])> threshold1 && abs(diff.dat[i])< threshold2)
154 {
155 in_bound.dat[i]=2; //yellow condition
156 count++;
157 }
158 else
159 {
160 in_bound.dat[i]=0; //red condition, no counter increment
161 }
162 }
163
164 if (count==6) return true;
165 else return false;
166}
167
169{
170 int i=0;
171 if (trial<0 || trial>=25) trial=0;
172 for (i=0; i<6; i++)
173 {
174 values.dat[i]=expected_values[i][trial];
175 }
176}
bool get_thresholds(int &low, int &high)
void get_current_expected_values(signed_elem_class &values, int trial)
bool check_vals(signed_elem_class values, int trial, signed_elem_class &diff, signed_elem_class &in_bound)
signed short dat[6]
signed_elem_class & operator=(const signed_elem_class &rhs)
unsigned short dat[6]
unsigned_elem_class & operator=(const unsigned_elem_class &rhs)