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

Representations/Perception/LandmarksPercept.h

Go to the documentation of this file.
00001 /**
00002 * @file Representations/Perception/LandmarksPercept.h
00003 *
00004 * Contains the definition of class LandmarksPercept. 
00005 *
00006 * @author <A href=mailto:roefer@tzi.de>Thomas Röfer</A>
00007 * @author <A href=mailto:asbre01@tzi.de>Andreas Sztybryc</A>
00008 */ 
00009 
00010 #ifndef __LandmarksPercept_h_
00011 #define __LandmarksPercept_h_
00012 
00013 #include "Tools/Streams/InOut.h"
00014 #include "Tools/Math/Vector3.h"
00015 #include "Tools/Math/Common.h"
00016 #include "Tools/ColorClasses.h"
00017 #include "Tools/Boundary.h"
00018 
00019 /**
00020 * The class represents a rectangular landmark boundary.
00021 * It also encodes, which edges of the boundary touch the image border.
00022 */
00023 class ConditionalBoundary : public Boundary<double>
00024 {
00025 private:
00026   Boundary<double> freeBorders; /**< Contains the edges that do not touch the image border. */
00027   
00028 public:
00029 /**
00030 * Constructor.
00031 * The boundary is empty.
00032   */
00033   ConditionalBoundary()
00034     : Boundary<double>(-pi,pi),
00035     freeBorders(-pi,pi) {}
00036   
00037   /**
00038    * The function adds a point to the boundary.
00039    * @param px The x-coordinate of a new x-boundary-candidate.
00040    * @param isOnBorder Is the point on the image border?
00041    */
00042   void addX(const double px,bool isOnBorder)
00043   {
00044     x.add(px);
00045     if(!isOnBorder)
00046       freeBorders.x.add(px);
00047   }
00048   
00049   
00050   /**
00051    * The function adds a point to the boundary.
00052    * @param py The y-coordinate of a new y-boundary-candidate.
00053    * @param isOnBorder Is the point on the image border?
00054    */
00055   void addY(const double py,bool isOnBorder)
00056   {
00057     y.add(py);
00058     if(!isOnBorder)
00059       freeBorders.y.add(py);
00060   }
00061 
00062   /**
00063   * The function adds another boundary to this one.
00064   * @param b The other boundary.
00065   */
00066   void add(const ConditionalBoundary& b)
00067   {
00068     Boundary<double>::add(b);
00069     freeBorders.add(b.freeBorders);
00070   }
00071   
00072   /**
00073   * The function determines whether a certain edge lies on the image border.
00074   * @param border This parameter specifies the edge to test. The parameter
00075   *               must be one of the following four members of this object:
00076   *               x.min, x.max, y.min, y.max. A typical call would be:
00077   *               b.isOnBorder(b.min.x)
00078   * @return Does the specified edge touch the image border?
00079   */
00080   bool isOnBorder(const double& border) const
00081   {
00082     if(&x.min == &border)
00083       return x.min != freeBorders.x.min;
00084     else if(&x.max == &border)
00085       return x.max != freeBorders.x.max;
00086     else if(&y.min == &border)
00087       return y.min != freeBorders.y.min;
00088     else if(&y.max == &border)
00089       return y.max != freeBorders.y.max;
00090     return false;
00091   }
00092 };
00093 
00094 /**
00095 * The class represents a flag.
00096 */
00097 class Flag : public ConditionalBoundary
00098 {
00099 public:
00100   enum FlagType
00101   {
00102     pinkAboveYellow, pinkAboveSkyblue, 
00103     yellowAbovePink, skyblueAbovePink,
00104     numberOfFlagTypes
00105   }; /**< The type is used to identify the six different flags on the field. */
00106   
00107   FlagType type; /**< The type of this flag. */
00108   Vector2<double> position; /**< The position of this flag on the field. */
00109   double distanceValidity; /**< The validity of the determined distance. Not used yet. */
00110   double angleValidity; /**< The validity of the determined direction. Not used yet. */
00111   
00112   /** distance to the flag, relative to robot */
00113   double distance;
00114   
00115   /** angle to the flag, relative to robot */
00116   double angle;
00117   
00118   /**
00119   * The function returns the color of the lower part of this flag.
00120   * @return The color of the lower half.
00121   */
00122   colorClass getLowerColor() const;
00123   
00124   /**
00125   * The function returns the color of the upper part of this flag.
00126   * @return The color of the upper half.
00127   */
00128   colorClass getUpperColor() const;
00129 };
00130 
00131 /**
00132 * The class represents a goal.
00133 */
00134 class Goal : public ConditionalBoundary
00135 {
00136 public:
00137   colorClass color; /**< The color of the goal. */
00138   Vector2<double> leftPost, /**< The position of the goal post that is <i>seen</i> left. */
00139     rightPost; /**< The position of the goal post that is <i>seen</i> right. */
00140   double distanceValidity; /**< The validity of the determined distance. Not used yet. */
00141   double angleValidity; /**< The validity of the determined direction. Not used yet. */
00142   
00143   /** distance to left corner of the goal, relative to robot */
00144   double distance;
00145   
00146   /** angle to the goal, relative to robot (meassured to the middle of the goalline) */
00147   double angle;
00148   
00149   /** rotation of the the goal, relative to robot (meassured to the middle of the goalline) */
00150   double rotation;
00151 };
00152 
00153 /**
00154 * The class represents all detected landmark percepts.
00155 */
00156 class LandmarksPercept
00157 {
00158 public:
00159   Flag flags[4]; /**< The array of up to 4 flags. */
00160   int numberOfFlags; /**< The number of flags actually stored in the array. */
00161   Goal goals[2]; /**< The array of up to 2 goals. */
00162   int numberOfGoals; /**< The number of goals actually stored in the array. */
00163   Vector3<double> cameraOffset; /**< The camera offset relative to position of the robot's neck */
00164   unsigned long frameNumber; /**< The frame number when perceived. */
00165   /**
00166   * Constructor.
00167   * Resets the object.
00168   */
00169   LandmarksPercept();
00170   
00171   /**
00172   * The function resets the object, i.e. the numbers of flags and goals are set to 0.
00173   */
00174   void reset(unsigned long frameNumber);
00175   
00176   /**
00177   * The function adds a flag to the flag array.
00178   */
00179   void addFlag(Flag::FlagType type,
00180     const Vector2<double>& position,
00181     const ConditionalBoundary& boundary);
00182   
00183   /**
00184   * The function adds a flag to the flag array.
00185   */
00186   void addFlag(Flag::FlagType type,
00187     bool ownTeamColorIsBlue,
00188     const ConditionalBoundary& boundary);
00189 
00190   /**
00191   * Calculates distance and angle for each flag.
00192   */
00193   void estimateOffsetForFlags
00194   (
00195    const Vector2<double>& cameraOffset
00196    );
00197   
00198   /**
00199   * The function adds a goal to the goal array.
00200   */
00201   void addGoal(colorClass color,
00202     const Vector2<double>& leftPost,
00203     const Vector2<double>& rightPost,
00204     const ConditionalBoundary& boundary);
00205 
00206   /**
00207   * The function adds a goal to the goal array.
00208   */
00209   void addGoal(colorClass color,
00210     bool ownTeamColorIsBlue,
00211     const ConditionalBoundary& boundary);
00212 
00213   /**
00214   * Calculates distance and angle for each goal.
00215   */
00216   void estimateOffsetForGoals
00217   (
00218    const Vector2<double>& cameraOffset
00219    );
00220 };
00221 
00222 /**
00223 * Streaming operator that reads a landmarks percept from a stream.
00224 * @param stream The stream from which is read.
00225 * @param landmarksPercept The landmarks percept to read.
00226 * @return The stream.
00227 */ 
00228 In& operator>>(In& stream,LandmarksPercept& landmarksPercept);
00229 
00230 /**
00231 * Streaming operator that writes a landmarks percept to a stream.
00232 * @param stream The stream to write on.
00233 * @param landmarksPercept The landmarks percept to write.
00234 * @return The stream.
00235 */ 
00236 Out& operator<<(Out& stream, const LandmarksPercept& landmarksPercept);
00237 
00238 
00239 #endif //__LandmarksPercept_h_
00240 
00241 /*
00242 * Change log :
00243 * 
00244 * $Log: LandmarksPercept.h,v $
00245 * Revision 1.3  2004/06/17 14:34:47  dassler
00246 * GT2004HeadControl updated
00247 * Now looks after propergated ball, followed up withe the communicated ball
00248 * GT2004HeadPathPlanner work now with time optimized moves
00249 * Middle Beacons removed of the Landmarkspercept
00250 *
00251 * Revision 1.2  2004/06/08 16:00:33  nistico
00252 * Final(?) improvement to the beaconSpecialist: 3 or 4 columns (depending on size)
00253 * are always scanned, and the results are merged based on validity, which is
00254 * calculated from the number of edges found and consistency checks
00255 *
00256 * Revision 1.1.1.1  2004/05/22 17:25:51  cvsadm
00257 * created new repository GT2004_WM
00258 *
00259 * Revision 1.3  2004/01/19 14:53:46  dueffert
00260 * all frameNumbers (and not only some of them) are unsigned long now
00261 *
00262 * Revision 1.2  2003/11/12 16:19:35  goehring
00263 * frameNumber added to percepts
00264 *
00265 * Revision 1.1  2003/10/07 10:09:36  cvsadm
00266 * Created GT2004 (M.J.)
00267 *
00268 * Revision 1.3  2003/09/26 15:27:27  juengel
00269 * Renamed DataTypes to representations.
00270 *
00271 * Revision 1.2  2003/09/26 11:37:23  juengel
00272 * - sorted tools
00273 * - clean-up in DataTypes
00274 *
00275 * Revision 1.1.1.1  2003/07/02 09:40:22  cvsadm
00276 * created new repository for the competitions in Padova from the 
00277 * tamara CVS (Tuesday 2:00 pm)
00278 *
00279 * removed unused solutions
00280 *
00281 * Revision 1.10  2003/05/04 17:31:52  roefer
00282 * Flag and goal specialists added to GT2003IP
00283 *
00284 * Revision 1.9  2003/03/22 16:53:10  juengel
00285 * Added estimateOffsetForGoals.
00286 *
00287 * Revision 1.8  2003/03/15 13:28:01  juengel
00288 * Added  void addGoal(colorClass color,  bool ownTeamColorIsBlue,  const ConditionalBoundary& boundary);
00289 *
00290 * Revision 1.7  2003/03/10 18:20:57  dueffert
00291 * warning removed
00292 *
00293 * Revision 1.6  2003/03/07 11:35:01  juengel
00294 * removed  smoothedDistance;
00295 *
00296 * added void addFlag(Flag::FlagType type, bool ownTeamColorIsBlue, const ConditionalBoundary& boundary);
00297 * added void LandmarksPercept::estimateOffsetForFlags()
00298 *
00299 * Revision 1.5  2002/11/07 13:32:35  roefer
00300 * isOnBorder repaired
00301 *
00302 * Revision 1.4  2002/10/14 13:14:24  dueffert
00303 * doxygen comments corrected
00304 *
00305 * Revision 1.3  2002/09/22 18:40:49  risler
00306 * added new math functions, removed GTMath library
00307 *
00308 * Revision 1.2  2002/09/17 23:55:20  loetzsch
00309 * - unraveled several datatypes
00310 * - changed the WATCH macro
00311 * - completed the process restructuring
00312 *
00313 * Revision 1.1  2002/09/10 15:26:40  cvsadm
00314 * Created new project GT2003 (M.L.)
00315 * - Cleaned up the /Src/DataTypes directory
00316 * - Removed Challenge Code
00317 * - Removed processing of incoming audio data
00318 * - Renamed AcousticMessage to SoundRequest
00319 *
00320 * Revision 1.3  2002/07/23 13:32:57  loetzsch
00321 * new streaming classes
00322 *
00323 * removed many #include statements
00324 *
00325 * Revision 1.2  2002/05/14 12:39:04  dueffert
00326 * corrected some documentation mistakes
00327 *
00328 * Revision 1.1.1.1  2002/05/10 12:40:13  cvsadm
00329 * Moved GT2002 Project from ute to tamara.
00330 *
00331 * Revision 1.14  2002/04/06 11:47:32  roefer
00332 * ConditionalBoundary corrected
00333 *
00334 * Revision 1.13  2002/04/02 14:25:11  roefer
00335 * smoothedDistance added
00336 *
00337 * Revision 1.12  2002/04/02 13:10:18  dueffert
00338 * big change: odometryData and cameraMatrix in image now, old logfiles may be obsolete
00339 *
00340 * Revision 1.11  2002/03/07 12:12:59  brunn
00341 * rumpelstilzchen
00342 *
00343 * Revision 1.10  2002/03/06 16:16:08  mkunz
00344 * More unused validities.
00345 *
00346 * Revision 1.9  2002/02/18 15:40:55  loetzsch
00347 * changed the offset vector in Flags and Goals to an angle and a destination
00348 *
00349 * Revision 1.8  2002/02/18 12:27:59  brunn
00350 * distance and angle removed ;-)
00351 *
00352 * Revision 1.7  2002/02/18 12:14:28  brunn
00353 * distance and angle added
00354 *
00355 * Revision 1.6  2002/02/18 12:05:17  loetzsch
00356 * Percept visualization continued
00357 *
00358 * Revision 1.5  2002/02/13 22:43:02  roefer
00359 * First working versions of DefaultLandmarksPerceptor and MonteCarloSelfLocator
00360 *
00361 * Revision 1.4  2002/02/12 09:45:17  roefer
00362 * Progress in DefaultLandmarksPerceptor and MonteCarloSelfLocator
00363 *
00364 * Revision 1.2  2002/02/06 10:30:11  AndySHB
00365 * MonteCarloLocalization First Draft
00366 *
00367 * Revision 1.3  2001/12/10 17:47:06  risler
00368 * change log added
00369 *
00370 */

Generated on Thu Sep 23 19:57:36 2004 for GT2004 by doxygen 1.3.6