MultiRegCam.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 __MULTI_REG_CAM_H_
00031 #define __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 "MultiRegCamStr.h"
00054 
00055 
00056 using namespace std;
00057 using namespace MipBaselib;
00058 
00059 namespace MipAlgorithms{
00060 
00061     class MultiRegCamPar {
00062     private:
00063         Decimal _linearTollerance;
00064         Decimal _angularTollerance;
00065         Decimal _projTollerance;
00066 
00067     public:
00069         MultiRegCamPar();
00070 
00072         MultiRegCamPar(Decimal lt, Decimal at, Decimal pt);
00073 
00075         MultiRegCamPar(const MultiRegCamPar &A);
00076 
00078         MultiRegCamPar& operator=(MultiRegCamPar &A);
00079 
00081 
00082         Decimal getLinearTollerance();
00083 
00085 
00086         Decimal getAngularTollerance();
00087 
00089         Decimal getProjTollerance();
00090     };
00091     
00092     class MultiRegCamSol {
00093     private:
00095         vector<PolFusion*> _sols;
00096 
00097     public:
00099 
00100         MultiRegCamSol();
00101 
00103 
00104         MultiRegCamSol(PolFusion *polFusion);
00105 
00106         ~MultiRegCamSol();
00107 
00109 
00110         void insertPol(PolFusion *polFusion);
00111 
00113 
00114         int getSize();
00115 
00117 
00118         PolFusion* getPolFusion(int pos);
00119 
00120         vector<PolFusion*> getActualSol();
00121 
00122         MultiRegCamSol& operator=(MultiRegCamSol &A);
00123 
00124         int searchId(int id, vector<Pose> *ris, vector<MIPMatrix> *measCov, Decimal *rightProb);
00125 
00126         string printSolutions(vector<Pose> *ris);
00127 
00129 
00130         string print(int opt = 0);
00131 
00132     };
00133 
00134     class MultiRegCam {
00135     public:
00136         MultiRegCamPar _par;
00137 
00139         MultiRegCam(MultiRegCamPar par);
00140 
00142         ~MultiRegCam();
00143 
00145         void initExample(vector<AngleId> &input);
00146 
00148         void print(vector<AngleId> input, int option);
00149 
00151         void print(vector< vector<Decimal> > input);
00152 
00154         void initTriangles(vector<AngleId> input, MultiRegCamSol *mrcsols, int myId);
00155 
00156         // \brief Find the direction seen by a robot
00157         vector <vector<Angle> > createAng(vector<vector<Angle> > input);
00158 
00159         vector <vector<Decimal> > findFormTot(vector<vector<Angle> > input);
00160 
00162         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);
00163         //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);
00164         //void evalTria(vector<AngleId> input,Decimal firstV,Decimal secondV,Decimal thridV,Decimal aSide,Decimal bSide,Decimal cSide,Triangle *triaPointer);
00165 
00167         int step(int argc, char** argv);
00168 
00169         //public:     // !TODO It's private (for testing...)
00170 
00172         void eraseDup(Triangle* &triaPointer, Decimal thr);
00173 
00175         void eraseDup3(Triangle* &triaPointer, Decimal thr);
00176 
00177         bool eraseDupTria(vector<Triangle*> &trias, Triangle* &tria);
00178 
00180         void createPol(vector<Triangle*> triaSols, int myId,MultiRegCamSol *mrcsols);
00181 
00183         void quickSortTria(vector<Triangle*> &triaSols, Triangle* &tria, int myId);
00184 
00186         void selectSubSol(vector<Triangle*> &triaSols, Triangle* &tria, int myId);
00187 
00189         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);
00190 
00191         fstream _logMultiRegCamFile;
00193         //void searchId(int id, MultiRegCamSol *mrcsols,vector<BearId> ris);
00194 
00195         //string printSolutions(vector<BearId> ris);
00196 
00197     };
00198 
00199     //Triangle tria1;
00200 
00201 }
00202 
00203 #endif
00204 
00205 // Rep for class PolFusion
00206 /*class PolFusion{ private:
00207                        vector<Triangle> _triangles;
00208                        TriaMatrix* _polMatrix;
00209 
00210                     public:
00212                         PolFusion(){
00213                             _triangles.clear();
00214                             _polMatrix=(TriaMatrix*)new TriaMatrix(1,1);
00215                         }
00216 
00218                         PolFusion(Triangle tria){
00219                             _triangles.clear();
00220                             _triangles.push_back(tria);
00221                             _polMatrix=(TriaMatrix*)new TriaMatrix(1,1);
00222                         }
00223 
00225                         PolFusion(vector<Triangle> tria){
00226                             _triangles=tria;
00227                             _polMatrix=(TriaMatrix*)new TriaMatrix(1,1);
00228                         }
00229 
00231                         ~PolFusion(){
00232 
00233                         }
00234 
00236                         void insertTriangle(Triangle *tria){
00237                             //_triangles.push_back(tria);
00238                             int pos = 0;
00239                             //Decimal scorr = 0;
00240                             cout << _triangles.size() << endl;
00241 
00242                             while((pos<_triangles.size())&&(_triangles.at(pos).getInter3Size()>=(*tria).getInter3Size()))
00243                                     pos++;
00244 
00245                                 cout << "pos: " << pos << endl;
00246                             _triangles.insert(_triangles.begin()+pos,*tria);
00247 
00248                         }
00249 
00251                         string print(){
00252                            stringstream s;
00253                            for(int i=0;i<_triangles.size();i++)
00254                                    s << "Triangle[" << i << "]:" << endl << _triangles.at(i).print();
00255 
00256                            return s.str();
00257                         }
00258 
00259    };
00260  */
00261 
00262 //Rep for the class MultiRegCamSol:
00263 /*class MultiRegCamSol{ private:
00265                             vector<PolFusion> _sols;
00266 
00267                         public:
00269                             MultiRegCamSol(){
00270                                 _sols.clear();
00271                             }
00272 
00274                             MultiRegCamSol(PolFusion polFusion){
00275                                 _sols.clear();
00276                                 _sols.push_back(polFusion);
00277                             }
00278 
00279                             ~MultiRegCamSol(){
00280 
00281                             }
00282 
00284                             void insertPol(PolFusion polFusion){
00285                                 _sols.push_back(polFusion);
00286                             }
00287 
00289                             int getSize(){
00290                                 return _sols.size();
00291                             }
00292 
00293                             MultiRegCamSol operator= (MultiRegCamSol &A){
00294                                 _sols.clear();
00295                                 _sols=A._sols;
00296                             }
00297 
00299                             string print(){
00300 
00301                                stringstream s;
00302                                for(int i=0;i<_sols.size();i++)
00303                                        s << RED << "Solution[" << i << "]:" << STOPCOLOR << endl << _sols.at(i).print();
00304 
00305                                return s.str();
00306                             }
00307 
00308    };
00309  */

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