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

Modules/BallLocator/GT2004ProcessModels/BaseModel.h

Go to the documentation of this file.
00001   /**
00002 * @file BaseModel.h
00003 * Contains base classes for implemting a KalmanBallLocator process model
00004 *
00005 * @author <a href="mailto:stefanuhrig@gmx.net">Stefan Uhrig</a>
00006 */
00007 //------------------------------------------------------------------------------
00008 #ifndef BASEMODEL_H_INCLUDED
00009 #define BASEMODEL_H_INCLUDED
00010 //------------------------------------------------------------------------------
00011 #include "Representations/Motion/OdometryData.h"
00012 #include "Tools/Streams/InOut.h"
00013 #include "Tools/Math/Vector_n.h"
00014 #include "Representations/Cognition/RobotPose.h"
00015 //------------------------------------------------------------------------------
00016 /**
00017 * @class KalmanBallState
00018 * Contains the supposed ball state
00019 */
00020 class KalmanBallState
00021 {
00022 public:
00023   KalmanBallState();
00024 
00025 public:
00026   double x;  ///< x-position in meter relative to robot
00027   double y;  ///< y-position in meter relative to robot
00028   double vx; ///< x-direction speed in meters per second
00029   double vy; ///< x-direction speed in meters per second
00030 };
00031 //------------------------------------------------------------------------------
00032 /**
00033 * @class KalmanUpdateResult
00034 * Contains the results of an update call of a KalmanBallLocator process model
00035 */
00036 class KalmanUpdateResult
00037 {
00038 public:
00039   KalmanUpdateResult();
00040 
00041 public:
00042   KalmanBallState state; ///< state of the ball
00043   double liklihood;      ///< liklihood (not probability!) of the model
00044 };
00045 //------------------------------------------------------------------------------
00046 /**
00047 * @class KalmanPredictResult
00048 * Contains the results of a predict call of a KalmanBallLocator process model
00049 */
00050 class KalmanPredictResult
00051 {
00052 public:
00053   KalmanPredictResult();
00054 
00055 public:
00056   KalmanBallState state; ///< predicted state of the ball
00057   double liklihood;      ///< predicted liklihood of the state
00058 };
00059 //------------------------------------------------------------------------------
00060 /**
00061 * @class KalmanProcessModelBase
00062 * Virtual base class defining the functions necessary to implement a
00063 * KalmanBallLocator process model.
00064 */
00065 class KalmanProcessModelBase
00066 {
00067 public:
00068   KalmanProcessModelBase();
00069   virtual ~KalmanProcessModelBase() {}
00070 
00071 public:
00072   /**
00073   * Returns the name of the process model
00074   * @return name of process model
00075   */
00076   virtual const char* getModelName() const = 0;
00077   /**
00078   * Returns the dimension of the state
00079   * @return dimension of the state
00080   */
00081   virtual int  getStateDim() const = 0;
00082   /**
00083   * Retrieves the internal kalman filter covariance matrix
00084   * @param pDest destination to store the covariance matrix to
00085   */
00086   virtual void getP(double* pDest) const = 0;
00087   /**
00088   * Retrieves the process error covariance matrix
00089   * @param pDest destination to store the covariance matrix to
00090   */
00091   virtual void getQ(double* pDest) const = 0;
00092   /** Sets the process error covariance matrix
00093   * @param pSource array containing the covariance matrix entries
00094   */
00095   virtual void setQ(const double* pSource) = 0;
00096   /**
00097   * Retrieves the measurement error covariance matrix
00098   * @param pDest destination to store the covariance matrix to
00099   */
00100   virtual void getR(double* pDest) const = 0;
00101   /** Sets the measurement error covariance matrix
00102   * @param pSource array containing the covariance matrix entries
00103   */
00104   virtual void setR(double* pSource) = 0;
00105   
00106   /** Resets the process model */
00107   virtual void reset() = 0;
00108   
00109   /**
00110   * Performs an update step of the process model
00111   * @param time time in seconds when the percepts were determined
00112   * @param x measured x-position of the ball in meters relative to the robot
00113   * @param y measured y-position of the ball in meters relative to the robot
00114   * @param pose the current robot pose, used for visualization
00115   * @param panningVelocity the head panning angular velocity, used to adjust the R covariance matrix
00116   * @return the update results of the process model
00117   */
00118   virtual KalmanUpdateResult update(double time, double x, double y, const RobotPose& pose, double panningVelocity) = 0;
00119   /**
00120   * Permorms a prediction of the ball state
00121   * @param time actual time in seconds
00122   * @return the predict results of the process model
00123   */
00124   virtual KalmanPredictResult predict(double time) = 0;
00125 
00126   /**
00127   * Function to adapt the state of the model when position and rotation of the robot changes.
00128   * @param lastOdometry last odometry of robot (original values in millimeters are used)
00129   * @param actualOdometry actual odometry of robot (original values in millimeters are used) 
00130   */
00131   virtual void adapt(const OdometryData& lastOdometry,
00132                      const OdometryData& actualOdometry) = 0;
00133 
00134   /**
00135   * Returns true, if the passed ball position is nonsense
00136   * (because it is far away from the field)
00137   * @return true, if passed position is nonsense
00138   */
00139   virtual bool isNonSensePos(double x, double y) const;
00140 
00141   /**
00142   * Returns true, if the model is to be used
00143   * @return true, if model is to be used
00144   */
00145   virtual bool useModel() const { return bUseModel; }
00146 
00147   /**
00148   * Writes data of the actual process model data to a stream (for debugging)
00149   * @param stream stream to write the process model data to
00150   * @return reference to the passed stream
00151   */
00152   virtual Out& toStream(Out& stream) const;
00153   /**
00154   * Reads settings for a process model from a stream (e.g. when covariance
00155   * matrices are changed by user.
00156   * @param stream stream to read settings from
00157   * @return reference to passed stream
00158   */
00159   virtual In& fromStream(In& stream);
00160 
00161 protected:
00162   /**
00163   * Outputs information about the process model that caused an exception
00164   * and information about the type of exception
00165   * @param pszLoc description of calculation step the exception occured in
00166   * @param m reference to exception
00167   */
00168   void OutputException(const char* pszLoc, MVException& m) const;
00169 
00170 protected:
00171   bool bUseModel; ///< true, if the model is to be used  
00172   static double pi;  ///< constant pi
00173   static double pi2; ///< constant 2*pi
00174   //! 1.2*length of field diagonal
00175   static double dFieldDiagonalLength;
00176 };
00177 //------------------------------------------------------------------------------
00178 #endif
00179 //------------------------------------------------------------------------------
00180 
00181 /*
00182  * Change log :
00183  * $Log: BaseModel.h,v $
00184  * Revision 1.1  2004/07/14 21:40:15  spranger
00185  * moved kalmanprocessmodel to gt2004processmodel
00186  *
00187  * Revision 1.4  2004/06/18 10:24:51  nistico
00188  * Kalman measurement covariance matrix now adjusted also based on
00189  * head panning angular velocity
00190  *
00191  * Revision 1.3  2004/06/16 17:57:00  nistico
00192  * Speed covariance submatrix dynamically calculated
00193  * based on distance from ball
00194  * More detailed identification of exception
00195  * Bug fixes
00196  *
00197  * Revision 1.2  2004/06/15 21:40:14  uhrig
00198  * Added possibility to disable and enable process models in the Kalman filter.
00199  *
00200  * Revision 1.1.1.1  2004/05/22 17:15:25  cvsadm
00201  * created new repository GT2004_WM
00202  *
00203  * Revision 1.3  2004/04/20 14:12:16  uhrig
00204  *  - odometry processing corrected
00205  *  - fixed position model disabled
00206  *  - covariance matrices tuned
00207  *
00208  * Revision 1.2  2004/03/15 12:28:52  risler
00209  * change log added
00210  *
00211  *
00212  */

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