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
00057 #include <ObsAvoiAlgoSND.h>
00058
00059 using namespace MipResources;
00060
00061 namespace MipTasks{
00062
00064
00065
00066
00071 class PursuingOptions : public Options {
00072 public:
00073 IntOption* customDebugLevel;
00074
00075 PursuingOptions(){
00076 customDebugLevel = new IntOption("PursuingDebugLevel", "Custom debug level of the Pursuing task.", 3);
00077
00078 list.push_back(customDebugLevel);
00079 }
00080 };
00081
00085 class PursuingSharedMem : public SharedMem{
00086 public:
00088 void initSharedMem();
00089
00091 PoseFeatures getFormation();
00092
00094 PoseFeatures getEstimates();
00095
00097 bool doAutoNavigation();
00098
00100 void setAvoidMutLocIds(vector<int> &newIds);
00101
00104 vector<int> getAvoidMutLocIds();
00105
00107 void clearAvoidMutLocIds();
00108 };
00109
00110
00111 enum PursuingState
00112 {
00113 WAITING,
00114 INITIALIZE,
00115 RUN
00116 };
00117
00121 class Pursuing : public Task, public MessageHandler{
00122 private:
00123 static const TaskPlate _plate = PUR_TASK;
00124 static const long int _maxDurSec = 0, _maxDurUsec = 30000;
00125 static const long int _maxSamplPeriodSec = 0, _maxSamplPeriodUsec = 200000;
00126 static const long int _minSamplPeriodSec = 0, _minSamplPeriodUsec = 100000;
00127
00128 MobileRob* _mobileRob;
00129 ObsAvoiAlgoSND* _pObsAvoiAlgo;
00130
00131 PursuingState _state;
00132 uint _robotID;
00133 PursuingSharedMem* _sharedMem;
00134
00135 PoseFeatures _otherRobotPoses;
00136
00137 Pose _goal;
00138 pthread_mutex_t _goalMutex;
00139 bool _bSendScanFromGoal;
00140 string _centralIP;
00141
00142 int _count;
00143
00144 RangeSensPar* _sensorParams;
00145 Decimal _robotRadius;
00146 PursuingOptions _options;
00147
00148 bool _getScan(Scan &scan, Time waitTime = Time(0,0));
00149 Pose _getPose();
00150 Pose _getGoal();
00151 void _setGoal( Pose newGoal );
00152 bool _atGoal();
00153
00154 void _initialize();
00155 void _recordOtherRobotPoses();
00156 void _navigate();
00157 void _communicate();
00158
00159 void _sendPoseAndScan(string ip);
00160 void _sendPose(string ip);
00161 void _sendParams(string ip);
00162
00165 string getObjectName() const {
00166 stringstream ss;
00167 assert(getPlate()<TASK_NUM);
00168
00169 ss << TaskNames[getPlate()] << ", Agent : "<< getID();
00170 return ss.str();
00171 }
00172
00173 public:
00178 Pursuing(ResourcePointers resources,int argc, const char* argv[]);
00179
00181 ~Pursuing();
00182
00186 TaskPlate getPlate() const {
00187 return _plate;
00188 }
00191 Time getMaxDuration(){
00192 return Time(_maxDurSec,_maxDurUsec);
00193 }
00196 Time getMaxSamplPeriod(){
00197 return Time(_maxSamplPeriodSec,_maxSamplPeriodUsec);
00198 }
00201 Time getMinSamplPeriod(){
00202 return Time(_minSamplPeriodSec,_minSamplPeriodUsec);
00203 }
00205 TaskOutputs run();
00206
00208 uint getID();
00209
00210 Decimal getSensorLinRangeMax();
00211 Angle getSensorFieldOfView();
00212 int getSensorNumRays();
00213 Angle getSensorAngRes();
00214 Decimal getRobotRadius();
00215
00216 void handleMessage(string inMessage,string ip);
00217 };
00218
00219
00220
00221 };
00222
00223 #endif
00224
00225
00226
00227
00228