ObsAvoiAlgoSND.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
00029
00030 #ifndef __OBS_AVOI_ALGO_SND_H
00031 #define __OBS_AVOI_ALGO_SND_H
00032
00033 #ifdef MIP_HOST_APPLE
00034 #include <applePatch.h>
00035 #endif
00036
00037 #include <algorithm>
00038 #include <ObsAvoiAlgo.h>
00039 #include <Spaces.h>
00040 #include <Scan.h>
00041 #include <Option.h>
00042 #include <LogTrace.h>
00043 #include <list>
00044
00045 using namespace MipBaselib;
00046
00047 namespace MipAlgorithms{
00048
00050
00051
00052 class ObsAvoiSNDGap {
00053 public:
00054 Angle bearing;
00055 Decimal distance;
00056 int iDir;
00057
00058 ObsAvoiSNDGap(){};
00059 ObsAvoiSNDGap( Angle ang, Decimal d, int iD ){ bearing = ang; distance = d; iDir = iD; };
00060 };
00061
00062 class ObsAvoiSNDValley {
00063 public:
00064 ObsAvoiSNDGap risingGap;
00065 ObsAvoiSNDGap otherGap;
00066
00067 ObsAvoiSNDValley(){};
00068 ObsAvoiSNDValley( ObsAvoiSNDGap rG, ObsAvoiSNDGap oG ){ risingGap = rG; otherGap = oG; };
00069 };
00070
00071
00079 class ObsAvoiAlgoSNDOptions : public Options {
00080 public:
00081
00082 DecimalOption* robotRadius;
00083 DecimalOption* obstacleAvoidDist;
00084
00085 DecimalOption* maxSpeed;
00086 DecimalOption* maxTurnRate;
00087 DecimalOption* goalPositionTol;
00088 DecimalOption* goalAngleTol;
00089 DecimalOption* minGapWidth;
00090
00091 BoolOption* trajectoryMode;
00092
00093 ObsAvoiAlgoSNDOptions();
00094
00095 string getObjectName() const {
00096 return "ObsAvoiAlgoSNDOptions";
00097 }
00098
00099 };
00100
00101
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00125 class ObsAvoiAlgoSNDParams : public MIPObject{
00126 ObsAvoiAlgoSNDOptions _options;
00127
00128 public:
00129
00130 Decimal robotRadius;
00131 Decimal obstacleAvoidDist;
00132
00133 Decimal maxSpeed;
00134 Decimal maxTurnRate;
00135 Decimal goalPositionTol;
00136 Decimal goalAngleTol;
00137 Decimal minGapWidth;
00138
00139 bool trajectoryMode;
00140
00150 ObsAvoiAlgoSNDParams(Decimal R=0.25,Decimal oAD=1.0,Decimal mS=0.5,Decimal mTR=1.5,Decimal gPT=0.25,Decimal gAT=6.3,Decimal mGW=0.6,bool mode=false);
00151
00155 ObsAvoiAlgoSNDParams(int argc, const char* argv[]);
00156
00158 string getObjectName() const {
00159 return "ObsAvoiAlgoSND";
00160 }
00161 };
00162
00166 class ObsAvoiAlgoSNDVars {
00167
00168 public:
00169
00170 Pose robotPose;
00171 Pose goal;
00172
00173 std::vector<ObsAvoiSNDGap> gapVec;
00174 ObsAvoiSNDValley* pBestValley;
00175 Angle safeRisingGapAngle;
00176 Angle midValleyAngle;
00177 Decimal obsAvoidDelta;
00178
00179 Angle driveAngle;
00180 ObsAvoiAlgoOut out;
00181
00183 ObsAvoiAlgoSNDVars(){pBestValley = NULL;}
00184 };
00185
00186
00190 class ObsAvoiAlgoSND : public ObsAvoiAlgo{
00191
00192 public:
00193 ObsAvoiAlgoSNDVars _var;
00194 ObsAvoiAlgoSNDParams _par;
00195
00196 stringstream _ssdebug;
00197
00198 Rays _Filtering(Scan &scan);
00199
00200 void _buildGapVector( Scan* pScan, Decimal fMaxRange );
00201 void _removeDuplicateGaps( Decimal fScanRes );
00202 void _findBestValley( Position distToGoal, Scan* pScan, Decimal fMaxRange );
00203 void _setObsAvoidDelta( Scan* pScan, Decimal safetyDist );
00204
00205 public:
00208 ObsAvoiAlgoSND(ObsAvoiAlgoSNDParams inParams);
00209
00213 void step(ObsAvoiAlgoIn in, ObsAvoiAlgoOut &out);
00214
00215 void getControl(ObsAvoiAlgoIn &in, ObsAvoiAlgoOut *out){
00216
00217 ObsAvoiAlgoIn inSND;
00218
00219 inSND.goal = in.goal;
00220 inSND.rangeMax = 1.0;
00221 inSND.robPose = in.robPose;
00222 inSND.scan = in.scan;
00223
00224 this->step(inSND, *out);
00225 }
00226
00227
00228
00230 string getObjectName() const {
00231 return "ObsAvoiAlgoSND";
00232 }
00233 };
00234
00235
00236
00237 };
00238
00239
00240 #endif
00241
00242
00243
00244
00245
00246
00247