ProbMultiRegStereoCam3DStr.h

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // $Id$
00004 //
00005 // Copyright 2008, 2009, 2010  Antonio Franchi
00006 //
00007 // This file is part of TeleKyb.
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
00023 //
00024 // ----------------------------------------------------------------------------
00025  
00029  
00030 #ifndef __PROB_MULTI_REG_STEREO_CAM_STR3D_H
00031 #define __PROB_MULTI_REG_STEREO_CAM_STR3D_H
00032  
00033 //Include libraries
00034 #include "time.h"
00035 #include <fstream>
00036 #include <stdlib.h>
00037 #include <stdio.h>
00038 #include <vector>
00039 #include <iostream>
00040 #include <vector>
00041 #include <map>
00042 #include <baselib.h>
00043 #include <ProbMultiRegCam3DStr.h>
00044  
00045 using namespace MipBaselib;
00046  
00047 namespace kybalg{
00051  class bearDistStr{
00052   public:
00053    Angle azimuth;
00054    Angle zenith;
00055    Decimal dist;
00056    
00058    bearDistStr();
00059    
00061    bearDistStr(Angle az,Angle zn, Decimal d);
00062    
00064    bearDistStr(Decimal az,Decimal zn,Decimal d);
00065    
00067    ~bearDistStr();
00068    
00070    bearDistStr& operator= (const bearDistStr &A);
00071    
00073    bool operator==(const bearDistStr &other) const;
00074    
00076    string print();
00077  };
00078  
00079  typedef ObjId<bearDistStr> bearDistId;
00080  
00084  class bearDistIdTime : public bearDistId {
00085   private:
00086    long int _ttSec;
00087    long int _ttUSec;
00088   public:
00090    bearDistIdTime(){};
00091 
00093    bearDistIdTime(Angle az,Angle zn, Decimal d,int id,long int ttSec, long int ttUSec);
00094    
00096    bearDistIdTime(bearDistStr bs, int id,long int ttSec, long int ttUSec);
00097 
00099    ~bearDistIdTime();
00100 
00102    void setTimeSec(long int sec);
00103 
00105    void setTimeUSec(long int usec);
00106 
00108    void setTime(long int sec, long int usec);
00109 
00111    long int getTimeSec();
00112    
00114    long int getTimeUSec();
00115 
00117    bool overTime(long int sec, long int usec);
00118    
00120    bool underTime(long int sec, long int usec);
00121    
00123    Decimal getTime();
00124    
00126    bool underTime(Decimal sec);
00127    
00129    bool overTime(Decimal sec);
00130    
00132    string print();
00133  }; 
00134  
00139  class triangleAssObs : public MIPObject {
00140  private:
00141   
00142  PosId3D    *_firstVertex;
00143  PosId3D    *_secondVertex;
00144  PosId3D    *_thirdVertex;
00145  InterPoints  *_interPoints3;
00146  InterPoints  *_interPoints2;
00147  bearDistStr  _oriTwo;
00148  bearDistStr  _oriThree;
00149  bearDistStr  _oriTwoOne;
00150  bearDistStr  _oriTwoThree;
00151  bearDistStr  _oriThreeOne;
00152  bearDistStr  _oriThreeTwo;
00153   bearDistStr _ori2;
00154   bearDistStr _ori3;
00155  
00156  private:
00157   string printSetOriResult();
00158  public:
00159 
00161   triangleAssObs();
00162 
00164   triangleAssObs(Position3D xy1, int id1, Position3D xy2, int id2, Position3D xy3, int id3);
00165   
00167   ~triangleAssObs();
00168   
00170   vector<PosId3D> getVertex();
00171   
00173   PosId3D* getFirstVertex();
00174   
00176   PosId3D* getSecondVertex();
00177   
00179   PosId3D* getThirdVertex();
00180   
00182   PosId3D* getVertexByPos(int pos);
00183   
00184   PosId3D* getVertexByID(int id);
00185   
00187   void setMyIdVertex(int myId, Decimal &aSide, Decimal &bSide, Decimal &cSide);
00188   
00190   bool isAVertex(Position3D pos, Decimal thr);
00191   
00193   void getIds(vector<int> &ris);
00194   
00196   vector<int> getIds();
00197   
00199   InterPoints* getInter3();
00200   
00202   InterPoints* setInter3();
00203   
00205   Position3D getInter3At(int i);
00206   
00208   int getInter3Size();
00209   
00211   InterPoints* getInter2();
00212   
00214   int getInter2Size();
00215   
00217   void deleteDupPoint2(int pos);
00218   
00220   void deleteDupPoint3(int pos);
00221   
00223   void insertPoints3(vector<Position3D> iPoints);
00224   
00226   void insertPoint3(Position3D iPoint);
00227   
00229   void insertPoints2(vector<Position3D> iPoints);
00230   
00232   void insertPoint2(Position3D iPoint);
00233   
00235   bool checkId(int myId);
00236   
00238   bool sameIds(triangleAssObs* tria);
00239   
00241   bool setOri(bearDistStr oriTwo, bearDistStr oriThree, bearDistStr oriTwoF, bearDistStr oriTwoS, bearDistStr oriThreeF, bearDistStr oriThreeS, Decimal projToll);
00242   
00244   bool setOriOpt(bearDistStr oriTwo, bearDistStr oriThree, bearDistStr oriTwoF, bearDistStr oriTwoS, bearDistStr oriThreeF, bearDistStr oriThreeS, Decimal projToll,Decimal angToll);
00245   
00247   bool setOriSing(bearDistStr oriTwo, bearDistStr oriThree, bearDistStr oriTwoF, bearDistStr oriTwoS, bearDistStr oriThreeF, bearDistStr oriThreeS, Decimal projToll,Decimal angToll);
00248   
00250   bearDistStr getOriTwo();
00251   
00253   bearDistStr getOriThree();
00254   
00256   bearDistStr getOriTwoThree();
00257   
00259   bearDistStr getOriTwoOne();
00260 
00262   bearDistStr getOriThreeOne();
00263   
00265   bearDistStr getOriThreeTwo();
00266   
00268   Angle getOriByPos(int pos);
00269   
00271   string print();
00272   
00274   triangleAssObs& operator=(triangleAssObs &A);
00275   
00277   bool operator==(triangleAssObs &A) const;
00278   
00280   string getObjectName() const{
00281    return "triangleAssObs";
00282   }
00283  };
00284  
00289  class probPolFusionDist : public MIPObject{
00290   private:
00291    // Pointers to the triangles that compose the polimorph
00292    vector<triangleAssObs*>  _triangles;
00293    // List of vertex
00294    vector<PosId3D>      _vertex;
00295    // Orientation of the robots 
00296    vector<Angle>       _ori;
00297    // Intersection by three
00298    InterPoints        _intThree;
00299    // List of triangle candidates to enter in the polimorph
00300    vector<triangleAssObs*>  _triangleQueue;
00301    // Rototranslation
00302    vector<MIPMatrix>     _rotoTrasl;
00303    // Scale factor
00304    vector<Decimal>      _scaleF;
00305    // Rating based on the number of verteces 
00306    int            _ratingVertex;
00307    // Rating based on the number of triple intersections
00308    int            _ratingInThree;
00309    // Number of intersection by four ordered by the triangle index inserted 
00310    vector<int>        _numIntFour;
00311    // Kind of expansion method used
00312    int            _expandMethod;
00313    // Scale factor of the entire formation
00314    Decimal          _scaleFactForm;
00315    // Scale factor of each triangle wrt the distance infos
00316    vector<Decimal>      _scaleFTriangles;
00317    
00318   public:
00320    probPolFusionDist();
00321    
00323    probPolFusionDist(triangleAssObs* tria, int expMth);
00324    
00326    ~probPolFusionDist();
00327    
00329    triangleAssObs* getTriangle(int pos);
00330    
00332    void setTriangle(int pos,triangleAssObs* tria);
00333    
00335    void deleteTriangle(int pos);
00336    
00338    void deleteLastTriangle();
00339    
00341    void deleteScaleFTriangles(int pos);
00342    
00344    void deleteLastScaleFTriangles();
00345    
00347    void setScaleFTriangles(int pos,Decimal &scale);
00348    
00350    void deleteBifConflicts(int pos,int posAt, int idNew);
00351    
00353    void deleteBifConflictsOpt(int pos, int idNew);
00354    
00356    int getSize();
00357    
00359    int getQueueSize();
00360    
00362    void getIds(vector<int> &ids);
00363    
00365    void insertVertex(PosId3D vertex);
00366    
00368    PosId3D getVertex(int pos);
00369    
00371    void setVertex(int pos,PosId3D vertex);
00372    
00374    void setQueue(triangleAssObs* queue);
00375    
00377    int queueSize();
00378    
00380    void deleteQueueTriangle(int pos);
00381    
00382    void deleteQueueLastTriangle();
00383    
00385    void setScale(int i, Decimal scale);
00386    
00388    void setScale(Decimal scale);
00389    
00391    Decimal getScale(int i);
00392    
00394    void deleteScaleF(int pos);
00395    
00396    void deleteLastScaleF();
00397    
00399    void setRotoTrasl(int pos, MIPMatrix rt);
00400    
00402    MIPMatrix getRotoTrasl(int pos);
00403    
00405    void deleteRotoTrasl(int pos);
00406    
00407    void deleteLastRotoTrasl();
00408    
00410    void insertOri(Decimal ori);
00411    
00413    Decimal getOri(int pos);
00414    
00416    void setOri(int pos,Angle ori);
00417    
00419    void deleteOri(int pos);
00420    
00422    void deleteLastOri();
00423    
00425    void insertTriangle(triangleAssObs *tria, int myId, int id1, int id2);
00426    
00428    PosId3D* searchVertex(int id);
00429    
00431    PosId3D* searchVertex(int id,int &posAt);
00432    
00434    void deleteVertex(int pos);
00435    
00437    void deleteLastVertex();
00438    
00440    int searchBif(PosId3D vertex,int &posAt,Decimal thr);
00441    
00443    void insertPoints(triangleAssObs* tria, int &numInt4);
00444    
00446    void insertPointsNoIn(triangleAssObs* tria, int &numInt4, MIPMatrix* &matrixPointer, Decimal actualScale, vector<Position3D> &intToInsert, int &incrRatInThree);
00447    
00449    int getNInThree(int pos);
00450    
00452    Position3D getIntThree(int pos);
00453    
00455    Position3D getLastIntThree();
00456    
00458    void deleteIntThree(int pos);
00459    
00461    void deleteLastIntThree();
00462    
00464    void insertPointIntThree(Position3D ip,int pos);
00465    
00467    bool expandPolNoIn(int myId, vector<probPolFusionDist*> actualSol, vector<probPolFusionDist*> &bifprobPolFusionDist,Decimal linThr, map <int, vector<Pose3D> > *likelihood, vector <int> activeLikelihoods,int &maxBifSize);
00468    
00470    bool checkBif(PosId3D vertex,Decimal thr,int myId);
00471    
00473    string print(int opt=0);
00474    
00476    probPolFusionDist& operator=(probPolFusionDist &A);
00477    
00479    Decimal computeProbability(Pose3D measure, int id, map <int, vector<Pose3D> > * &likelihood);
00480    
00482    Decimal computeProbabilityScale(Position3D &measure, Decimal measureYaw,  int id, map <int, vector<Pose3D> > * &likelihood);
00483    
00485    void setRatingVertex(int rating);
00486    
00488    int getRatingVertex();
00489    
00491    void growRatingVertex();
00492    
00494    void decreaseRatingVertex();
00495    
00497    void setRatingInThree(int rating);
00498    
00500    int getRatingInThree();
00501    
00503    void growRatingInThree();
00504    
00506    void decreaseRatingInThree();
00507    
00509    void setIntFourNum(int pos, int val);
00510    
00512    int getIntFourNum(int pos);
00513    
00515    int getLastIntFourNum();
00516    
00518    void deleteLastIntFourNum();
00519    
00521    void selectScale(Decimal &bestScale, Decimal &bestProb, map <int, vector<Pose3D> > * &likelihood, vector <int> &activeLikelihoods,vector<int> &idsV);
00522    
00524    void computeProbFixedScale(Decimal &bestProb, map <int, vector<Pose3D> > * &likelihood, vector <int> &activeLikelihoods,vector<int> &idsV);
00525    
00527    void setExpandMethod(int expMth);
00528    
00530    string getObjectName() const{
00531     return "probPolFusionDist";
00532    }
00533    
00535    Decimal getScaleFormation();
00536    
00538    void updateScaleFactForm(Decimal &d);
00539    
00541    void deleteScaleFactForm(Decimal &d);
00542  };
00543  
00544 } // End of namespace
00545 
00546 #endif

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