Driver.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
00027
00028 #ifndef __DRIVER_H_
00029 #define __DRIVER_H_
00030
00031 #include <Task.h>
00032 #include <Resource.h>
00033 #include <MobileRob.h>
00034 #include <MobileRob3D.h>
00035 #include <IPCommModule.h>
00036
00037 #include <CommonOptions.h>
00038
00039
00040 #include <ObsAvoiAlgoPFM.h>
00041 #include <ObsAvoiAlgoVFH.h>
00042
00043 #include <Serialization.h>
00044 #include <SharedMem.h>
00045
00049
00050
00054
00055
00056 using namespace MipAlgorithms;
00057 using namespace MipResources;
00058
00059 namespace MipTasks{
00061
00062
00064 enum DriverState{
00065 DRIVER_FIRST_RUN,
00066 DRIVER_NORMAL_RUN,
00067 DRIVER_NUM_RUNS
00068 };
00069
00070
00072 enum ObsAvoiMethod{
00073 NO=0,
00074 PFM=1,
00075 VFH=2,
00076 OBSAVOI_NUM_METHODS
00077 };
00078
00080 enum DriveInput{
00081 POSITION=0,
00082 SPEED=1,
00083 DRIVE_INPUT_NUM
00084 };
00085
00086
00090 class DriverOptions : public Options {
00091 public:
00092 IntOption* driverInput;
00093 IntOption* driverObsAvoi;
00094 DecimalOption* driverGoalX;
00095 DecimalOption* driverGoalY;
00096 DecimalOption* driverGoalZ;
00097 DecimalOption* driverGoalTheta;
00098 DecimalOption* driverMaxV;
00099 DecimalOption* driverMaxW;
00100
00101 string getObjectName() const;
00102
00103 DriverOptions();
00104 };
00105
00106
00107
00111 class DriverSharedMem : public SharedMem{
00112 public:
00114 void initSharedMem();
00115
00117 bool emergencyLock();
00118
00122 void setControlInput(Decimal lv, Decimal av, Time t);
00123 };
00124
00125
00129 class DriverTaskPar {
00130 private:
00131 public:
00133 Decimal Vmax;
00135 Decimal Wmax;
00137 Decimal goalReachedEps;
00139 Decimal Kv;
00141 Decimal Kw;
00143 Decimal Kwe;
00145 DriveInput driverInput;
00146
00148 DriverTaskPar();
00149
00151 DriverTaskPar(DriverOptions& options);
00152
00154 DriverTaskPar(Decimal VmaxP, Decimal WmaxP, Decimal goalReachedEpsP, Decimal KvP, Decimal KwP, Decimal KweP,DriveInput driverInputP);
00155
00157 DriverTaskPar(const DriverTaskPar &A);
00158
00160 DriverTaskPar operator= (DriverTaskPar A);
00161 };
00162
00163
00167 class DriverTask : public Task{
00168 private:
00169 static const TaskPlate _plate = DRV_TASK;
00170 static const long int _maxDurSec = 0, _maxDurUsec = 100000;
00171 static const long int _maxSamplPeriodSec = 0, _maxSamplPeriodUsec = 150000;
00172 static const long int _minSamplPeriodSec = 0, _minSamplPeriodUsec = 100000;
00173
00174 static const long int TRACE_ON_DEFAULT = 0;
00175 static const long int COMM_TRACE_ON_DEFAULT = 0;
00176 static const long int BACK_VEL_DEFAULT = 0;
00177
00178 MobileRob* _mobileRob;
00179 MobileRob3D* _mobileRob3D;
00180 CommModule* _commModule;
00181
00182 bool useMobileRob;
00183 bool useMobileRob3D;
00184
00185 DriverSharedMem* _sharedMem;
00186
00187 bool commTraceOn;
00188 bool traceOn;
00189
00191 DriverState state;
00192 DriverTaskPar par;
00194 ObsAvoiMethod method;
00195
00197 bool backVelOn;
00198
00200 ObsAvoiAlgo* OA;
00201 ObsAvoiAlgoIn OAin;
00202 ObsAvoiAlgoOut OAout;
00203
00205 Pose robPose;
00206 Pose3D robPose3D;
00208 Scan scan;
00209
00211 Pose goal;
00212 Pose3D goal3D;
00213 Position goalVel;
00214
00216 Decimal traveledDistance;
00217
00219 Decimal V;
00221 Decimal W;
00222
00223 Timer controlPeriod;
00224
00226 DriverOptions options;
00227
00230 void init(ResourcePointers resources);
00232 void firstRun();
00234 void normalRun();
00235
00237 void getCommPackets();
00239 void getPoseAndScan();
00241 void getPoseAndScan3D();
00243 void getGoal();
00245 void getGoal3D();
00247 void getGoalVel();
00249 void getControl();
00251 void drivePos();
00253 void driveVel();
00254
00256 void attractiveControl();
00258 void velSat();
00259
00260 public:
00266 DriverTask(ResourcePointers resources,int argc, const char* argv[]);
00267
00269 ~DriverTask();
00270
00272 TaskPlate getPlate() const {
00273 return _plate;
00274 }
00276 Time getMaxDuration(){
00277 return Time(_maxDurSec,_maxDurUsec);
00278 }
00280 Time getMaxSamplPeriod(){
00281 return Time(_maxSamplPeriodSec,_maxSamplPeriodUsec);
00282 }
00284 Time getMinSamplPeriod(){
00285 return Time(_minSamplPeriodSec,_minSamplPeriodUsec);
00286 }
00287
00289 TaskOutputs run();
00290 };
00291
00292
00293
00294 };
00295
00296 #endif
00297
00298
00299
00300
00301