GMPHDUnicycle2DCamIdRCFilter.h
Go to the documentation of this file.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
00030 #ifndef __GMPHD_UNICYCLE_2D_CAM_ID_FILTER_H
00031 #define __GMPHD_UNICYCLE_2D_CAM_ID_FILTER_H
00032
00033 #include <Spaces.h>
00034 #include <SpacesArma.h>
00035 #include <GaussianMixture.h>
00036 #include "PHDFilter.h"
00037 #include <map>
00038 #include <CameraParameters.h>
00039
00040 #define NO_ID -1
00041 #define STEADY_ID -2
00042
00043 using namespace MipBaselib;
00044 using namespace arma;
00045
00046 namespace MipAlgorithms{
00047
00049
00050
00054 class GMPHDUnicycle2DCamIdRCFilterPars:public PHDFilterPars{
00055 public:
00056
00058 DMat N_n_x;
00059
00060
00062 DMat H;
00063
00065 DMat N_n_z;
00066
00067
00070 Decimal truncThresh;
00071
00073 int maxNumComponents;
00074
00077 Decimal mergThresh;
00078
00080 int partNumber;
00081
00082
00084 Decimal sensorDetectionRay;
00085
00087 Decimal targetDimension;
00088
00090 Decimal maxDetectionBearing;
00091
00093 bool useNewNoMeasWeight;
00094
00096 CameraPar3DArma* camPars;
00097
00099 int myId;
00100
00102 Roto3DArma* rotoQuadMobRob;
00103
00105 Roto3DArma* rotSonarQuad;
00106
00108 Roto3DArma rotCameraQuadTrans;
00109
00111 Position3DArma* posSonarQuad;
00112
00114 bool vertZSonarAlgo;
00115
00117 string print();
00118
00119
00121 GMPHDUnicycle2DCamIdRCFilterPars();
00122
00124 GMPHDUnicycle2DCamIdRCFilterPars(int mId, Decimal pS, Decimal pD, SimTime t, DMat& nx, DMat& h, DMat& nz, Decimal tt, int mc, Decimal mt, int pN, Decimal sdr, Decimal td, Decimal mdb, Decimal flc, Decimal wc, Decimal hc, Roto3DHomoArma &qct, Decimal ppx, Decimal ppy, Roto3DArma& rotoQuadMob, Roto3DHomoArma& rotoSonarQuad, bool vzsm);
00125 };
00126
00130 class GMPHDUnicycle2DCamIdRCFilterVars:public PHDFilterVars{
00131
00132 public:
00133
00134
00135 DMat::fixed<3,3> AMat;
00136 Position3DArma bVec;
00137 Roto3DArma CMat;
00138
00139
00140 Decimal vHeight;
00141
00142 Decimal zHeight;
00143
00144
00145
00146 Decimal roll;
00147
00148 Decimal pitch;
00149
00150 Decimal myYaw;
00151 Decimal myLastYaw;
00152
00153
00154 Position2DArma borders[4];
00155
00156
00157 vector<Position2DArma> newMeas;
00158
00159
00160 vector<Position2DArma> newBorder;
00161
00162
00163 Odometry2DTimeArma myLastOdom;
00164 Odometry2DTimeArma myOdo;
00165
00166 Decimal lastMeasurementNumber;
00167 vector<Position> lastMeasurements;
00168
00169 GaussianMixtureJointId prediction;
00170
00171 vector<DCol> predictedMeasures;
00172 vector<Decimal> predictedMeasuresD;
00173 vector<Angle> predictedMeasuresB;
00174 vector<DMat> predictedCovariances;
00175 vector<DMat> kalmanGains;
00176 vector<DMat> stepKCovariances;
00177 vector<Decimal> detectionProbability;
00178
00179 int bestMyEstimate;
00180
00181 vector<vector<Decimal> > predictedMeasuresOth;
00182 vector<vector<Decimal> > predictedCovariancesOth;
00183 vector<vector<DMat> > kalmanGainsOth;
00184 vector<vector<DMat> > stepKCovariancesOth;
00185 vector<vector<Decimal> > detectionProbabilityOth;
00186 vector<vector<Decimal> > sensorWeightsOth;
00187
00188 vector<Decimal> detectionProbabilitySum;
00189 Decimal sensorWeightSum;
00190 vector<Decimal> notDetectionProbabilityProd;
00191
00192 vector<vector<Decimal > > dists;
00193
00194
00195 map <int, vector <int> > currSens;
00196
00197 bool firstStepAfterMeasurements;
00198
00199 GaussianMixtureJointId belief;
00200
00201 GaussianMixtureJointId beliefOth;
00202
00203 vector<int> lastOtherRobotPoseNum;
00204 map<int,Pose2DArma> lastOtherRobotPose;
00205 map<int,Pose2DArma> odometries;
00206
00207 GMPHDUnicycle2DCamIdRCFilterVars();
00208 };
00209
00211
00212
00216 class GMPHDUnicycle2DCamIdRCFilter:public PHDFilter{
00217 protected:
00218 GMPHDUnicycle2DCamIdRCFilterVars* _gmvars;
00219 GMPHDUnicycle2DCamIdRCFilterPars* _gmpars;
00220
00221 public:
00223 GMPHDUnicycle2DCamIdRCFilter();
00224
00227 GMPHDUnicycle2DCamIdRCFilter(GMPHDUnicycle2DCamIdRCFilterPars inParams);
00228
00231 void step(PHDFilterIn &in);
00232
00235 string print();
00236
00239 void getBelief(GaussianMixtureJointId &gm);
00240
00244 void getBeliefWeightedSum(map<int,Col<Decimal>::fixed<3> > &out, SimTime* actTime=NULL);
00245
00249 void getBestBelief(map<int,Col<Decimal>::fixed<3> > &out, SimTime* actTime=NULL);
00250
00253 string exportAsStringWeightedSum();
00254
00257 string exportAsStringWeightedSumImagePlane();
00258
00261 string exportAsStringBestGuess();
00262
00265 string exportAsStringBestGuessImagePlane();
00266
00269 string exportAsStringAllGuessImagePlane();
00270
00273 string exportAsStringAllGuess();
00274
00277 string exportAsStringUAVData();
00278
00282 string exportAsStringClusterGuess(const Decimal &per);
00283
00286 string exportAsString();
00287
00290 void exportAs3DRelCoordBestGuess(map<int,DCol::fixed<4> > &in);
00291
00292 PHDFilterOutputType getOutputType(){
00293 return PHD_OUT_GMJID;
00294 }
00295
00296 private:
00297
00298 fstream streamFile;
00299
00301 void _initialize(PHDFilterIn&);
00302
00304 void _initializeWithMeas(PHDFilterIn&);
00305
00307 void _normalStep(PHDFilterIn&);
00308
00310 void _computeOdometries(PHDFilterIn&);
00311
00313 void _computeOdometriesInit(PHDFilterIn &in);
00314
00316 void _predictBirthTarget(PHDFilterIn&);
00317
00319 void _predictExistingTarget();
00320
00326 vector<Position2DArma> _plateMeasurements(vector<Position2DArma> &points, const Decimal &height);
00327
00333 vector<Position2DArma> _plateMeasurementsAlongZCam(vector<Position2DArma> &points, const Decimal &height);
00334
00340 vector<Position2DArma> _plateMeasurementsVert(vector<Position2DArma> &points, const Decimal &height);
00341
00343 void _findMyBestEstimate();
00344
00347 void _buildPHDUpdateComponents(PHDFilterIn &in);
00348
00350 void _updateWithNoMeasurements();
00351
00354 void _updateWithMeasurements(PHDFilterIn &in);
00355
00357 void _prune();
00358
00366 void _transRotoPlateAbsHeight();
00367
00374 void _transRotoPlateRelHeight(DMat::fixed<3,3> &KFun, Position3DArma &b);
00375
00377 Velocity2DArma _transPlateLinVel(const Velocity3DArma &vel);
00378
00383 vector<Position2DArma> _findImagePlaneBorder(const Decimal &height);
00384
00389 vector<Position2DArma> _findImagePlaneBorderAlongZCam(const Decimal &height);
00390
00394 vector<Position2DArma> _findImagePlaneBorderVert();
00395
00398 void _updateLinearCoeff();
00399
00406 Decimal _computeProbDetVert(Position2DArma& point);
00407
00411 Decimal _mahalanobisDist(GaussianComponent& a, GaussianComponent& b);
00412
00414 void _pruneSimple();
00415
00418 void _preProcessingData(PHDFilterIn& in);
00419
00424 void _plateOdometry(PHDFilterIn &in);
00425
00427 Decimal _transformPQRYD(const Velocity3DArma &pqr);
00428
00429 public:
00435 Pose2DArma _integral(Odometry2DTimeArma& vA, Odometry2DTimeArma& vB, const Decimal& dT);
00436
00437 string getObjectName() const {
00438 return "GMPHDUnicycle2DCamIdRCFilter";
00439 }
00440 };
00441
00442
00443
00444 }
00445
00446
00447 #endif