00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00029 #ifndef __PROB_MUTLOCQUAD_STEREO_CAM_H_
00030 #define __PROB_MUTLOCQUAD_STEREO_CAM_H_
00031
00032 #include "baselib.h"
00033 #include "LogTrace.h"
00034 #include <Option.h>
00035 #include "ProbMultiRegStereoCam3D.h"
00036 #include "MutLocQuad.h"
00037 #include <PaFilBFLRelRel3D.h>
00038 #include <DraWinGL.h>
00039
00040 #define DEBUGMUTLOCQUAD 0
00041
00042
00043 #define WORLDGRAVITY 9.81
00044
00045 typedef MipBaselib::IMUOdometry IMUData;
00046
00047 namespace kybalg{
00048
00052 class mutLocQuadStereoCamPar : public MutLocQuadPar{
00053 private:
00054 Decimal sigmaNoiseDist;
00055 Decimal rangeNoiseDist;
00056 Decimal minIntWeight;
00057 string rootFakeQuadIds;
00058 public:
00060 mutLocQuadStereoCamPar() : MutLocQuadPar(){};
00061
00063 ~mutLocQuadStereoCamPar();
00064
00066 mutLocQuadStereoCamPar(Decimal lt, Decimal at, Decimal pt,int expandMethod,bool se,bool smrg,Decimal tts,string rf,string rtm,string rfts,string rfi, Decimal tmfmu,int mno,bool ev,bool pf,bool pp,string rfic,bool lfaf,string rapf, bool sap, bool rvf,bool scfs, bool sra,bool sbe,Decimal zpt, Decimal snd, Decimal rnd, Decimal miw, string fqif) : MutLocQuadPar(lt, at, pt, expandMethod, se, smrg, tts, rf, rtm, rfts, rfi, tmfmu, mno, ev, pf, pp, rfic, lfaf, rapf, sap, rvf, scfs, sra, sbe, zpt, false,0,0,0,0){
00067 sigmaNoiseDist = snd;
00068 rangeNoiseDist = rnd;
00069 minIntWeight = miw;
00070 rootFakeQuadIds = fqif;
00071 };
00072
00074 mutLocQuadStereoCamPar(const mutLocQuadStereoCamPar &A);
00075
00077 mutLocQuadStereoCamPar& operator=(mutLocQuadStereoCamPar &A);
00078
00081 Decimal getSigmaNoiseDist();
00082
00085 Decimal getRangeNoiseDist();
00086
00089 Decimal getMinIntWeight();
00090
00093 string getRootFakeQuadIdsFile();
00094 };
00095
00099 class mutLocQuadStereoCam : public MIPObject{
00100 private:
00101
00102 static mutLocQuadStereoCam* _instance;
00103
00104 bool _doOnlyFilter;
00105
00106 bool _saveInputFilterFile;
00107
00108 bool _dwOn;
00109
00110 MipResources::DraWinGL* _draWin;
00111 unsigned int _drawList;
00112
00113 bool _printFormation;
00114
00115 bool _printFormationDetails;
00116
00117 mutLocQuadStereoCamPar _par;
00118
00119 probMultiRegStereoCam3DCam* _probMultiReg;
00120
00121 vector< vector<bearDistId> > inputMultiRegOff;
00122
00123 vector<int> _fakeQuadIds;
00124
00125 vector<map<int,Position3D> > idPosFilter;
00126
00127 vector<map<int,Angle> > _idYawFilter;
00128
00129 vector<pair<long int,long int> > _timeOffline;
00130 vector<Decimal> _timeOff;
00131
00132 int countMeasOff;
00133
00134 vector< vector<IMUDataTime> > _tStateOff;
00135
00136 vector< map<int, pair<Angle,Angle> > > _rollPitch;
00137
00138 map<int,MipAlgorithms::PaFilBFLRelRel3D*> _filter;
00139
00140 vector<int> _activatedFilters;
00141
00142
00143
00144 map<int,vector<bearStr> > _measFromMultiBeaReg;
00145
00146 map<int,vector<Orientation3D> > _measFromMultiBeaRegOri;
00147
00148 vector<int> _measFromMultiBeaRegIds;
00149
00150
00151 vector<Velocity3D> _myOmegaVel;
00152
00153
00154
00155 vector<Pose3D> _absPosOwner;
00156
00157 vector<map<int,Pose3D> > _absPosOther;
00158
00159 vector<map<int,Velocity3D> > _velAbsOther;
00160
00161 vector<Velocity3D> _absVelOwner;
00162
00163
00164
00165
00166 int _myId;
00167
00168 Pose3D _myPose;
00169
00170 IMUDataTime _myIMU;
00171
00172 vector<bearDistStr> _myBearObs;
00173
00174
00175
00176 map<int, vector<bearStr> > _othersBearObs;
00177
00178 vector<int> _othersBearObsNums;
00179
00180
00181 map<int,IMUDataTime> _othersIMU;
00182
00183
00184 map<int,Pose3D> _estimates;
00185 map<int,Velocity3D> _velEstimates;
00186 vector<int> _activatedEstimates;
00187 map<int,Timer> _timeFromLastMessage;
00188 vector<PoseFeature3D> _formation;
00189
00190
00191 map<int,fstream*> _savefile;
00192
00193 map<int,fstream*> _saveBest;
00194
00195 fstream _saveRealPosFile;
00196
00197 fstream _saveMultiRegCamFile;
00198 fstream _saveBestEstimate;
00199 fstream _readFile;
00200
00201 fstream _logMultiRegCamFile;
00202 fstream _logMultiRegCamOff;
00203
00204 fstream _logTimeOff;
00205
00206 map<int,fstream*> _saveAllP;
00207
00208 fstream _saveInputFilter;
00209
00210
00211 stringstream s;
00212
00213 map<int,int> banned;
00214
00215
00216 private:
00218 void _readDataFromFiles();
00219
00221 int searchIMUData(vector<IMUDataTime> &inputIMUTime, Decimal time, Decimal thr);
00222
00224 int searchAbsPos(vector<Pose3DIdTime> &inputPosTime, Decimal time, Decimal thr);
00225
00227 Position3D _computeRelPos(Pose3DIdTime pos,Position3D posOther,bearDistStr &bearObs);
00228
00230 Position3D _computeRelCoord(Position3D myVel,Orientation3D myOri,Position3D velOther);
00231
00233 Pose3D _computeRelCoord(Pose3D myPose,Pose3D otherPose);
00234
00236 void _doOnePropagationFilterStep(map <int, vector <Pose3D> > &likelihoods, vector<int> &likelihoodsActive,map <int, vector <Velocity3D> > &velLikelihoods);
00237
00239 bool _activeFilter(int hisId);
00240
00242 void _completeMutLocFilInput(MipAlgorithms::MutLocFilInput3D &fStepIn, int hisId);
00243
00245 void _performBearingOnlyMultipleRegistration(map <int, vector <Pose3D> > &likelihoods, vector<int> &likelihoodsActive, probMultiRegStereoCam3DQuadSol* probMultiRegQuadSol);
00246
00248 void _insertValidQuadObservations(vector<bearDistId> &allObservations);
00249
00251 void _activateFilter(int hisId);
00252
00254 bool _activeEstimate(int hisId);
00255
00257 void _computeFormation(actualForm &af);
00258
00260 Pose3D _computeAbsCoord(Pose3D owner,Pose3D other);
00261
00263 Position3D _computeAbsCoord(Pose3D owner,Position3D other);
00264
00266 void _draw();
00267
00269 void selectParticles(vector<Decimal> weights, vector<int> &posBest,int numVis);
00270
00271 public:
00273 mutLocQuadStereoCam(mutLocQuadStereoCamPar mlqp);
00274
00276 mutLocQuadStereoCam(mutLocQuadStereoCamPar mlqp, bool falsePos);
00277
00279 mutLocQuadStereoCam(int argc,char** argv,mutLocQuadStereoCamPar mlqp);
00280
00282 mutLocQuadStereoCam();
00283
00285 ~mutLocQuadStereoCam();
00286
00288 Velocity3D transformPQRRDPDYD(Velocity3D pqr,Angle roll,Angle pitch);
00289
00291 Position3D quadNoRollPitch(Position3D point,Angle roll,Angle pitch);
00293 Velocity3D quadNoRollPitch(Velocity3D point,Angle roll,Angle pitch);
00295 Acceleration3D quadNoRollPitch(Acceleration3D point,Angle roll, Angle pitch);
00296
00297
00299 vector<bearDistIdTime> _readBearingFromPos(ifstream &file,int id);
00300
00302 vector<bearDistIdTime> _readBearingFromPosId(ifstream &file,int id,int opt);
00303
00305 vector<Pose3DIdTime> _readBearingFromAbsPosId(ifstream &file,int id);
00306
00308 vector<Velocity3D> _readVelFile(ifstream &file,int id);
00309
00311 void _readIdsFile(ifstream &file,vector<int> &ris);
00312
00314 void _readFakeQuadIdsFile(ifstream &file);
00315
00317 vector<IMUDataTime> _readTState(ifstream &file,MIPMatrix rotAcc,MIPMatrix rotGyro,Position3D biasAcc,Position3D scalingAcc,Position3D biasAngVel,Position3D scalingAngVel);
00318
00320 void _readIMUConfigFile(ifstream &file,vector<MIPMatrix> &RotAcc,vector<MIPMatrix> &rotGyro,vector<Position3D>& biasAcc,vector<Position3D>& scalingAcc,vector<Position3D>& biasAngVel,vector<Position3D>& scalingAngVel);
00321
00323 void _computeInputMultiRegOff(vector<vector<bearDistIdTime> > &inputTime,vector<vector<bearDistId> > &inputMultiRegOff,int myIdPos, vector< vector<IMUDataTime> > &inputTStateOffTemp, vector< vector<IMUDataTime> > &inputTStateOff,vector<int> IdsF);
00324
00326 static mutLocQuadStereoCam* instance(mutLocQuadStereoCamPar* mlqp);
00327
00329 actualForm step(bool &nextStep);
00330
00332 string getObjectName() const{
00333 return "mutLocQuadStereoCam";
00334 }
00335 };
00336
00337 }
00338 #endif