PHDCamFilterTask.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
00030
00031
00037
00038
00039 #ifndef __PHD_CAM_FILTER_TASK_H_
00040 #define __PHD_CAM_FILTER_TASK_H_
00041
00042 #include <SpacesArma.h>
00043
00044 #include <Task.h>
00045 #include <Resource.h>
00046 #include <Uav.h>
00047 #include <GMPHDUnicycle2DCamIdRCFilter.h>
00048 #include <PHDRansac.h>
00049
00050 #include <SharedMem.h>
00051 #include <CommonOptions.h>
00052 #ifndef MIP_PLATFORM_ARM
00053 #include <DraWin.h>
00054 #endif
00055 #include <CommModule.h>
00056 #include <PHDFilterTask.h>
00057
00058
00059 using namespace MipAlgorithms;
00060 using namespace MipResources;
00061 using namespace arma;
00062
00063
00064 namespace MipTasks{
00065
00067
00068
00072 class PHDCamFilterTaskOptions : public Options {
00073 public:
00074
00076 DecimalOption* timeBetweenMeasUpdates;
00077
00079 DecimalOption* timeBetweenSysUpdates;
00080
00082 StringOption* filterType;
00083
00085 DecimalOption* survivalProbability;
00086
00088 DecimalOption* detectionProbability;
00089
00092 DecimalOption* truncationThreshold;
00093
00095 IntOption* maxComponentNumber;
00096
00099 DecimalOption* mergingThreshold;
00100
00102 IntOption* particleNumber;
00103
00105 DecimalOption* sensorDetectionRay;
00106
00108 DecimalOption* targetDimension;
00109
00111 DecimalOption* maxDetectionBearing;
00112
00114 DecimalOption* widthCam;
00115
00117 DecimalOption* heightCam;
00118
00120 DecimalOption* focaLengthCam;
00121
00123 Pose3DOption* relPoseCamQuad;
00124
00126 Pose3DOption* relPoseSonarQuad;
00127
00129 PositionOption* principalPoint;
00130
00131 DecimalArrayOption* rotoQuadMobRob;
00132
00134 IntOption* saveResults;
00135
00137 DecimalOption* sigmaNoiseDist;
00138
00140 DecimalOption* noiseRangeDist;
00141
00143 StringOption* rootFolder;
00144
00146 StringOption* rootEstimates;
00147
00149 StringOption* rootBestEstimate;
00150
00152 StringOption* rootMeasImPlane;
00153
00155 BoolOption* addNoiseOnMeas;
00156
00159 BoolOption* vertZSonarAlgo;
00160
00162 PHDCamFilterTaskOptions();
00163
00164 string getObjectName() const {
00165 return "PHDCamFilterTaskOptions";
00166 }
00167 };
00168
00169
00173 class PHDCamFilterTaskSharedMem : public SharedMem{
00174 private:
00175 Odometry2DTimeArma odo;
00176 public:
00179 void initSharedMem();
00180
00184 PosiFeatures getMyProtrusions(MotionModuleTState &state);
00185
00188 void getMyProtrusionsCam(vector<Position2DArma> &pos);
00189
00197 void getMyProtrusionsCamWithNoise(vector<Position2DArma> &pos, const Decimal &sigmaDist, const Decimal &noiseDist, const Decimal &w, const Decimal h);
00198
00207 void getMyControlInput(Decimal &lvx, Decimal &lvy, Decimal &lvz, Decimal &avx, Decimal &avy, Decimal &avz, Time &ct);
00208
00213 void getMyControlInput(Velocity3DArma &lv, Velocity3DArma &av, Time &ct);
00214
00217 void getMyControlInput(Odometry3DTimeArma &odoTime);
00218
00222 void getMyAttitude(Angle &roll, Angle &pitch);
00223
00226 void getMyYaw(Angle &y);
00227
00230 void getMyHeight(Decimal &height);
00231
00234 void getGT(map<int,Pose> >Pos);
00235
00238 bool doMloc();
00239
00241 void unsetDoMloc();
00242
00245 bool printFormation();
00246
00249 bool printFormationDetails();
00250 };
00251
00252
00256 class PHDCamFilterTask : public Task{
00257 private:
00258
00259
00260 fstream filozzo2;
00261
00262
00263 Decimal noiseDist;
00264 Decimal sigmaDist;
00265
00266
00267 fstream* _savEstimates;
00268 fstream* _saveBestGuess;
00269 fstream* _saveWeightedSumImPlane;
00270 fstream* _saveImPlaneMeas;
00271 fstream* _saveImPlaneAllMeas;
00272 fstream* _saveUAVData;
00273
00274 static const TaskPlate _plate = PHC_TASK;
00275
00277 static const long int _maxDurSec = 0, _maxDurUsec = 150000;
00278 static const long int _maxSamplPeriodSec = 0, _maxSamplPeriodUsec = 500000;
00279 static const long int _minSamplPeriodSec = 0, _minSamplPeriodUsec = 200000;
00280
00282
00283
00284
00285
00286 PHDFilter* _phdFilter;
00287 PHDFilterType _phdFilterType;
00288
00289 Uav* _uav;
00290
00291 CommModule* _commModule;
00292
00293 #ifndef MIP_PLATFORM_ARM
00294 DraWin* _draWin;
00295 unsigned int _drawList;
00296 bool dwOn;
00297 #endif
00298
00299 PHDCamFilterTaskSharedMem* _sharedMem;
00300
00301 PHDCamFilterTaskOptions _options;
00302
00303
00304 int _myId;
00305 Pose _myPose;
00306 PosiFeatures _myPosiFeatures;
00307 vector<Position2DArma> _myCamObs;
00308 Odometry3DTimeArma _myOdo;
00309 Angle _roll, _pitch, _yaw;
00310 Decimal _height;
00311
00312 map<int,PosiFeatures> _othersPosiFeatures;
00313 vector<int> _othersPosiFeaturesNums;
00314
00315 map<int,GaussianMixtureJointId> _othersGM;
00316 vector<int> _othersGMNums;
00317
00318 int counter;
00319
00320 PHDRansac _ransac;
00321
00322 map<int, Decimal > _othersLVel;
00323 map<int, Decimal > _othersAVel;
00324 map<int, SimTime > _othersTimeCIn;
00325 vector<int> _othersVelNums;
00326
00327 map<int,Pose> _othersPose;
00328 vector<int> _othersPoseNums;
00329 map<int,SimTimer> _timeFromLastMessage;
00330 SimTimer _lastStepTime;
00331
00332
00333
00334
00336 GaussianMixtureJointId _gmStepResult;
00337
00338
00339 void _draw();
00340
00342 void _communicate();
00343
00345 void _receiveMyPose(CommPacket* packet, int senderId);
00346
00348 void _receiveMyControlInput(CommPacket *packet, int senderId);
00349
00351 void _receiveMyGaussianMixture(CommPacket *packet, int senderId);
00352
00354 void _receiveMyPosiFeature(CommPacket *packet, int senderId);
00355
00357 void _readSharedMem();
00358
00360 void _saveOnFile();
00361
00362 public:
00364 PHDCamFilterTask(ResourcePointers resources,int argc, const char* argv[]);
00365
00367 ~PHDCamFilterTask();
00368
00371 TaskPlate getPlate() const {
00372 return _plate;
00373 }
00376 Time getMaxDuration(){
00377 return Time(_maxDurSec,_maxDurUsec);
00378 }
00381 Time getMaxSamplPeriod(){
00382 return Time(_maxSamplPeriodSec,_maxSamplPeriodUsec);
00383 }
00386 Time getMinSamplPeriod(){
00387 return Time(_minSamplPeriodSec,_minSamplPeriodUsec);
00388 }
00389
00392 TaskOutputs run();
00393 };
00394
00395
00396
00397 };
00398
00399 #endif
00400
00401
00402
00403
00404