76 if (s1 == s2 && s2 == s3 && s3 == s4 && s4 == s5 && s5 == s6) {
81 <<
"PndLmdSensorAligner::calculateMatrix::FATAL. Pair sorting error, pairs vectors have different sizes.\n";
82 cout <<
"s1: " << s1 <<
"\n";
83 cout <<
"s2: " << s2 <<
"\n";
84 cout <<
"s3: " << s3 <<
"\n";
85 cout <<
"s4: " << s4 <<
"\n";
86 cout <<
"s5: " << s5 <<
"\n";
87 cout <<
"s6: " << s6 <<
"\n";
92 cout <<
"=====================================================\n";
93 cout <<
"WARNING! Invalid pairs in pair file, check your data!\n";
94 cout <<
"=====================================================\n";
102 bool eventTimeCheck =
true;
103 double minDelta = 1e-6;
114 <<
"PndLmdSensrAligner::Error: Trying to use less than 5 pairs! (And that's not going to work.) Aborting.\n";
122 double* Model =
new double[dim * nPairs];
123 double* Template =
new double[dim * nPairs];
126 cout <<
"arranging pairs...\n";
129 cout <<
"num pairs from dec: " << nPairs <<
"\n";
133 for (
int ipair = 0; ipair < nPairs; ipair++) {
142 for (
int ipair = 0; ipair < nPairs; ipair++) {
145 Model[ipair * dim + 2] = (double) ipair;
148 Template[ipair * dim + 2] = (double) ipair;
156 if (
verbose == 3) cout <<
"applying artificial Z coordinate...\n";
158 for (
int ipair = 0; ipair < nPairs; ipair++) {
159 Model[ipair * dim + 2] = ((2.0 * ipair / (double) nPairs - 1.0) * 1e4);
160 Template[ipair * dim + 2] = ((2.0 * ipair / (double) nPairs - 1.0) * 1e4);
165 int modxinv = 0, modyinv = 0, modzinv = 0;
166 int temxinv = 0, temyinv = 0, temzinv = 0;
174 if (
verbose == 3) cout <<
"checking for zero values...\n";
176 for (
int iCheck = 0; iCheck < dim * nPairs; iCheck++) {
177 double val1 = abs(Model[iCheck]);
178 double val2 = abs(Template[iCheck]);
180 if (iCheck % 3 == 0) {
184 if (iCheck % 3 == 1) {
188 if (iCheck % 3 == 2) {
196 if (iCheck % 3 == 0) {
200 if (iCheck % 3 == 1) {
204 if (iCheck % 3 == 2) {
214 double zeroFactor = zeroVals / ((double) nPairs * 6.0);
215 if (zeroFactor > 0.1 && zeroFactor < 0.3) {
216 cout <<
"WARNING. More than 10 % of your entries is zero. That must be a mistake. \n";
217 cout <<
"Also, the kdtree creation could crash. Keep an eye out for that...\n";
218 cout <<
"Zero factor: " << zeroFactor <<
"\n";
219 cout <<
"model x vals invalid: " << modxinv / (double) nPairs <<
"\n";
220 cout <<
"model y vals invalid: " << modyinv / (double) nPairs <<
"\n";
221 cout <<
"model z vals invalid: " << modzinv / (double) nPairs <<
"\n";
222 cout <<
"templ x vals invalid: " << temxinv / (double) nPairs <<
"\n";
223 cout <<
"templ y vals invalid: " << temyinv / (double) nPairs <<
"\n";
224 cout <<
"templ z vals invalid: " << temzinv / (double) nPairs <<
"\n";
227 if (zeroFactor > 0.3) {
228 cout <<
"ERROR. More than 30 % of your entries is zero. That must be a mistake. \n";
229 cout <<
"Also, the kdtree creation will crash. Exiting.\n";
230 cout <<
"Zero factor: " << zeroFactor <<
"\n";
231 cout <<
"model x vals invalid: " << modxinv / (double) nPairs <<
"\n";
232 cout <<
"model y vals invalid: " << modyinv / (double) nPairs <<
"\n";
233 cout <<
"model z vals invalid: " << modzinv / (double) nPairs <<
"\n";
234 cout <<
"templ x vals invalid: " << temxinv / (double) nPairs <<
"\n";
235 cout <<
"templ y vals invalid: " << temyinv / (double) nPairs <<
"\n";
236 cout <<
"templ z vals invalid: " << temzinv / (double) nPairs <<
"\n";
237 cout <<
"=== additional data ===\n";
238 cout <<
"overlap id: " <<
overlapID <<
"\n";
239 cout <<
"no of Pairs: " << nPairs <<
"\n";
258 cout <<
"creating ICP...\n";
270 if (
verbose == 3) cout <<
"ICP and model created...\n";
276 translation =
Matrix(2, 1);
280 translation =
Matrix(3, 1);
284 icp.fit(Template, nPairs, Rotation, translation, -1);
286 if (
verbose == 3) cout <<
"ICP fit step done.\n";
291 double* tempR =
new double[4];
292 double* tempT =
new double[2];
297 double* finalMatrix =
new double[16];
300 finalMatrix[0] = tempR[0];
301 finalMatrix[1] = tempR[1];
303 finalMatrix[3] = tempT[0];
304 finalMatrix[4] = tempR[2];
305 finalMatrix[5] = tempR[3];
307 finalMatrix[7] = tempT[1];
310 finalMatrix[10] = 1.0;
315 finalMatrix[15] = 1.0;
329 double* tempR =
new double[9];
330 double* tempT =
new double[3];
335 double* finalMatrix =
new double[16];
338 finalMatrix[0] = tempR[0];
339 finalMatrix[1] = tempR[1];
340 finalMatrix[2] = tempR[2];
341 finalMatrix[3] = tempT[0];
342 finalMatrix[4] = tempR[3];
343 finalMatrix[5] = tempR[4];
344 finalMatrix[6] = tempR[5];
345 finalMatrix[7] = tempT[1];
346 finalMatrix[8] = tempR[6];
347 finalMatrix[9] = tempR[7];
348 finalMatrix[10] = tempR[8];
349 finalMatrix[11] = tempT[2];
365 std::stringstream alignlog;
367 if (icp.hasConverged()) {
368 if (
verbose == 3) cout <<
"ICP convergence ok.\n";
373 alignlog <<
"====================================================\n";
374 alignlog <<
"icp converged for overlapID " <<
overlapID <<
" in " << icp.getInterations()
376 alignlog <<
"pairs available: " << nPairs;
377 if (nPairs < 100000) {
378 alignlog <<
" (WARNING! This is not enough for accurate alignment!)\n";
384 alignlog <<
"euclidean fitness score: " << icp.getFitnessScore();
385 if (icp.getFitnessScore() > 0.55) {
386 alignlog <<
" (WARNING! This is bad! Should be ~0.55)";
389 alignlog <<
"minDelta: " << minDelta <<
"\n";
391 alignlog <<
"EventTimeCheck: ";
392 if (eventTimeCheck) {
393 alignlog <<
"on (and passed)\n";
398 alignlog <<
"Force Instant: ";
405 alignlog <<
"====================================================\n";
409 alignlog <<
"====================================================\n";
410 alignlog <<
"CRITICAL ERROR:\n";
411 alignlog <<
"no convergence for overlapID " <<
overlapID <<
"." <<
"\n";
412 alignlog <<
"====================================================\n";
414 if (
verbose == 3) cout <<
"ICP did not converge!\n";
417 if (
verbose == 3) cout << alignlog.str();
std::vector< double > simpleSensorTwoZ
std::vector< double > simpleSensorOneX
void setVal(const int32_t m, const int32_t n, const FLOAT *val_)
std::vector< double > simpleSensorTwoY
std::vector< double > simpleSensorOneY
std::vector< double > simpleSensorOneZ
void getData(FLOAT *val_, int32_t i1=0, int32_t j1=0, int32_t i2=-1, int32_t j2=-1)
std::vector< double > simpleSensorTwoX