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

Representations/Cognition/BallModel.h

Go to the documentation of this file.
00001 /**
00002 * @file BallModel.h
00003 *
00004 * Declaration of class BallPosition
00005 *
00006 * @author Martin Lötzsch
00007 * @author <A href=mailto:roefer@tzi.de>Thomas Röfer</A>
00008 */
00009 
00010 #ifndef __BallModel_h_
00011 #define __BallModel_h_
00012 
00013 #include "Tools/Streams/InOut.h"
00014 #include "Tools/Math/Pose2D.h"
00015 #include "Tools/Math/Geometry.h"
00016 
00017 /**
00018 * @class SeenBallPosition
00019 *
00020 * The knowledge about the ball that was obtained by own observations.
00021 */
00022 class SeenBallPosition : public Vector2<double>
00023 {
00024 public:
00025   /** Constructor */
00026   SeenBallPosition();
00027   
00028   /** The speed of the ball estimated from own observations. */
00029   Vector2<double> speed;
00030   
00031   /**
00032   * The time when the ball was last seen by the own camera.
00033   * "position" and speed were set at that point in time.
00034   */
00035   unsigned long timeWhenLastSeen;
00036   
00037   /**
00038   * The time when the ball was last seen consecutively, i.e.
00039   * it has been seen "a lot" but not necessarily in all frames;
00040   * gaps of n frames or more are okay
00041   */
00042   unsigned long timeWhenFirstSeenConsecutively;
00043   
00044   /**
00045   * The time until the ball has been seen consecutively, i.e.
00046   * it has been seen "a lot" but not necessarily in all frames
00047   * until the time stored here;
00048   */
00049   unsigned long timeUntilSeenConsecutively;
00050   
00051   bool ballInFrontOfOpponentGoal;
00052 
00053   /**
00054   * If this is positive, we see the ball for that time consecutively.
00055   * If this is negative, we have not seen the ball consecutively for -that time.
00056   */
00057   long getConsecutivelySeenTime() const;
00058 
00059   double distanceError;
00060 
00061   double angleError;
00062 
00063   /** Assignment operator for Vector2<double>
00064    * @param other The Vector2<double> to be assigned to (x,y)
00065    * @return A reference to this object after the assignment.
00066    */
00067   SeenBallPosition& operator=(const Vector2<double>& other){
00068     x=other.x;
00069     y=other.y;
00070     return *this;
00071   }
00072   
00073 };
00074 
00075 /**
00076 * The position of the ball estimated from own observations and the observed
00077 * ball speed; it is propagated even if the ball is not seen.
00078 */
00079 class PropagatedBallPosition : public Vector2<double>
00080 {
00081 public:
00082   /** Constructor */
00083   PropagatedBallPosition();
00084 
00085   /** The speed of the ball estimated from propagations and last speed. */
00086   Vector2<double> speed;
00087 
00088   Vector2<double> getPropagatedPosition(long time) const;
00089   Vector2<double> getPropagatedSpeed(long time) const;
00090   
00091   long timeOfObservation;
00092   Vector2<double> positionWhenLastObserved;
00093   Vector2<double> observedSpeed;
00094   
00095 private:
00096 };
00097 
00098 /** The position of the ball estimated from own observations and from
00099 * observation of other players. */
00100 class CommunicatedBallPosition : public Vector2<double>
00101 {
00102 public:
00103   /** Constructor */
00104   CommunicatedBallPosition();
00105   
00106   /** The time when an observation made by an other robot. */
00107   unsigned long timeWhenLastObserved;
00108   
00109   /** used for the Ruhrpott-Hellhounds-collective-scoccer behavior to access
00110   the gaussian distribution of the GaussBellTeamBallLocator
00111   May be removed in the futute. */
00112   double distanceInMajDirection;
00113   double distanceInMinDirection;
00114   double orientationAngleOfGaussBell;
00115   
00116 };
00117 
00118 
00119 /**
00120 * @class BallState
00121 *
00122 * Qualitative proposition for the ball.
00123 */
00124 class BallState
00125 {
00126 public:
00127   /** Constructor. Sets all variables to false */
00128   BallState();
00129 
00130   /** If true, the ball rolls by left in a short distance */
00131   bool ballRollsByLeft;
00132   
00133   /** If true, the ball rolls by right in a short distance */
00134   bool ballRollsByRight;
00135   
00136   /** If true, the ball rolls towards the robot */
00137   bool ballRollsTowardsRobot;
00138   
00139   /** If true, the ball has a high speed in any direction */
00140   bool ballRollsFast;
00141 
00142   /** this is the projected distance of the ball on the Y axis of the robot (in mm)*/
00143   double projectedDistanceOnYAxis;
00144 
00145   /** time in ms which the ball needs to cross the robots y axis */
00146   long timeBallCrossesYAxis;
00147 
00148   /** resets all values to false*/
00149   void reset();
00150 };
00151 
00152 /**
00153 * @class BallModel
00154 *
00155 * Contains the modeled knowledge about the ball.
00156 */
00157 class BallModel
00158 {
00159 public:
00160   /** Constructor. */
00161   BallModel();
00162   
00163   unsigned long frameNumber;
00164   void setFrameNumber(unsigned long frameNumber) {this->frameNumber = frameNumber;}
00165   
00166   int numberOfImagesWithoutBallPercept;
00167   int numberOfImagesWithBallPercept;
00168 
00169   bool ballWasSeen;
00170 
00171   /** The position of the ball estimated from own observations */
00172   SeenBallPosition seen;
00173   
00174   /**
00175   * The position of the ball estimated from own observations and the observed
00176   * ball speed; it is propagated even if the ball is not seen
00177   */
00178   PropagatedBallPosition propagated;
00179   
00180   /**
00181   * The position of the ball estimated from own observations and from
00182   * observation of other players.
00183   */
00184   CommunicatedBallPosition communicated;
00185 
00186   /** Qualitative propositions of the ball */
00187   BallState ballState;
00188 
00189   /**
00190   * Returns a "known" ball position. If the ball was seen, the seen ball position
00191   * is used. If the ball was not seen for a timeAfterThatCommunicatedBallsAreAccepted,
00192   * the communicatedBallPosition is returned, if there was received a ball position.
00193   * @param timeAfterWhichCommunicatedBallsAreAccepted The time after that the communicated position is returned
00194   */
00195   const Vector2<double>& getKnownPosition(unsigned long timeAfterWhichCommunicatedBallsAreAccepted) const;
00196   
00197   /**
00198   * Returns the time since the ball was seen or communicated.
00199   * @param timeAfterWhichCommunicatedBallsAreAccepted as in getKnownPosition()
00200   */
00201   unsigned long getTimeSinceLastKnown(unsigned long timeAfterWhichCommunicatedBallsAreAccepted) const;
00202   
00203   /** The time for the behaviorControl after that communicated ball positions are accepted */
00204   enum {behaviorControlTimeAfterWhichCommunicatedBallsAreAccepted=6000};
00205   
00206   // ????
00207   double validity;
00208   double motionValidity;
00209   
00210 };
00211 
00212 /**
00213 * Streaming operator that reads a BallModel from a stream.
00214 * @param stream The stream from which is read.
00215 * @param ballPosition The BallModel object.
00216 * @return The stream.
00217 */
00218 In& operator>>(In& stream,BallModel& ballPosition);
00219 
00220 /**
00221 * Streaming operator that writes a BallModel to a stream.
00222 * @param stream The stream to write on.
00223 * @param ballPosition The BallModel object.
00224 * @return The stream.
00225 */
00226 Out& operator<<(Out& stream, const BallModel& ballPosition);
00227 
00228 
00229 #endif //__BallModel_h_
00230 
00231 /*
00232 * Change log :
00233 *
00234 * $Log: BallModel.h,v $
00235 * Revision 1.4  2004/06/23 11:37:43  dassler
00236 * New Ballsymbols introduced
00237 * ball.projected-distance-on-y-axis" description="Projected Distance of the ball to the y axis of the robot
00238 * ball.time-until-ball-crosses-y-axis" description="Time until the ball crosses the y axis of the robot
00239 *
00240 * Revision 1.3  2004/06/15 17:51:41  juengel
00241 * Added:
00242 * numberOfImagesWithoutBallPercept;
00243 * numberOfImagesWithBallPercept;
00244 *
00245 * Revision 1.2  2004/05/27 18:49:17  kerdels
00246 * added a small 5 frames sliding average for the relative ballspeed,
00247 * added new ballState Representation and adjusted the apropriate files
00248 *
00249 * Revision 1.1.1.1  2004/05/22 17:25:02  cvsadm
00250 * created new repository GT2004_WM
00251 *
00252 * Revision 1.11  2004/05/18 21:14:33  goehring
00253 * vector2 Propagated speed added
00254 *
00255 * Revision 1.10  2004/05/04 10:48:59  loetzsch
00256 * replaced all enums
00257 * xxxBehaviorControlTimeAfterWhichCommunicatedBallsAreAccepted
00258 * by
00259 * behaviorControlTimeAfterWhichCommunicatedBallsAreAccepted
00260 * (this mechanism was neither fully implemented nor used)
00261 *
00262 * Revision 1.9  2004/05/03 15:32:25  uhrig
00263 * Added additional ball state and disabled sending of Kalman filter process model states.
00264 *
00265 * Revision 1.8  2004/05/02 13:33:21  juengel
00266 * Added GT2004BehaviorControl.
00267 * (gt2004BehaviorControlTimeAfterWhichCommunicatedBallsAreAccepted)
00268 *
00269 * Revision 1.7  2004/04/05 17:56:49  loetzsch
00270 * merged the local German Open CVS of the aibo team humboldt with the tamara CVS
00271 *
00272 * Revision 1.3  2004/04/02 10:01:58  jumped
00273 * added ballIFrontOfOpponentGoal member
00274 *
00275 *
00276 * Revision 1.6  2004/03/28 17:54:11  juengel
00277 * Added ballState "ballRollsFast".
00278 *
00279 * Revision 1.5  2004/03/25 13:33:50  schmitt
00280 * Added distance- and angleError again
00281 *
00282 * Revision 1.4  2004/03/21 12:44:48  juengel
00283 * Added "wait-for-feedback" to ballState
00284 *
00285 * Revision 1.3  2004/02/29 13:37:15  dueffert
00286 * doxygen bugs fixed and beautified
00287 *
00288 * Revision 1.2  2004/02/05 14:21:24  spranger
00289 * added type definition fpr ball-state enum
00290 *
00291 * Revision 1.1  2004/02/03 12:56:41  spranger
00292 * renamed BallPosition class to BallModel (including the files)
00293 *
00294 * Revision 1.9  2004/01/22 20:08:00  schumann
00295 * added validity for movement
00296 * added elemination of jumping ball
00297 * improved calculation of ball movement
00298 *
00299 * Revision 1.8  2004/01/19 14:55:23  dueffert
00300 * all frameNumbers (and not only some of them) are unsigned long now
00301 *
00302 * Revision 1.7  2004/01/13 18:07:41  spranger
00303 * changed name from ballDirection to ballState
00304 *
00305 * Revision 1.6  2004/01/13 17:55:01  spranger
00306 * added ballDirectionn(shortRange)
00307 *
00308 * Revision 1.5  2003/11/14 19:02:25  goehring
00309 * frameNumber added
00310 *
00311 * Revision 1.4  2003/10/26 22:49:41  loetzsch
00312 * created ATH2004BehaviorControl from GT2003BehaviorControl
00313 *  - strongly simplified option graph
00314 *  - moved some symbols from GT2003 to CommonXabsl2Symbols
00315 *  - moved some basic behaviors from GT2003 to CommonXabsl2BasicBehaviors
00316 *
00317 * cloned ATH2004 three times (BB2004, DDD2004, MSH2004)
00318 *
00319 * Revision 1.3  2003/10/22 13:06:21  goehring
00320 * = Operator for Vector<double> added
00321 *
00322 * Revision 1.2  2003/10/21 13:11:15  goehring
00323 * review
00324 *
00325 * Revision 1.1  2003/10/07 10:07:01  cvsadm
00326 * Created GT2004 (M.J.)
00327 *
00328 * Revision 1.4  2003/09/25 11:23:52  juengel
00329 * Removed BlobCollection.
00330 *
00331 * Revision 1.3  2003/07/08 03:27:53  wachter
00332 * - added challengeBallBetweenFeetd
00333 * - removed propagetedBallDistance imput symbol
00334 * - fixed cvs ;)
00335 *
00336 * Revision 1.2  2003/07/04 16:40:34  loetzsch
00337 * gt2003BehaviorControlTimeAfterWhichCommunicatedBallsAreAccepted
00338 *
00339 * Revision 1.1.1.1  2003/07/02 09:40:22  cvsadm
00340 * created new repository for the competitions in Padova from the
00341 * tamara CVS (Tuesday 2:00 pm)
00342 *
00343 * removed unused solutions
00344 *
00345 * Revision 1.18  2003/06/17 20:01:25  dueffert
00346 * getConsecutivelySeenTime() added
00347 *
00348 * Revision 1.17  2003/06/15 16:43:56  jhoffman
00349 * propagated position is calculated by a function rather then in iteratively in cognition
00350 *
00351 * Revision 1.16  2003/06/15 14:26:44  jhoffman
00352 * + moved "relative2FieldCoord" to Geometry
00353 * + added member function to ballposition to calculate the propagated position and speed for a given time
00354 * + propagated speed and time calculation using exponential decay instead of using an iterative calculation
00355 * + in motion you can now use propageted ball pos at 125 Hz rather then the framerate determined by cognition
00356 *
00357 * Revision 1.15  2003/05/19 15:35:20  wachter
00358 * Added some comments
00359 *
00360 * Revision 1.14  2003/05/09 15:28:51  loetzsch
00361 * added time-after-which-communicated-ball-are-accepted
00362 *
00363 * Revision 1.13  2003/05/02 14:06:36  wachter
00364 * Moved distanceInMayDirection and distanceInMinDirection from BallPosition to CommunicatedBallPosition
00365 *
00366 * Revision 1.12  2003/05/01 19:32:04  roefer
00367 * Ball position assignment issues solved
00368 *
00369 * Revision 1.11  2003/05/01 18:10:03  loetzsch
00370 * renamed CommunicatedBallPosition::timeWhenLastReceived to CommunicatedBallPosition::timeWhenLastObserved
00371 *
00372 * Revision 1.10  2003/05/01 17:09:06  loetzsch
00373 * Redesign of ball modeling:
00374 * - Modularized class BallPosition
00375 * - splitted up module "BallLocator" into "BallLocator" for modeling of percepts
00376 *   and "TeamBallLocator" for modelling communicated positions
00377 * - Removed solution JumpingBallLocator
00378 * - Splitted Solution DefaultBallLocator into DefaultBallLocator and DefaultTeamBallLocator
00379 * - Renamed SensorFusionBallLocator to GaussBellTeamBallLocator
00380 *
00381 * Revision 1.9  2003/04/14 16:00:42  loetzsch
00382 * ATH after GermanOpen CVS merge:
00383 * added timeUntilSeenConsecutively
00384 *
00385 * Revision 1.2  2003/04/11 21:45:35  Jan Hoffmann
00386 * Added timeUntilSeenConsecutively
00387 *
00388 * Revision 1.1.1.1  2003/04/09 14:22:16  loetzsch
00389 * started Aibo Team Humboldt's GermanOpen CVS
00390 *
00391 * Revision 1.8  2003/04/03 21:07:32  jhoffman
00392 * added "consecutive time ball seen"
00393 *
00394 * Revision 1.7  2003/03/31 13:22:13  jhoffman
00395 * added propagated speed
00396 *
00397 * Revision 1.6  2003/02/14 14:34:02  wachter
00398 * Added SensorFusionBallLocator
00399 *
00400 * Revision 1.5  2003/01/30 13:16:48  loetzsch
00401 * Redesign of class BallPosition
00402 *
00403 * Revision 1.4  2002/11/26 12:25:48  dueffert
00404 * doxygen docu corrected
00405 *
00406 * Revision 1.3  2002/11/21 16:08:39  dueffert
00407 * doxygen comments corrected
00408 *
00409 * Revision 1.2  2002/09/22 18:40:50  risler
00410 * added new math functions, removed GTMath library
00411 *
00412 * Revision 1.1  2002/09/10 15:26:39  cvsadm
00413 * Created new project GT2003 (M.L.)
00414 * - Cleaned up the /Src/DataTypes directory
00415 * - Removed Challenge Code
00416 * - Removed processing of incoming audio data
00417 * - Renamed AcousticMessage to SoundRequest
00418 *
00419 * Revision 1.2  2002/07/23 13:32:56  loetzsch
00420 * new streaming classes
00421 *
00422 * removed many #include statements
00423 *
00424 * Revision 1.1.1.1  2002/05/10 12:40:13  cvsadm
00425 * Moved GT2002 Project from ute to tamara.
00426 *
00427 * Revision 1.12  2002/04/25 20:29:57  roefer
00428 * New BallPercept and BallPosition, GTMath errors in SimGT2002 fixed
00429 *
00430 * Revision 1.11  2002/04/06 02:28:45  loetzsch
00431 * added time when ball was seen last
00432 *
00433 * Revision 1.10  2002/02/11 11:19:57  roefer
00434 * no message
00435 *
00436 * Revision 1.9  2002/02/11 11:13:06  roefer
00437 * BallPerceptor and BallLocator inserted
00438 *
00439 * Revision 1.8  2002/02/05 03:30:52  loetzsch
00440 * replaced direct member access by
00441 * inline const VALUE& get...() const   and
00442 * inline void set...(const Value&) methods.
00443 *
00444 * Revision 1.7  2002/01/27 22:14:54  roefer
00445 * BallPosition is now a pair of two vectors
00446 *
00447 * Revision 1.6  2002/01/25 15:40:13  roefer
00448 * The Oracle
00449 *
00450 * Revision 1.5  2002/01/22 00:06:55  loetzsch
00451 * In den Get...() Funktionen wurden die Parameter nicht als Referenz übergeben,
00452 * geändert
00453 *
00454 * Revision 1.4  2002/01/11 23:50:09  xiang
00455 * BallPosition von Hong & Lang
00456 *
00457 * Revision 1.3  2001/12/10 17:47:05  risler
00458 * change log added
00459 *
00460 */

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