Pursuing.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
00034
00035
00036 #ifndef __PURSUING_H_
00037 #define __PURSUING_H_
00038
00039 #ifdef MIP_HOST_APPLE
00040 #include <applePatch.h>
00041 #endif
00042
00043 #include <fstream>
00044
00045 #include <R2.h>
00046 #include <Grid.h>
00047 #include <Scan.h>
00048
00049 #include <Task.h>
00050 #include <Resource.h>
00051 #include <MobileRob.h>
00052 #include <SharedMem.h>
00053 #include <Time.h>
00054
00055 #include <CommonOptions.h>
00056 #include <CommModule.h>
00057 #include <PursuingData.h>
00058 #include <PursuingComm.h>
00059
00060 using namespace MipResources;
00061
00062 namespace MipTasks{
00063
00065
00066
00067
00072 class PursuingOptions : public Options {
00073 public:
00074
00075 IntOption* customDebugLevel;
00076
00077
00078 PursuingOptions(){
00079
00080 customDebugLevel = new IntOption("PursuingDebugLevel", "Custom debug level of the Pursuing task.", 3);
00081
00082
00083
00084 }
00085 };
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097 typedef std::vector<Position > PositionPath;
00098 typedef std::vector<Position > ViewPoints;
00099
00100 int gMinArcSize = 2;
00101 int gMinMergeArcSize = 1;
00102 int gMinRadialArcSize = 3;
00103
00104
00109 class Pursuing : public Task{
00110 private:
00111 static const TaskPlate _plate = PUR_TASK;
00112 static const long int _maxDurSec = 0, _maxDurUsec = 30000;
00113 static const long int _maxSamplPeriodSec = 0, _maxSamplPeriodUsec = 200000;
00114 static const long int _minSamplPeriodSec = 0, _minSamplPeriodUsec = 100000;
00115
00116 MobileRob* _mobileRob;
00117 CommModule* _commModule;
00118 PursuingComm *_pursuingComm;
00119
00120 uint _robotId;
00121
00122
00123 PursuingOptions _options;
00124
00125 PursuingStates _state;
00126 PursuingGuardStates _frontGuardSubState;
00127 PursuingGuardUpdatingStates _frontGuardUpdatingSubState;
00128 PursuingWandererStates _wandererSubState;
00129
00130 Frontier _frontier;
00131 Frontier _freeArcs;
00132 Frontier _prevFrontier;
00133 Grid _LSR;
00134 Grid _prevLSR;
00135 bool _bFrontierInitialized;
00136
00137
00138 int _iLeader;
00139
00140
00141
00142 int _iWaitForAgent;
00143
00144
00145 map<uint,PursuingMessageTypes > _asynRequests;
00146 vector<uint> _followers;
00147 map<uint,GuardUpdatingState> _localGuards;
00148 map<uint,PursuingStates> _neighborStates;
00149 map<uint,TimeStampedPose> _neighborPoses;
00150
00151 void _expand( );
00152
00153 void _guardUpdating( );
00154 void _guardPlanning();
00155 void _guardIdleSendingFollower( );
00156 void _guardIdle( );
00157
00158 void _follow( );
00159 void _wander( );
00160 void _wanderWaiting();
00161
00162 void _recordLSR();
00163 Position _pickBestViewpoint( uint *iNumViewPoints );
00164 bool _isCellCovered( DubInt iViewPoint, DubInt iCell );
00165 ExplorationParams _getExplParams();
00166
00167
00168
00170 void _setToExpand( Pose goalPose );
00171
00174 string getObjectName() const {
00175 stringstream ss;
00176 assert(getPlate()<TASK_NUM);
00177
00178 ss << TaskNames[getPlate()] << ", Agent : "<< getId();
00179 return ss.str();
00180 }
00181
00183 void _setToGuard( );
00184
00186 void _setToFollow( uint leaderId );
00187
00189 void _setToWander( );
00190 void _setToWanderWaitingForLeader( uint leaderId );
00191
00193 void _printNeighbouringGuards();
00194
00196 void _printAsyncRequests();
00197
00200 void _updateAsynRequests();
00201
00204 void _updateGuardList();
00205
00208 bool _guardUpdatingDone();
00209
00213 void _receiveGimmeYourFrontier(int &robIdTosendTo,bool &hasToSendFrontier);
00214
00218 void _checkLocalGuardsArray(int &robIdToSendTo,bool &hasToSendFrontier );
00219
00221 void _receiveFrontiers();
00222
00224 void _receiveUpdatedFrontier();
00225
00227 void _commonActions();
00228
00231 bool _isWaitingForAnyAgent();
00232
00234 void _updateFrontier();
00235
00237 void _processFrontier();
00238
00239 public:
00244 Pursuing(ResourcePointers resources,int argc, const char* argv[]);
00245
00247 ~Pursuing();
00248
00252 TaskPlate getPlate() const {
00253 return _plate;
00254 }
00257 Time getMaxDuration(){
00258 return Time(_maxDurSec,_maxDurUsec);
00259 }
00262 Time getMaxSamplPeriod(){
00263 return Time(_maxSamplPeriodSec,_maxSamplPeriodUsec);
00264 }
00267 Time getMinSamplPeriod(){
00268 return Time(_minSamplPeriodSec,_minSamplPeriodUsec);
00269 }
00271 TaskOutputs run();
00272
00274 uint getId();
00275 };
00276
00277
00278
00279 };
00280
00281 #endif
00282
00283
00284
00285
00286