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

Modules/BallLocator/GT2004BallLocator.h

Go to the documentation of this file.
00001 /**
00002 * @file GT2004BallLocator.h
00003 * Contains a BallLocator implementation using GT2004 filtering
00004 *
00005 * @author <a href="mailto:stefanuhrig@gmx.net">Stefan Uhrig</a>
00006 */
00007 //------------------------------------------------------------------------------
00008 #ifndef KALMANBALLLOCATOR_H_INCLUDED
00009 #define KALMANBALLLOCATOR_H_INCLUDED
00010 //------------------------------------------------------------------------------
00011 #include "BallLocator.h"
00012 #include "Tools/Debugging/GenericDebugData.h"
00013 #include "GT2004ProcessModels/BaseModel.h"
00014 #include <vector>
00015 #include "Tools/Actorics/RobotDimensions.h"
00016 #include "Tools/RobotConfiguration.h"
00017 #include "Tools/Math/Common.h"
00018 //------------------------------------------------------------------------------
00019 /**
00020 * @class GT2004BallLocator
00021 * A BallLocator using GT2004 filtering. This class is the main class managing
00022 * different GT2004 process models
00023 */
00024 class GT2004BallLocator : public BallLocator
00025 {
00026 public:
00027   GT2004BallLocator(BallLocatorInterfaces& interfaces);
00028   virtual ~GT2004BallLocator();
00029 
00030 public:
00031   /**
00032   * Executes the GT2004BallLocator module
00033   */
00034   virtual void execute();
00035   /**
00036   * Handles idGT2004Data debug messages
00037   * @param message The message
00038   * @return true if message was handled
00039   */
00040   virtual bool handleMessage(InMessage& message);
00041 
00042 private:
00043 
00044   /** Counts the number of percepts that contained a ball or no ball */
00045   void determineNumberOfImagesWith_WithoutBall();
00046 
00047   /**
00048   * Called if ball was seen. Performs update step.
00049   */
00050   void handleSeenBall();
00051   /**
00052   * Called if ball was not seen. Performs predict step.
00053   */
00054   void handleUnseenBall();
00055 
00056   /** Compensates the body movements */
00057   void compensateOdometry();
00058 
00059   /**
00060   * Checks if the ball rolls by right or left of the robot
00061   */
00062   void setBallState();
00063   /**
00064   * Checks if the ball rolls by right or left of the robot, v2
00065   */
00066   void setBallStateV2();
00067   /**
00068   * setUnknownResult is called if an exception occurs.
00069   * However, this should not happen, but if, this prevents the robot from crashing.
00070   */
00071   void setUnknownResult();
00072   /**
00073   * True if passed position is nonsense.
00074   * @param x x-position in millimeter
00075   * @param y y-position in millimeter
00076   * @return true if position is nonsense
00077   */
00078   bool isNonSensePos(double x, double y);
00079   /**
00080   * Adds a process model to the list of managed process models.
00081   * @param pModel Pointer to process model derived from GT2004ProcessModelBase
00082   */
00083   void addModel(KalmanProcessModelBase* pModel);
00084   /**
00085   * Frees the managed process models
00086   */
00087   void destroyModels();
00088   /**
00089   * Sends the process model states as debug messages
00090   */
00091   void sendProcessModelStates();
00092   /**
00093   * Draws the global ball positions and data model ball positions on the field
00094   */
00095   void drawBallPosition();
00096 
00097 private:
00098   unsigned long int lastFrameNumber;
00099   bool ballWasSeenInLastImage;
00100 
00101   //! Vector containing all instantiated process models
00102   std::vector<KalmanProcessModelBase*> kalmanModels;
00103   //! Vector containing the result of calls to the update function of the
00104   //! process models
00105   std::vector<KalmanUpdateResult> kalmanUpdateResults;
00106   //! Vector containing the result of calls to the predict function of the
00107   //! process models
00108   std::vector<KalmanPredictResult> kalmanPredictResults;
00109 
00110   double x_rel;  ///< x-position of ball relative to robot
00111   double y_rel;  ///< y-position relative to robot
00112   double x_abs;  ///< x-position of ball on field
00113   double y_abs;  ///< y-position of ball on field
00114   double vx_rel; ///< speed of ball in x-direction relative to robot
00115   double vy_rel; ///< speed of ball in y-direction relative to robot
00116 
00117   double vx_abs; ///< speed of ball in x-direction on field
00118   double vy_abs; ///< speed of ball in y-direction on field
00119   bool ballWasSeen; ///< true if ball was seen
00120   double last_seen_x_rel; ///< x-position of last seen ball relative to robot
00121   double last_seen_y_rel; ///< y-position of last seen ball relative to robot
00122 
00123   //! Last odometry data of robot
00124   OdometryData lastOdometry;
00125 
00126   //! If true, process model states are sent as debug messages
00127   bool bSendProcessModelStates;
00128 
00129   //! 1.2*length of field diagonal
00130   static double dFieldDiagonalLength;
00131 
00132   // some data for ball state information 
00133   // used in setBallStateV2();
00134   bool freshDefend;
00135   Vector2<double> ballSensedPos;
00136   Vector2<double> ballSensedRelPos;
00137   unsigned long ballSensedTime;
00138 
00139   CameraMatrix prevCameraMatrix;
00140 
00141   // percept-part
00142   Vector2<double> lastBallSeen;
00143   
00144   Pose2D lastRobotOdometry; 
00145   
00146   Vector2<double> relative2FieldCoord(RobotPose rp, double x, double y);
00147 };
00148 //------------------------------------------------------------------------------
00149 #endif
00150 //------------------------------------------------------------------------------
00151 
00152 /*
00153  * Change log :
00154  * $Log: GT2004BallLocator.h,v $
00155  * Revision 1.1  2004/07/14 20:56:34  spranger
00156  * moved KalmanCombo (incl percept stuff) to gt2004balllocator
00157  *
00158  * Revision 1.9  2004/06/21 08:15:57  nistico
00159  * The dot product of normalized vectors (versors) is guaranteed to be within [-1, 1] ;
00160  * the angle was not normalized, however. (-pi, pi)
00161  *
00162  * Revision 1.8  2004/06/18 10:24:51  nistico
00163  * Kalman measurement covariance matrix now adjusted also based on
00164  * head panning angular velocity
00165  *
00166  * Revision 1.7  2004/06/15 21:40:14  uhrig
00167  * Added possibility to disable and enable process models in the Kalman filter.
00168  *
00169  * Revision 1.6  2004/06/15 17:48:32  juengel
00170  * Added method determineNumberOfImagesWith_WithoutBall().
00171  *
00172  * Revision 1.5  2004/06/14 10:44:29  risler
00173  * removed speed averaging
00174  * reactivated old working ball state
00175  *
00176  * Revision 1.4  2004/05/27 18:49:17  kerdels
00177  * added a small 5 frames sliding average for the relative ballspeed,
00178  * added new ballState Representation and adjusted the apropriate files
00179  *
00180  * Revision 1.3  2004/05/26 10:08:03  loetzsch
00181  * correct use of odometry
00182  *
00183  * Revision 1.1.1.1  2004/05/22 17:15:19  cvsadm
00184  * created new repository GT2004_WM
00185  *
00186  * Revision 1.5  2004/04/20 14:12:16  uhrig
00187  *  - odometry processing corrected
00188  *  - fixed position model disabled
00189  *  - covariance matrices tuned
00190  *
00191  * Revision 1.4  2004/04/07 12:28:56  risler
00192  * ddd checkin after go04 - first part
00193  *
00194  * Revision 1.3  2004/03/31 00:09:46  risler
00195  * set last seen position when ball is not seen
00196  *
00197  * Revision 1.2  2004/03/30 15:48:06  risler
00198  * various bugfixes from stefan
00199  *
00200  * Revision 1.1.1.1  2004/03/29 08:28:51  Administrator
00201  * initial transfer from tamara
00202  *
00203  * Revision 1.3  2004/03/15 12:28:52  risler
00204  * change log added
00205  *
00206  *
00207  */

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