ParticleMutLocTaskNoMR.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
00026
00030
00035
00036
00037
00038 #ifndef __PARTICLE_MUT_LOC_TASK_NOMR_H_
00039 #define __PARTICLE_MUT_LOC_TASK_NOMR_H_
00040
00041
00042 #include <Task.h>
00043 #include <Resource.h>
00044 #include <MobileRob.h>
00045 #include <DraWin.h>
00046 #include <SharedMem.h>
00047 #include <SimTime.h>
00048
00049 #include <CommonOptions.h>
00050 #include <PaFilBFLRelRelNoMR.h>
00051 #include <MutLocFASTSlam.h>
00052 #include <CommModule.h>
00053 #include <Gaussian.h>
00054
00055
00056 using namespace MipAlgorithms;
00057 using namespace MipResources;
00058
00059
00060
00061 namespace MipTasks{
00063
00064
00065
00072 enum FrameTypesPMLNMR{
00073 FIXED_FRAME_PMLNMR,
00074 ATTACHED_FRAME_PMLNMR,
00075 FRAME_TYPES_NUM_PMLNMR
00076 };
00077
00078 static const char* FrameTypesNamesPMLNMR[FRAME_TYPES_NUM_PMLNMR] = {
00079 "fixed",
00080 "attached"
00081 };
00082
00086 enum MutLocNoMRTypes{
00087 MAX_LIK_PMLNMR,
00088 FAST_SLAM_PMLNMR,
00089 MUTLOC_NOMR_TYPES_NUM
00090 };
00091
00092 static const char* MutLocNoMRNames[MUTLOC_NOMR_TYPES_NUM] = {
00093 "MaximumLikelyhood",
00094 "FastSlam"
00095 };
00096
00097
00098
00101 enum PMLNOMRTaskFunctionalities{
00102 PMLNOMR_TASK_COMM_MYPOSE,
00103 PMLNOMR_TASK_COMM_MYPF,
00104 PMLNOMR_TASK_SEP_FILTERS,
00105 PMLNOMR_TASK_SING_FILT,
00106 PMLNOMR_TASK_FUNCTIONALITIES_NUM
00107 };
00108
00114 static const bool PMLNOMRTaskFunctionalitiesTable[MUTLOC_NOMR_TYPES_NUM][PMLNOMR_TASK_FUNCTIONALITIES_NUM]={
00115
00116 true, false, true, false,
00117 true, true, false, true
00118 };
00119
00120
00121
00125 class ParticleMutLocNoMROptions : public Options {
00126 public:
00127
00128 IntOption* minObservationSize;
00129
00130 IntOption* findTarget;
00131 IntOption* targetId;
00132
00133 StringOption* myFrameType;
00134 StringOption* hisFrameType;
00135
00136 StringOption* algoType;
00137
00138 BoolOption* saveEstimates;
00139 StringOption* saveFilesRoot;
00140 BoolOption* offlineSimulation;
00141
00142 ParticleMutLocNoMROptions();
00143
00144 OptionGroupsType getGroup();
00145
00146 string getObjectName() const {
00147 return "ParticleMutLocNoMROptions";
00148 }
00149 };
00150
00151
00155 class ParticleMutLocNoMRSharedMem : public SharedMem{
00156 public:
00158 void initSharedMem();
00159
00163 PosiFeatures getMyProtrusions(MotionModuleTState &state);
00164
00167 Time getTime();
00168
00171 void setFormation(PoseFeatures &form);
00172
00175 void setEstimates(PoseFeatures &est);
00176
00179 Pose getTarget();
00180
00183 void setTarget(Pose &t);
00184
00187 bool doMloc();
00188
00191 bool printFormation();
00192
00195 bool printFormationDetails();
00196
00199 vector<int> getAvoidParticleMutLocIds();
00200 };
00201
00202
00206 class ParticleMutLocTaskNoMR : public Task{
00207 private:
00208 static const TaskPlate _plate = PDE_TASK;
00209 static const long int _maxDurSec = 0, _maxDurUsec = 500000;
00210 static const long int _maxSamplPeriodSec = 1, _maxSamplPeriodUsec = 0;
00211 static const long int _minSamplPeriodSec = 0, _minSamplPeriodUsec = 400000;
00212
00213 MutLocNoMRTypes _algoType;
00214
00215 MutLocFASTSlam* _mlFastSlam;
00216
00217
00218 MobileRob* _mobileRob;
00219 DraWin* _draWin;
00220 unsigned int _drawList;
00221 bool _dwOn;
00222 ParticleMutLocNoMRSharedMem* _sharedMem;
00223 CommModule* _commModule;
00224
00225 FrameTypesPMLNMR _myFrameType;
00226 FrameTypesPMLNMR _hisFrameType;
00227
00228
00229 ParticleMutLocNoMROptions _options;
00230
00231
00232 map<int,MutLocFilter*> _filter;
00233 MutLocFilter* _staticFilter;
00234 map<int,SimTimer> _timeFromLastMeasureUpdate;
00235 vector<int> _activatedFilters;
00236
00237
00238 SimTime _actualTime;
00239 bool _dofilter;
00240 vector<int> ignoreIds;
00241 bool _printFormation;
00242 bool _printFormationDetails;
00243
00244
00245 int _myId;
00246 Pose _myPose;
00247 PosiFeatures _myPosiFeatures;
00248 Observation _myObservation;
00249
00250
00251 map<int,PosiFeatures> _othersPosiFeatures;
00252 vector<int> _othersPosiFeaturesNums;
00253 map<int,Pose> _othersPose;
00254 vector<int> _othersPoseNums;
00255
00256
00257 map<int,Pose> _estimates;
00258 map<int,Pose> _estimatesBest;
00259 vector<int> _activatedEstimates;
00260 map<int,SimTimer> _timeFromLastMessage;
00261 PoseFeatures _formation;
00262 PoseFeatures _formationBest;
00263
00264 fstream _savefile;
00265 fstream _savefileBest;
00266 map<int, fstream*> _saveFileAll;
00267 fstream _savefileAllSt;
00268
00269 public:
00271 ParticleMutLocTaskNoMR(ResourcePointers resources,int argc, const char* argv[]);
00272
00274 ~ParticleMutLocTaskNoMR();
00275
00278 TaskPlate getPlate() const {
00279 return _plate;
00280 }
00283 Time getMaxDuration(){
00284 return Time(_maxDurSec,_maxDurUsec);
00285 }
00288 Time getMaxSamplPeriod(){
00289 return Time(_maxSamplPeriodSec,_maxSamplPeriodUsec);
00290 }
00293 Time getMinSamplPeriod(){
00294 return Time(_minSamplPeriodSec,_minSamplPeriodUsec);
00295 }
00298 TaskOutputs run();
00299
00300 private:
00301
00303 void _readSharedMemory();
00304
00306 void _communicate();
00307
00308
00310 void _sendMyPose(CommNode &sender, CommNode &recipient);
00311
00313 void _sendMyPosiFeature(CommNode &sender, CommNode &recipient);
00314
00316 void _receiveMyPose(CommPacket* packet, int senderId);
00317
00319 void _receiveMyPosiFeature(CommPacket *packet, int senderId);
00320
00321
00322
00323
00324
00325
00327 void _draw();
00328
00330 void _writeSharedMem();
00331
00332 void _computeFormation();
00333
00336 void _insertValidObservations(vector<Observation> &allObservations);
00337
00341 void _completeMutLocFilInput(MutLocFilInput &fStepIn, int hisId);
00342
00345 bool _activeFilter(int hisId);
00346
00349 bool _activeEstimate(int hisId);
00350
00352 void _activateFilter(int hisId);
00353
00355 void _activateStaticObstacleFilter();
00356
00359
00360
00363 map <int, vector<Decimal> > _associateMeasures();
00364
00367 map <int, vector<Decimal> > _associateMeasures2();
00368 };
00369
00370
00371
00372 };
00373
00374
00375 #endif
00376
00377
00378
00379