Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

Representations/Cognition/ObstaclesModel.h

Go to the documentation of this file.
00001 /**
00002  * @file ObstaclesModel.h
00003  * 
00004  * Declaration of class ObstaclesModel
00005  * @author <a href="mailto:juengel@informatik.hu-berlin.de">Matthias Juengel</a>
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  * A class describing the distance to obstacles around the robot,
00020  */
00021 class ObstaclesModel
00022 {
00023 public:
00024   ObstaclesModel();
00025   ~ObstaclesModel();
00026 
00027   /** copies another ObstaclesModel to this one */
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    * return the center angle of a given sector
00036    */
00037   static double getAngleOfSector(int sector)
00038   {
00039 //    if(sector < numOfSectors && 0 <= sector)
00040 //    {
00041       return -pi + ((double)sector + 0.5) * pi2 / numOfSectors;
00042 //    }
00043 //    else
00044 //    {
00045 //      OUTPUT(idText, text, "sector out of range");
00046 //      return 0;
00047 //    }
00048   }
00049 
00050   /** the frame number when perceived */
00051   unsigned long frameNumber;
00052 
00053   void setFrameNumber(unsigned long frameNumber) {this->frameNumber = frameNumber;}
00054   
00055   /** the distance to the closest obstacle in an angular sector */
00056   int distance[numOfSectors];
00057 
00058   /** */
00059   ObstaclesPercept::ObstacleType obstacleType[numOfSectors];
00060 
00061   /** the distance to the closest obstacle in a rectangular corridor in front of the robot */
00062   int corridorInFront;
00063 
00064   /** currently seen begining sector and end sector */
00065   int currentlySeenStartSector;
00066   int currentlySeenEndSector;
00067 
00068 
00069   /** returns the distance to the closest obstacle
00070    * in the corridor specified by angle and width */
00071   double getDistanceInCorridor(double angle, double width) const;
00072 
00073   /** returns the angle of the closest free sector with angle sizeOfSector 
00074    * relative to angle. Free means free up to minDistance */
00075   double getAngleOfNextFreeSector(double sizeOfSector, double angle, int minDistance) const;
00076 
00077   /** returns the angle of the closest free with angle sizeOfSector 
00078    * relative to angle. Free means free up to minDistance */
00079   double getAngleOfNextFreeSectorLeft(double sizeOfSector, double angle, int minDistance) const;
00080   double getAngleOfNextFreeSectorRight(double sizeOfSector, double angle, int minDistance) const;
00081 
00082   /** Calculates the angle with the farsest distance to an obstacle between the front direction and the angle.
00083    * Returns the distance.
00084    */
00085 //  int getBestAngleBetweenFrontAndDestination(double sizeOfSector, double angle, double& bestAngle) const;
00086 
00087   /** 
00088    * returns the distance to the closest obstacle
00089    * in one of the major directions defined above */
00090   int getDistanceInMajorDirection(Directions direction) const;
00091 
00092   /**
00093    * return the distance to the closest obstacle
00094    * in a given direction and a given opening angle */
00095   int getDistanceInDirection(double direction, double openingAngle) const;
00096   /**
00097    * return the distance of an sector to the closest obstacle
00098    * in a given direction */
00099 
00100   int getSectorDistanceInDirection(double direction) const;
00101   /**
00102   * sums up all distances in a sector specified by direction and opening angle;
00103   * the maxDist(ance) specifies what the maximum distance should be when
00104   * adding up (you don't want really big single values to distort the sum) */
00105   double getTotalFreeSpaceInSector(double direction, double openingAngle, double maxDist) const;
00106 
00107   /** Calculates the angle with the closest distance to an obstacle.
00108    * Returns the distance.
00109    */
00110   int getMinimalDistanceInRange(double centerAngle, double openingAngle, double& angleWithMinimalDistance) const;
00111 
00112   /** Calculates the angle with the closest distance to an obstacle of a certain obstacle type.
00113    * Returns the distance.
00114    */
00115   int getMinimalDistanceInRange(double centerAngle, double openingAngle, double& angleWithMinimalDistance, ObstaclesPercept::ObstacleType obstacleType) const;
00116 
00117   /** Calculates the percentage of sectors with obstacles that are closer than the specified distance in the specified range.
00118    */
00119   double getPercentageOfLowDistanceObstaclesInRange(double centerAngle, double openingAngle, int maxDistance) const;
00120 
00121   /** Calculates the angle with the farsest distance to an obstacle.
00122    * Returns the angle.
00123    */
00124   double getAngleOfLargeGapInRange(double centerAngle, double openingAngle, SearchDirections searchDirection) const;
00125 
00126   /** Calculates the angle with the farsest distance to an obstacle.
00127    * Returns the angle.
00128    */
00129   double getAngleOfLargeGapInRange2(double centerAngle, double openingAngle, SearchDirections searchDirection) const;
00130 
00131   /**
00132    * return the corresponding sector to a given angle
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]; // NOT SET BY GoalRecognizer DDD2005 version
00143   unsigned long lastTimeFreePartOfGoalWasDetermined[2];
00144   bool angleToFreePartOfGoalWasDetermined[2];
00145 
00146   bool angleToNextFreeTeammateWasDetermined;
00147   double angleToNextFreeTeammate;
00148   double distanceToNextFreeTeammate;
00149 
00150   /** angle to seen goal, updated by vision and odometry*/
00151   double angleToSeenGoal[2];
00152 
00153   /** distance to seen goal, updated by vision and odometry*/
00154   double distanceToSeenGoal[2];
00155 
00156   /** something is definitely wrong with the seen goal (occurs only when not seeing the goal)*/
00157   bool trustSeenGoal[2]; /* kicks in when the other goal is seen and the angle to the goal is also in the image */
00158 
00159 
00160   /** time since last seen goal*/
00161   unsigned long timeOfSeenGoal[2];
00162 
00163 
00164   /**
00165   * last value of the body psd sensor (if present)
00166   */
00167   double bodyPSD;
00168 };
00169 
00170 /**
00171  * Streaming operator that reads a ObstaclesModel from a stream.
00172  * @param stream The stream from which is read.
00173  * @param obstaclesModel The ObstaclesModel object.
00174  * @return The stream.
00175  */ 
00176 In& operator>>(In& stream,ObstaclesModel& obstaclesModel);
00177  
00178 /**
00179  * Streaming operator that writes a ObstaclesModel to a stream.
00180  * @param stream The stream to write on.
00181  * @param obstaclesModel The ObstaclesModel object.
00182  * @return The stream.
00183  */ 
00184 Out& operator<<(Out& stream, const ObstaclesModel& obstaclesModel);
00185 
00186 
00187 #endif //__ObstaclesModel_h_

Generated on Mon Mar 20 22:00:01 2006 for GT2005 by doxygen 1.3.6