00001 /** 00002 * @file ObstaclesPercept.h 00003 * 00004 * Declaration of class ObstaclesPercept 00005 * @author <a href="mailto:juengel@informatik.hu-berlin.de">Matthias Juengel</a> 00006 */ 00007 00008 #ifndef __ObstaclesPercept_h_ 00009 #define __ObstaclesPercept_h_ 00010 00011 00012 #include "Tools/Streams/InOut.h" 00013 #include "Tools/Math/Vector2.h" 00014 00015 /** 00016 * The class represents perceived obstacles on the field. 00017 */ 00018 class ObstaclesPercept 00019 { 00020 public: 00021 enum ObstacleType {border, goal, teammate, opponent, unknown}; 00022 enum {maxNumberOfPoints = 200}; /**< Specifies the maximum number of points per line type. */ 00023 00024 Vector2<int> nearPoints[maxNumberOfPoints]; /**< The nearest green points*/ 00025 Vector2<int> farPoints[maxNumberOfPoints]; /**< The most distant green points*/ 00026 bool farPointIsOnImageBorder[maxNumberOfPoints]; /**< Indicates if the far point is an obstacle or the image border */ 00027 ObstacleType obstacleType[maxNumberOfPoints]; 00028 00029 int numberOfPoints; /**< The number of pairs of points */ 00030 00031 enum{ownGoal = 0, opponentGoal = 1}; 00032 bool angleToFreePartOfGoalWasDetermined[2]; 00033 double angleToFreePartOfGoal[2], 00034 distanceToFreePartOfGoal[2], 00035 widthOfFreePartOfGoal[2]; 00036 /** 00037 * Constructor. 00038 */ 00039 ObstaclesPercept() {reset(0);} 00040 00041 /** 00042 * The function empties the obstacle percept. 00043 */ 00044 void reset(unsigned long frameNumber); 00045 00046 /** 00047 * The function adds a new pair of points to the obstacle percept. 00048 * @param nearPoint The near point. 00049 * @param farPoint The far point. 00050 * @param farPointIsOnImageBorder Specifies whether farPoint was found on the image border 00051 */ 00052 void add(const Vector2<int>& nearPoint, const Vector2<int>& farPoint, bool farPointIsOnImageBorder); 00053 00054 /** 00055 * The function adds a new pair of points to the obstacle percept. 00056 * @param nearPoint The near point. 00057 * @param farPoint The far point. 00058 * @param farPointIsOnImageBorder Specifies whether farPoint was found on the image border 00059 * @param obstacleType The type of the obstacle 00060 */ 00061 void add(const Vector2<int>& nearPoint, const Vector2<int>& farPoint, bool farPointIsOnImageBorder, ObstacleType obstacleType); 00062 00063 /** The frame number when perceived. */ 00064 unsigned long frameNumber; 00065 }; 00066 00067 /** 00068 * Streaming operator that reads a ObstaclesPercept from a stream. 00069 * @param stream The stream from which is read. 00070 * @param obstaclesPercept The ObstaclesPercept object. 00071 * @return The stream. 00072 */ 00073 In& operator>>(In& stream,ObstaclesPercept& obstaclesPercept); 00074 00075 /** 00076 * Streaming operator that writes a ObstaclePercept to a stream. 00077 * @param stream The stream to write on. 00078 * @param obstaclesPercept The ObstaclesPercept object. 00079 * @return The stream. 00080 */ 00081 Out& operator<<(Out& stream, const ObstaclesPercept& obstaclesPercept); 00082 00083 00084 #endif //__ObstaclesPercept_h_ 00085 00086 /* 00087 * Change log : 00088 * 00089 * $Log: ObstaclesPercept.h,v $ 00090 * Revision 1.1.1.1 2004/05/22 17:25:59 cvsadm 00091 * created new repository GT2004_WM 00092 * 00093 * Revision 1.5 2004/03/01 11:47:50 juengel 00094 * Moved enum ObstacleType to class ObstaclesPercept. 00095 * 00096 * Revision 1.4 2004/02/28 13:50:36 juengel 00097 * Added ObstacleType. 00098 * 00099 * Revision 1.3 2004/01/19 14:53:46 dueffert 00100 * all frameNumbers (and not only some of them) are unsigned long now 00101 * 00102 * Revision 1.2 2003/11/12 16:19:35 goehring 00103 * frameNumber added to percepts 00104 * 00105 * Revision 1.1 2003/10/07 10:09:36 cvsadm 00106 * Created GT2004 (M.J.) 00107 * 00108 * Revision 1.2 2003/08/08 11:37:30 dueffert 00109 * doxygen docu corrected 00110 * 00111 * Revision 1.1.1.1 2003/07/02 09:40:22 cvsadm 00112 * created new repository for the competitions in Padova from the 00113 * tamara CVS (Tuesday 2:00 pm) 00114 * 00115 * removed unused solutions 00116 * 00117 * Revision 1.3 2003/06/25 18:42:14 juengel 00118 * Added nearPoints, farPoints[maxNumberOfPoints] and farPointIsOnImageBorder to ObstaclesPercept. 00119 * 00120 * Revision 1.2 2003/05/26 08:12:11 juengel 00121 * Moved angleToFreePartOfGoal from specialPercept to obstaclesPercept. 00122 * 00123 * Revision 1.1 2003/03/10 13:52:09 juengel 00124 * Added ObstaclesPercept 00125 * 00126 * 00127 */