ProbMultiRegCam.h

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // $Id$
00004 //
00005 // Copyright 2008, 2009, 2010, 2011, 2012  Antonio Franchi and Paolo Stegagno
00006 //
00007 // This file is part of MIP.
00008 //
00009 // MIP is free software: you can redistribute it and/or modify
00010 // it under the terms of the GNU General Public License as published by
00011 // the Free Software Foundation, either version 3 of the License, or
00012 // (at your option) any later version.
00013 //
00014 // MIP is distributed in the hope that it will be useful,
00015 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017 // GNU General Public License for more details.
00018 //
00019 // You should have received a copy of the GNU General Public License
00020 // along with MIP. If not, see <http://www.gnu.org/licenses/>.
00021 //
00022 // Contact info: antonio.franchi@tuebingen.mpg.de stegagno@diag.uniroma1.it
00023 //
00024 // ----------------------------------------------------------------------------
00025 
00026 
00030 #ifndef __PROB_MULTI_REG_CAM_H_
00031 #define __PROB_MULTI_REG_CAM_H_
00032 
00033 #define BLACK "\e[2;30m"
00034 #define RED "\e[0;31m"
00035 #define GREEN "\e[0;32m"
00036 #define YELLOW "\e[0;33m"
00037 #define BLUE "\e[0;34m"
00038 #define MAGENTA "\e[0;35m"
00039 #define CYAN "\e[0;36m"
00040 #define WHITE "\e[0;37m"
00041 #define STOPCOLOR "\e[m"
00042 
00043 #include <MIPMatrix.h>
00044 #include "time.h"
00045 #include <fstream>
00046 #include <stdlib.h>
00047 #include <stdio.h>
00048 #include <vector>
00049 #include <iostream>
00050 #include <R2.h>
00051 #include <S1.h>
00052 #include <SE2.h>
00053 #include <map>
00054 #include "ProbMultiRegCamStr.h"
00055 
00056 
00057 using namespace std;
00058 using namespace MipBaselib;
00059 
00060 namespace MipAlgorithms{
00061 
00062     class ProbMultiRegCamPar {
00063     private:
00064         Decimal _linearTollerance;
00065         Decimal _angularTollerance;
00066         Decimal _projTollerance;
00067         int     _expandMethod;
00068 
00069     public:
00071         ProbMultiRegCamPar();
00072 
00074         ProbMultiRegCamPar(Decimal lt, Decimal at, Decimal pt,int expandMethod);
00075 
00077         ProbMultiRegCamPar(const ProbMultiRegCamPar &A);
00078 
00080         ProbMultiRegCamPar& operator=(ProbMultiRegCamPar &A);
00081 
00083 
00084         Decimal getLinearTollerance();
00085 
00087 
00088         Decimal getAngularTollerance();
00089 
00091         Decimal getProjTollerance();
00092 
00094         int getExpandMethod();
00095     };
00096     
00097     class ProbMultiRegCamSol {
00098     private:
00100         vector<ProbPolFusion*> _sols;
00101 
00102     public:
00104 
00105         ProbMultiRegCamSol();
00106 
00108 
00109         ProbMultiRegCamSol(ProbPolFusion *polFusion);
00110 
00111         ~ProbMultiRegCamSol();
00112 
00114 
00115         void insertPol(ProbPolFusion *polFusion);
00116 
00118 
00119         int getSize();
00120 
00122 
00123         ProbPolFusion* getProbPolFusion(int pos);
00124 
00125         vector<ProbPolFusion*> getActualSol();
00126 
00127         ProbMultiRegCamSol& operator=(ProbMultiRegCamSol &A);
00128 
00129         int searchId(int id, vector<Pose> *ris, vector<MIPMatrix> *measCov, Decimal *rightProb, vector<Decimal> *weights);
00130 
00131         string printSolutions(vector<Pose> *ris);
00132 
00134 
00135         string print(int opt = 0);
00136 
00137     };
00138 
00139     class ProbMultiRegCam {
00140     private:
00141         map <int, vector<Pose> > *likelihood;
00142  vector <int> activeLikelihoods;
00143 
00144   public:
00145         ProbMultiRegCamPar _par;
00146 
00148         ProbMultiRegCam(ProbMultiRegCamPar par);
00149 
00151         ~ProbMultiRegCam();
00152 
00154         void initExample(vector<AngleId> &input);
00155 
00157         void print(vector<AngleId> input, int option);
00158 
00160         void print(vector< vector<Decimal> > input);
00161 
00163         void initTriangles(vector<AngleId> &input, ProbMultiRegCamSol *mrcsols, int myId, Pose &myPose);
00164 
00165         // \brief Find the direction seen by a robot
00166         vector <vector<Angle> > createAng(vector<vector<Angle> > input);
00167 
00168         vector <vector<Decimal> > findFormTot(vector<vector<Angle> > input);
00169 
00171         void evalTria(vector<AngleId> input,int firstV,int firstF,int firstS,int secondV,int secondF,int secondS,int thirdV,int thirdF,int thirdS,Decimal aSide,Decimal bSide,Decimal cSide,Triangle *triaPointer);
00172         //void evalTria(vector<AngleId> input, Decimal firstV, Decimal firstF, Decimal firstS, Decimal secondV, Decimal secondF, Decimal secondS, Decimal thirdV, Decimal thirdF, Decimal thirdS, Decimal aSide, Decimal bSide, Decimal cSide, Triangle *triaPointer);
00173         //void evalTria(vector<AngleId> input,Decimal firstV,Decimal secondV,Decimal thridV,Decimal aSide,Decimal bSide,Decimal cSide,Triangle *triaPointer);
00174 
00176         int step(int argc, char** argv);
00177 
00178         //public:     // !TODO It's private (for testing...)
00179 
00181         void eraseDup(Triangle* &triaPointer, Decimal thr);
00182 
00184         void eraseDup3(Triangle* &triaPointer, Decimal thr);
00185 
00186         bool eraseDupTria(vector<Triangle*> &trias, Triangle* &tria);
00187 
00189         void createPol(vector<Triangle*> triaSols, int myId,ProbMultiRegCamSol *mrcsols,Pose &myPose);
00190 
00192         void quickSortTria(vector<Triangle*> &triaSols, Triangle* &tria, int myId);
00193 
00195         void selectSubSol(vector<Triangle*> &triaSols, Triangle* &tria, int myId);
00196 
00198         void printDataIn(AngleId* first,int f1,int f2, AngleId* second, int s1, int s2, AngleId* third, int t1, int t2,int info1,int info2, int info3, int id1, int id2, int id3);
00199 
00201         void setLikelihood(vector<int>& ids, map <int, vector<Pose> >* lik);
00202 
00203         fstream _logProbMultiRegCamFile;
00204         fstream _logProbMultiRegCamOutput;
00206         //void searchId(int id, ProbMultiRegCamSol *mrcsols,vector<BearId> ris);
00207 
00208         //string printSolutions(vector<BearId> ris);
00209 
00210     };
00211 
00212     //Triangle tria1;
00213 
00214 }
00215 
00216 #endif
00217 
00218 // Rep for class ProbPolFusion
00219 /*class ProbPolFusion{ private:
00220                        vector<Triangle> _triangles;
00221                        TriaMatrix* _polMatrix;
00222 
00223                     public:
00225                         ProbPolFusion(){
00226                             _triangles.clear();
00227                             _polMatrix=(TriaMatrix*)new TriaMatrix(1,1);
00228                         }
00229 
00231                         ProbPolFusion(Triangle tria){
00232                             _triangles.clear();
00233                             _triangles.push_back(tria);
00234                             _polMatrix=(TriaMatrix*)new TriaMatrix(1,1);
00235                         }
00236 
00238                         ProbPolFusion(vector<Triangle> tria){
00239                             _triangles=tria;
00240                             _polMatrix=(TriaMatrix*)new TriaMatrix(1,1);
00241                         }
00242 
00244                         ~ProbPolFusion(){
00245 
00246                         }
00247 
00249                         void insertTriangle(Triangle *tria){
00250                             //_triangles.push_back(tria);
00251                             int pos = 0;
00252                             //Decimal scorr = 0;
00253                             cout << _triangles.size() << endl;
00254 
00255                             while((pos<_triangles.size())&&(_triangles.at(pos).getInter3Size()>=(*tria).getInter3Size()))
00256                                     pos++;
00257 
00258                                 cout << "pos: " << pos << endl;
00259                             _triangles.insert(_triangles.begin()+pos,*tria);
00260 
00261                         }
00262 
00264                         string print(){
00265                            stringstream s;
00266                            for(int i=0;i<_triangles.size();i++)
00267                                    s << "Triangle[" << i << "]:" << endl << _triangles.at(i).print();
00268 
00269                            return s.str();
00270                         }
00271 
00272    };
00273  */
00274 
00275 //Rep for the class ProbMultiRegCamSol:
00276 /*class ProbMultiRegCamSol{ private:
00278                             vector<ProbPolFusion> _sols;
00279 
00280                         public:
00282                             ProbMultiRegCamSol(){
00283                                 _sols.clear();
00284                             }
00285 
00287                             ProbMultiRegCamSol(ProbPolFusion polFusion){
00288                                 _sols.clear();
00289                                 _sols.push_back(polFusion);
00290                             }
00291 
00292                             ~ProbMultiRegCamSol(){
00293 
00294                             }
00295 
00297                             void insertPol(ProbPolFusion polFusion){
00298                                 _sols.push_back(polFusion);
00299                             }
00300 
00302                             int getSize(){
00303                                 return _sols.size();
00304                             }
00305 
00306                             ProbMultiRegCamSol operator= (ProbMultiRegCamSol &A){
00307                                 _sols.clear();
00308                                 _sols=A._sols;
00309                             }
00310 
00312                             string print(){
00313 
00314                                stringstream s;
00315                                for(int i=0;i<_sols.size();i++)
00316                                        s << RED << "Solution[" << i << "]:" << STOPCOLOR << endl << _sols.at(i).print();
00317 
00318                                return s.str();
00319                             }
00320 
00321    };
00322  */

Generated on Mon Feb 20 07:01:06 2017 for MIP by  doxygen 1.5.6