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 #include <Message.h>
00055
00056 #include <CommonOptions.h>
00057
00058 #include <ObsAvoiAlgoSND.h>
00059
00060 using namespace MipResources;
00061 using namespace MipBaselib;
00062 using namespace MipAlgorithms;
00063
00064 namespace MipTasks{
00065
00067
00068
00069
00074 class PursuingOptions : public Options {
00075
00076 public:
00077 IntOption* customDebugLevel;
00078 DecimalOption* maxSpeed;
00079 DecimalOption* maxRotSpeed;
00080 DecimalOption* maxRange;
00081 BoolOption* forceHokuyoPar;
00082
00083 PursuingOptions();
00084
00085 string getObjectName() const {
00086 return "PursuingOptions";
00087 }
00088 };
00089
00093 class PursuingSharedMem : public SharedMem{
00094 public:
00096 void initSharedMem();
00097
00099 PoseFeatures getFormation();
00100
00102 PoseFeatures getEstimates();
00103
00105 bool doAutoNavigation();
00106
00108 void setAvoidMutLocIds(vector<int> &newIds);
00109
00112 vector<int> getAvoidMutLocIds();
00113
00115 void clearAvoidMutLocIds();
00116 };
00117
00118
00119 enum PursuingState
00120 {
00121 WAITING,
00122 INITIALIZE,
00123 RUN
00124 };
00125
00129 class Pursuing : public Task, public MessageHandler{
00130 private:
00131 static const TaskPlate _plate = PUR_TASK;
00132 static const long int _maxDurSec = 0, _maxDurUsec = 30000;
00133 static const long int _maxSamplPeriodSec = 0, _maxSamplPeriodUsec = 200000;
00134 static const long int _minSamplPeriodSec = 0, _minSamplPeriodUsec = 100000;
00135
00136 MobileRob* _mobileRob;
00137 ObsAvoiAlgoSND* _pObsAvoiAlgo;
00138
00139 PursuingState _state;
00140 uint _robotID;
00141 PursuingSharedMem* _sharedMem;
00142
00143 PoseFeatures _otherRobotPoses;
00144
00145 Pose _goal;
00146 pthread_mutex_t _goalMutex;
00147 bool _bSendScanFromGoal;
00148 string _centralIP;
00149
00150 int _count;
00151
00152 RangeSensPar* _sensorParams;
00153 Decimal _rangeMax;
00154 Decimal _robotRadius;
00155 PursuingOptions _options;
00156
00157 bool _getScan(Scan &scan, Time waitTime = Time(0,0));
00158 Pose _getPose();
00159 Pose _getGoal();
00160 void _setGoal( Pose newGoal );
00161 bool _atGoal();
00162
00163 void _initialize();
00164 void _recordOtherRobotPoses();
00165 void _navigate();
00166 void _communicate();
00167
00168 void _sendPoseAndScan(string ip);
00169 void _sendPose(string ip);
00170 void _sendPoseArray(string ip);
00171 void _sendParams(string ip);
00172
00175 string getObjectName() const {
00176 stringstream ss;
00177 assert(getPlate()<TASK_NUM);
00178
00179 ss << TaskNames[getPlate()] << ", Agent : "<< getID();
00180 return ss.str();
00181 }
00182
00183 public:
00188 Pursuing(ResourcePointers resources,int argc, const char* argv[]);
00189
00191 ~Pursuing();
00192
00196 TaskPlate getPlate() const {
00197 return _plate;
00198 }
00201 Time getMaxDuration(){
00202 return Time(_maxDurSec,_maxDurUsec);
00203 }
00206 Time getMaxSamplPeriod(){
00207 return Time(_maxSamplPeriodSec,_maxSamplPeriodUsec);
00208 }
00211 Time getMinSamplPeriod(){
00212 return Time(_minSamplPeriodSec,_minSamplPeriodUsec);
00213 }
00215 TaskOutputs run();
00216
00218 uint getID() const;
00219
00220 Decimal getSensorLinRangeMax();
00221 Angle getSensorFieldOfView();
00222 int getSensorNumRays();
00223 Angle getSensorAngRes();
00224 Decimal getRobotRadius();
00225
00226 void handleMessage(string inMessage,string ip);
00227 };
00228
00229
00230
00231 };
00232
00233 #endif
00234
00235
00236
00237
00238