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

Representations/Cognition/BallModel.cpp

Go to the documentation of this file.
00001 /**
00002 * @file BallModel.cpp
00003 *
00004 * Implementation of class BallModel.
00005 *
00006 * @author <A href=mailto:xiang@informatik.uni-bremen.de>Hong Xiang</A>
00007 * @author <A href=mailto:rlx@informatik.uni-bremen.de>Lang Lang</A>
00008 * @author <A href=mailto:roefer@tzi.de>Thomas Röfer</A>
00009 * @author <A href=mailto:jan@aiboteamhumboldt.com>Jan Hoffmann</A>
00010 */
00011 
00012 #include "BallModel.h"
00013 #include "Platform/SystemCall.h"
00014 
00015 static const int SLIDINGSIZE = 30;
00016 
00017 SeenBallPosition::SeenBallPosition()
00018 : timeWhenLastSeen(0),
00019 timeWhenFirstSeenConsecutively(SystemCall::getCurrentSystemTime()),
00020 timeUntilSeenConsecutively(SystemCall::getCurrentSystemTime()),
00021 angleError(0), distanceError(0), ballInFrontOfOpponentGoal(false)
00022 {
00023 }
00024 
00025 long SeenBallPosition::getConsecutivelySeenTime() const
00026 {
00027   long notSeenTime = (long)SystemCall::getTimeSince(timeUntilSeenConsecutively);
00028   if (notSeenTime<200)
00029   {
00030     return ((long)timeUntilSeenConsecutively - (long)timeWhenFirstSeenConsecutively);
00031   }
00032   else
00033   {
00034     return -notSeenTime;
00035   }
00036 }
00037 
00038 PropagatedBallPosition::PropagatedBallPosition()
00039 {
00040   positionWhenLastObserved.x = 0;
00041   positionWhenLastObserved.y = 0;
00042   observedSpeed.x = 0;
00043   observedSpeed.y = 0;
00044   timeOfObservation = 0;
00045   x = 0;
00046   y = 0;
00047   speed.x = 0;
00048   speed.y = 0;
00049 }
00050 
00051 
00052 Vector2<double> PropagatedBallPosition::getPropagatedPosition(long time) const
00053 {
00054   //double timeDiff = (time - timeOfObservation)/1000.0;
00055   return positionWhenLastObserved;// + observedSpeed * (1-exp(-timeDiff/2));
00056 }
00057 
00058 Vector2<double> PropagatedBallPosition::getPropagatedSpeed(long time) const
00059 {
00060   return Vector2<double>(0,0);
00061   
00062   //  double timeDiff = (time - timeOfObservation)/1000.0;
00063   //  return observedSpeed * exp(-timeDiff/2);
00064 }
00065 
00066 BallState::BallState()
00067 {
00068   reset();
00069 }
00070 
00071 void BallState::reset()
00072 {
00073   ballRollsByLeft       = false;
00074   ballRollsByRight      = false;
00075   ballRollsTowardsRobot = false;
00076   ballRollsFast         = false;
00077 
00078   projectedDistanceOnYAxis=1000;
00079   timeBallCrossesYAxis=100;
00080 }
00081 
00082 CommunicatedBallPosition::CommunicatedBallPosition()
00083 : timeWhenLastObserved(0)
00084 {
00085 }
00086 
00087 const Vector2<double>& BallModel::getKnownPosition(unsigned long timeAfterWhichCommunicatedBallsAreAccepted) const
00088 {
00089   if (SystemCall::getTimeSince(seen.timeWhenLastSeen) < timeAfterWhichCommunicatedBallsAreAccepted)
00090   {
00091     // use the seen position
00092     return seen;
00093   }
00094   else
00095   {
00096     if (SystemCall::getTimeSince(seen.timeWhenLastSeen)
00097       < SystemCall::getTimeSince(communicated.timeWhenLastObserved))
00098     {
00099       return seen;
00100     }
00101     else
00102     {
00103       return communicated;
00104     }
00105   }
00106 }
00107 
00108 unsigned long BallModel::getTimeSinceLastKnown(unsigned long timeAfterWhichCommunicatedBallsAreAccepted) const
00109 {
00110   if (SystemCall::getTimeSince(seen.timeWhenLastSeen) < timeAfterWhichCommunicatedBallsAreAccepted)
00111   {
00112     // use the seen position
00113     return SystemCall::getTimeSince(seen.timeWhenLastSeen);
00114   }
00115   else
00116   {
00117     return min(SystemCall::getTimeSince(seen.timeWhenLastSeen),
00118       SystemCall::getTimeSince(communicated.timeWhenLastObserved));
00119   }
00120 }
00121 
00122 
00123 BallModel::BallModel()
00124 : validity(1), motionValidity(1), numberOfImagesWithoutBallPercept(), numberOfImagesWithBallPercept(0)
00125 {
00126   ballWasSeen = false;
00127 }
00128 
00129 In& operator>>(In& stream,BallModel& ballPosition)
00130 {
00131   stream >> ballPosition.frameNumber;
00132   stream.read(&ballPosition,sizeof(BallModel));
00133   return stream;
00134 }
00135 
00136 Out& operator<<(Out& stream, const BallModel& ballPosition)
00137 {
00138   stream << ballPosition.frameNumber;
00139   stream.write(&ballPosition,sizeof(BallModel));
00140   return stream;
00141 }
00142 
00143 /*
00144 * Change log :
00145 *
00146 * $Log: BallModel.cpp,v $
00147 * Revision 1.4  2004/06/27 15:37:45  dassler
00148 * introduced ball speed to headcontrol
00149 *
00150 * Revision 1.3  2004/06/15 17:51:41  juengel
00151 * Added:
00152 * numberOfImagesWithoutBallPercept;
00153 * numberOfImagesWithBallPercept;
00154 *
00155 * Revision 1.2  2004/05/27 18:49:17  kerdels
00156 * added a small 5 frames sliding average for the relative ballspeed,
00157 * added new ballState Representation and adjusted the apropriate files
00158 *
00159 * Revision 1.1.1.1  2004/05/22 17:25:01  cvsadm
00160 * created new repository GT2004_WM
00161 *
00162 * Revision 1.5  2004/05/18 21:14:33  goehring
00163 * vector2 Propagated speed added
00164 *
00165 * Revision 1.4  2004/04/05 17:56:48  loetzsch
00166 * merged the local German Open CVS of the aibo team humboldt with the tamara CVS
00167 *
00168 * Revision 1.2  2004/04/02 10:02:10  jumped
00169 * added ballIFrontOfOpponentGoal member
00170 *
00171 * Revision 1.1.1.1  2004/03/31 11:16:53  loetzsch
00172 * created ATH repository for german open 2004
00173 *
00174 * Revision 1.3  2004/03/28 14:09:51  jhoffman
00175 * - added error member variables to ball model
00176 * - minor improvement in handling of updateRP in motiontesterdialog
00177 *
00178 * Revision 1.2  2004/02/29 13:37:15  dueffert
00179 * doxygen bugs fixed and beautified
00180 *
00181 * Revision 1.1  2004/02/03 12:56:41  spranger
00182 * renamed BallPosition class to BallModel (including the files)
00183 *
00184 * Revision 1.6  2004/02/02 19:10:30  kerdels
00185 * adjusted some options for the use with reflexes, created a simple version of turn-for-ball and modified some option ratings...
00186 *
00187 * Revision 1.5  2004/01/21 14:28:06  loetzsch
00188 * some initializations
00189 *
00190 * Revision 1.4  2003/11/15 17:58:10  juengel
00191 * fixed bug in streaming operator
00192 *
00193 * Revision 1.3  2003/11/14 19:02:25  goehring
00194 * frameNumber added
00195 *
00196 * Revision 1.2  2003/10/21 13:11:15  goehring
00197 * review
00198 *
00199 * Revision 1.1  2003/10/07 10:07:01  cvsadm
00200 * Created GT2004 (M.J.)
00201 *
00202 * Revision 1.2  2003/07/08 03:27:53  wachter
00203 * - added challengeBallBetweenFeetd
00204 * - removed propagetedBallDistance imput symbol
00205 * - fixed cvs ;)
00206 *
00207 * Revision 1.1.1.1  2003/07/02 09:40:22  cvsadm
00208 * created new repository for the competitions in Padova from the
00209 * tamara CVS (Tuesday 2:00 pm)
00210 *
00211 * removed unused solutions
00212 *
00213 * Revision 1.16  2003/06/22 15:25:02  dueffert
00214 * getConsecutivelySeenTime improved
00215 *
00216 * Revision 1.15  2003/06/17 20:01:25  dueffert
00217 * getConsecutivelySeenTime() added
00218 *
00219 * Revision 1.14  2003/06/17 19:26:46  thomas
00220 * modified: auskommentiert von PropagatedBallPosition::getPropagatedPosition
00221 *
00222 * Revision 1.13  2003/06/17 18:26:54  thomas
00223 * modified: auskommentiert von PropagatedBallPosition::getPropagatedSpeed und range abgefangen in DefaultObstaclesLocator::addObstaclePoint
00224 *
00225 * Revision 1.12  2003/06/17 11:28:36  jhoffman
00226 * bug fixed (variable not initialized)
00227 *
00228 * Revision 1.11  2003/06/15 16:43:56  jhoffman
00229 * propagated position is calculated by a function rather then in iteratively in cognition
00230 *
00231 * Revision 1.10  2003/06/15 14:26:44  jhoffman
00232 * + moved "relative2FieldCoord" to Geometry
00233 * + added member function to ballposition to calculate the propagated position and speed for a given time
00234 * + propagated speed and time calculation using exponential decay instead of using an iterative calculation
00235 * + in motion you can now use propageted ball pos at 125 Hz rather then the framerate determined by cognition
00236 *
00237 * Revision 1.9  2003/05/02 14:06:36  wachter
00238 * Moved distanceInMayDirection and distanceInMinDirection from BallPosition to CommunicatedBallPosition
00239 *
00240 * Revision 1.8  2003/05/01 18:10:03  loetzsch
00241 * renamed CommunicatedBallPosition::timeWhenLastReceived to CommunicatedBallPosition::timeWhenLastObserved
00242 *
00243 * Revision 1.7  2003/05/01 17:09:05  loetzsch
00244 * Redesign of ball modeling:
00245 * - Modularized class BallPosition
00246 * - splitted up module "BallLocator" into "BallLocator" for modeling of percepts
00247 *   and "TeamBallLocator" for modelling communicated positions
00248 * - Removed solution JumpingBallLocator
00249 * - Splitted Solution DefaultBallLocator into DefaultBallLocator and DefaultTeamBallLocator
00250 * - Renamed SensorFusionBallLocator to GaussBellTeamBallLocator
00251 *
00252 * Revision 1.6  2003/04/14 16:00:42  loetzsch
00253 * ATH after GermanOpen CVS merge:
00254 * added timeUntilSeenConsecutively
00255 *
00256 * Revision 1.2  2003/04/11 21:47:15  Jan Hoffmann
00257 * timeWhenFirstSeenConsecutively and timeUntilSeenConsecutively are initialized with CurrentSystemTime.
00258 *
00259 * Revision 1.1.1.1  2003/04/09 14:22:16  loetzsch
00260 * started Aibo Team Humboldt's GermanOpen CVS
00261 *
00262 * Revision 1.5  2003/04/08 08:50:03  schmidt
00263 * Initializing validity with 0
00264 *
00265 * Revision 1.4  2003/02/14 14:34:02  wachter
00266 * Added SensorFusionBallLocator
00267 *
00268 * Revision 1.3  2003/01/30 13:16:48  loetzsch
00269 * Redesign of class BallPosition
00270 *
00271 * Revision 1.2  2002/09/22 18:40:50  risler
00272 * added new math functions, removed GTMath library
00273 *
00274 * Revision 1.1  2002/09/10 15:26:39  cvsadm
00275 * Created new project GT2003 (M.L.)
00276 * - Cleaned up the /Src/DataTypes directory
00277 * - Removed Challenge Code
00278 * - Removed processing of incoming audio data
00279 * - Renamed AcousticMessage to SoundRequest
00280 *
00281 * Revision 1.1.1.1  2002/05/10 12:40:13  cvsadm
00282 * Moved GT2002 Project from ute to tamara.
00283 *
00284 * Revision 1.12  2002/04/25 20:29:57  roefer
00285 * New BallPercept and BallPosition, GTMath errors in SimGT2002 fixed
00286 *
00287 * Revision 1.11  2002/04/06 02:28:45  loetzsch
00288 * added time when ball was seen last
00289 *
00290 * Revision 1.10  2002/02/11 11:19:57  roefer
00291 * no message
00292 *
00293 * Revision 1.9  2002/02/11 11:13:06  roefer
00294 * BallPerceptor and BallLocator inserted
00295 *
00296 * Revision 1.8  2002/02/05 03:30:52  loetzsch
00297 * replaced direct member access by
00298 * inline const VALUE& get...() const   and
00299 * inline void set...(const Value&) methods.
00300 *
00301 * Revision 1.7  2002/01/27 22:14:54  roefer
00302 * BallPosition is now a pair of two vectors
00303 *
00304 * Revision 1.6  2002/01/25 15:40:13  roefer
00305 * The Oracle
00306 *
00307 * Revision 1.5  2002/01/22 00:06:55  loetzsch
00308 * In den Get...() Funktionen wurden die Parameter nicht als Referenz übergeben,
00309 * geändert
00310 *
00311 * Revision 1.4  2002/01/11 23:50:24  xiang
00312 * BallPosition von Hong & Lang
00313 *
00314 * Revision 1.3  2001/12/10 17:47:05  risler
00315 * change log added
00316 *
00317 */

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