00001
00002
00003
00004
00005
00006
00007
00008 #ifndef __ObstaclesModel_h_
00009 #define __ObstaclesModel_h_
00010
00011
00012 #include "Tools/Streams/InOut.h"
00013 #include "Tools/Math/Common.h"
00014 #include "Tools/Debugging/Debugging.h"
00015
00016 #include "Representations/Perception/ObstaclesPercept.h"
00017
00018
00019
00020
00021 class ObstaclesModel
00022 {
00023 public:
00024 ObstaclesModel();
00025 ~ObstaclesModel();
00026
00027
00028 void operator = (const ObstaclesModel& other);
00029
00030 enum Directions{ back, backRight, right, frontRight, front, frontLeft, left, backLeft, numberOfDirections};
00031 enum SearchDirections{searchLeft, searchLeftAndRight, searchRight};
00032 enum { numOfSectors = 90 , maxDistance = 1500};
00033
00034
00035
00036
00037 static double getAngleOfSector(int sector)
00038 {
00039
00040
00041 return -pi + ((double)sector + 0.5) * pi2 / numOfSectors;
00042
00043
00044
00045
00046
00047
00048 }
00049
00050
00051 unsigned long frameNumber;
00052
00053 void setFrameNumber(unsigned long frameNumber) {this->frameNumber = frameNumber;}
00054
00055
00056 int distance[numOfSectors];
00057
00058
00059 ObstaclesPercept::ObstacleType obstacleType[numOfSectors];
00060
00061
00062 int corridorInFront;
00063
00064
00065 int currentlySeenStartSector;
00066 int currentlySeenEndSector;
00067
00068
00069
00070
00071 double getDistanceInCorridor(double angle, double width) const;
00072
00073
00074
00075 double getAngleOfNextFreeSector(double sizeOfSector, double angle, int minDistance) const;
00076
00077
00078
00079 double getAngleOfNextFreeSectorLeft(double sizeOfSector, double angle, int minDistance) const;
00080 double getAngleOfNextFreeSectorRight(double sizeOfSector, double angle, int minDistance) const;
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090 int getDistanceInMajorDirection(Directions direction) const;
00091
00092
00093
00094
00095 int getDistanceInDirection(double direction, double openingAngle) const;
00096
00097
00098
00099
00100 int getSectorDistanceInDirection(double direction) const;
00101
00102
00103
00104
00105 double getTotalFreeSpaceInSector(double direction, double openingAngle, double maxDist) const;
00106
00107
00108
00109
00110 int getMinimalDistanceInRange(double centerAngle, double openingAngle, double& angleWithMinimalDistance) const;
00111
00112
00113
00114
00115 int getMinimalDistanceInRange(double centerAngle, double openingAngle, double& angleWithMinimalDistance, ObstaclesPercept::ObstacleType obstacleType) const;
00116
00117
00118
00119 double getPercentageOfLowDistanceObstaclesInRange(double centerAngle, double openingAngle, int maxDistance) const;
00120
00121
00122
00123
00124 double getAngleOfLargeGapInRange(double centerAngle, double openingAngle, SearchDirections searchDirection) const;
00125
00126
00127
00128
00129 double getAngleOfLargeGapInRange2(double centerAngle, double openingAngle, SearchDirections searchDirection) const;
00130
00131
00132
00133
00134 static int getSectorFromAngle(double angle)
00135 {
00136 return (int)((normalize(angle) + pi) / pi2 * numOfSectors);
00137 }
00138
00139 enum {ownGoal = 0, opponentGoal = 1};
00140 double angleToFreePartOfGoal[2];
00141 double widthOfFreePartOfGoal[2];
00142 double distanceToFreePartOfGoal[2];
00143 unsigned long lastTimeFreePartOfGoalWasDetermined[2];
00144 bool angleToFreePartOfGoalWasDetermined[2];
00145
00146 bool angleToNextFreeTeammateWasDetermined;
00147 double angleToNextFreeTeammate;
00148 double distanceToNextFreeTeammate;
00149
00150
00151 double angleToSeenGoal[2];
00152
00153
00154 double distanceToSeenGoal[2];
00155
00156
00157 bool trustSeenGoal[2];
00158
00159
00160
00161 unsigned long timeOfSeenGoal[2];
00162
00163
00164
00165
00166
00167 double bodyPSD;
00168 };
00169
00170
00171
00172
00173
00174
00175
00176 In& operator>>(In& stream,ObstaclesModel& obstaclesModel);
00177
00178
00179
00180
00181
00182
00183
00184 Out& operator<<(Out& stream, const ObstaclesModel& obstaclesModel);
00185
00186
00187 #endif //__ObstaclesModel_h_