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

Representations/Cognition/PlayerPoseCollection.h

Go to the documentation of this file.
00001 /**
00002  * @file PlayerPoseCollection.h
00003  * 
00004  * Declaration of class PlayerPoseCollection
00005  * @author <A href=mailto:kspiess@informatik.uni-bremen.de>Kai Spiess</A>
00006  */ 
00007 
00008 #ifndef __PlayerPoseCollection_h_
00009 #define __PlayerPoseCollection_h_
00010 
00011 #include "Representations/Cognition/RobotPose.h"
00012 #include "Tools/Streams/InOut.h"
00013 #include "Tools/Math/Pose2D.h"
00014 #include "Tools/Player.h"
00015 #include "Platform/SystemCall.h"
00016 
00017 
00018 /**
00019  *  This class contains the informations about the PlayerPose 
00020  *  of a located robot. This is not for informations about the own robot.
00021  */
00022 class PlayerPose
00023 {
00024 public:
00025   /** Constructor */
00026   PlayerPose(){speed = 0;playerNumber=Player::undefinedPlayerNumber;sigmaMin=-1;sigmaMaj=-1;timeStamp=0;}
00027   /** Copy-Constructor */
00028   PlayerPose(const PlayerPose& other){*this = other;};
00029   /** Destructor */
00030   ~PlayerPose(){};
00031 
00032   unsigned long frameNumber; /**< The frame number of the image that was used to create the percept. */
00033   
00034   void setFrameNumber(unsigned long frameNumber) {this->frameNumber = frameNumber;}
00035 
00036   /** sets the pose */
00037   void setPose(const Pose2D& p) {pose = p;}
00038 
00039   /** sets the pose */
00040   void setRobotPose(const RobotPose& p) 
00041   {
00042     pose = p.getPose();
00043     validity = p.getValidity();
00044     timeStamp = p.timestamp;
00045   }
00046 
00047   /** sets the pose */
00048   void setPose(const double& x, const double& y, const double& rotation)
00049   { pose.translation.x = x; pose.translation.y = y; pose.rotation = rotation; }
00050 
00051   /** returns the pose */
00052   const Pose2D& getPose() const {return pose;}
00053 
00054   /** sets the speed */
00055   void setSpeed(const double& _speed) {
00056     speed = _speed;
00057   }
00058 
00059   /** returns the speed */
00060   const double& getSpeed() const {return speed;}
00061 
00062   /** sets the validity */
00063   void setValidity(const double& v) {validity = v;}
00064 
00065   /** sets the player number */
00066   void setPlayerNumber(const Player::playerNumber p) {playerNumber = p;}
00067 
00068   /** sets the timestamp */
00069   void setTimeStamp(const long& t) {timeStamp = t;}
00070 
00071   /** returns the validity */
00072   const double& getValidity() const {return validity;}
00073 
00074   /** returns the playerRole */
00075   const Player::playerNumber& getPlayerNumber() const {return playerNumber;}
00076 
00077   /** return the timeStamp */
00078   const long& getTimeStamp() const {return timeStamp;}
00079 
00080   /** returns the player number as an Integer */
00081   int getPlayerNumberAsInt() const {return (int)playerNumber; }
00082 
00083   /** copies another PlayerPose to this one */
00084   void operator = (const PlayerPose& other);
00085 
00086   /** sets the sigmaMin */
00087   void setSigmaMin(const double sigma) {sigmaMin = sigma;}
00088 
00089   /** returns the sigmaMin */
00090   const double& getSigmaMin() const {return sigmaMin;}
00091 
00092   /** sets the sigmaMaj */
00093   void setSigmaMaj(const double sigma) {sigmaMaj = sigma;}
00094 
00095   /** returns the sigmaMaj */
00096   const double& getSigmaMaj() const {return sigmaMaj;}
00097 
00098   /** sets the cosAngle */
00099   void setCosAngle(const double cos) {cosAngle = cos;}
00100 
00101   /** returns the cosAngle */
00102   const double& getCosAngle() const {return cosAngle;}
00103 
00104   /** sets the sinAngle */
00105   void setSinAngle(const double sin) {sinAngle = sin;}
00106 
00107   /** returns the sinAngle */
00108   const double& getSinAngle() const {return sinAngle;}
00109 
00110 private:
00111   /** The position and orientation of the player as a Pose2D */
00112   Pose2D pose;
00113 
00114   /** The speed of the player */
00115   double speed;
00116 
00117   /** The validity of the located robot */
00118   double validity;
00119 
00120   /** The variance in Min-direction */
00121   double sigmaMin;
00122 
00123   /** The variance in Maj-direction */
00124   double sigmaMaj;
00125 
00126   /** The cosinus of the angle of the variance-ellipse */
00127   double cosAngle;
00128 
00129   /** The sinus of the angle of the variance-ellipse */
00130   double sinAngle;
00131 
00132   /** These values are only needed for the own team */
00133   /** The last update of position */
00134   long timeStamp;
00135 
00136   /** Playernumber */
00137   Player::playerNumber playerNumber;
00138 };
00139 
00140 /**
00141  * Streaming operator that reads a PlayerPose from a stream.
00142  * @param stream The stream from which is read.
00143  * @param playerPose The PlayerPose object.
00144  * @return The stream.
00145  */ 
00146 In& operator>>(In& stream,PlayerPose& playerPose);
00147 
00148 /**
00149  * Streaming operator that writes a PlayerPose to a stream.
00150  * @param stream The stream to write on.
00151  * @param playerPose The PlayerPose object.
00152  * @return The stream.
00153  */ 
00154 Out& operator<<(Out& stream, const PlayerPose& playerPose);
00155 
00156 
00157 
00158 /**
00159  *  This class contains the PlayerPoses of all detected robots.
00160  */
00161 class PlayerPoseCollection
00162 {
00163 public:
00164   /** Constructor */
00165   PlayerPoseCollection();
00166 
00167   /** Copy-Constructor */
00168   PlayerPoseCollection(PlayerPoseCollection& other);
00169 
00170   /** Destructor */
00171   ~PlayerPoseCollection();
00172 
00173   /** sets a player pose of the own team at a given index */
00174   void setOwnPlayerPose(int index, const PlayerPose& pose) {ownPlayerPoses[index] = pose;}
00175 
00176   /** sets a player pose of the own team at a given index */
00177   void setOwnPlayerPose(int index, const double& x, const double& y, const double& rotation) 
00178   {ownPlayerPoses[index].setPose(x,y,rotation);}
00179 
00180   /** sets a player pose of the own team at a given index */
00181   void setOwnPlayerPose(int index, const double& x, const double& y, const double& rotation, const double& validity) 
00182   {
00183     ownPlayerPoses[index].setPose(x,y,rotation);
00184     ownPlayerPoses[index].setValidity(validity);
00185   }
00186 
00187   /** sets a player pose of the own team at a given index */
00188 /* 
00189   void setOwnPlayerPose(int index, const double& x, const double& y, 
00190                       const double& rotation,
00191                       const Player::playerNumber playerNumber,
00192                       const long timeStamp) 
00193   {
00194     ownPlayerPoses[index].setPose(x,y,rotation);
00195     ownPlayerPoses[index].setValidity(validity);
00196     ownPlayerPoses[index].setPlayerNumber(playerNumber);
00197     ownPlayerPoses[index].setTimeStamp(timeStamp);
00198 
00199   }
00200   */
00201   /** sets a player pose of the own team */
00202   void setOwnPlayerPose(const RobotPose pose, const Player::playerNumber playerNumber) 
00203   {
00204     if (numberOfOwnPlayers<4)
00205     {
00206       ownPlayerPoses[numberOfOwnPlayers].setRobotPose(pose);
00207       ownPlayerPoses[numberOfOwnPlayers].setPlayerNumber(playerNumber);
00208       ownPlayerPoses[numberOfOwnPlayers].setTimeStamp(SystemCall::getCurrentSystemTime());
00209       numberOfOwnPlayers++;
00210     }
00211   }
00212   /** returns a player pose of the own team for a given index */
00213   const PlayerPose& getOwnPlayerPose(int index) const {return ownPlayerPoses[index];}
00214 
00215   /** returns the player pose of the own team for a given player number */
00216   const bool getOwnPlayerPoseByPlayerNumber(Player::playerNumber player,PlayerPose& pose) const 
00217   {
00218     for (int i=0;i<numberOfOwnPlayers;i++)
00219     {
00220       if (ownPlayerPoses[i].getPlayerNumber() == player)
00221       {
00222         pose = ownPlayerPoses[i];
00223         return true;
00224       }
00225       else
00226         return false;
00227     }
00228     return false;
00229   }
00230 
00231   /** sets a player pose of the opponent team at a given index */
00232   void setOpponentPlayerPose(int index, const PlayerPose& pose) {opponentPlayerPoses[index] = pose;}
00233 
00234   /** sets a player pose of the opponent team at a given index */
00235   void setOpponentPlayerPose(int index, const double& x, const double& y, const double& rotation) 
00236   {opponentPlayerPoses[index].setPose(x,y,rotation);}
00237 
00238   /** sets a player pose of the opponent team at a given index */
00239   void setOpponentPlayerPose(int index, const double& x, const double& y, const double& rotation, const double& validity) 
00240   {
00241     opponentPlayerPoses[index].setPose(x,y,rotation);
00242     opponentPlayerPoses[index].setValidity(validity);
00243   }
00244   
00245   /** returns a player pose of the opponent team for a given index */
00246   const PlayerPose& getOpponentPlayerPose(int index) const {return opponentPlayerPoses[index];}
00247 
00248   /** copies another PlayerPoseCollection to this one */
00249   void operator = (const PlayerPoseCollection& other);
00250 
00251   /** Number of located opponent robots */
00252   int numberOfOpponentPlayers;
00253 
00254   /** Number of located own robots */
00255   int numberOfOwnPlayers;
00256 
00257   /** give the In operator acess to protected members */
00258   friend In& operator>>(In& stream,PlayerPoseCollection& playerPoseCollection);
00259 
00260   /** give the Out operator acess to protected members */
00261   friend Out& operator<<(Out& stream, const PlayerPoseCollection& playerPoseCollection);
00262 
00263 protected:
00264   /** A list of located opponent robots */
00265   PlayerPose opponentPlayerPoses[4];
00266 
00267   /** A list of located own robots */
00268   PlayerPose ownPlayerPoses[3];
00269 };
00270 
00271 /**
00272  * Streaming operator that reads a PlayerPoseCollection from a stream.
00273  * @param stream The stream from which is read.
00274  * @param playerPoseCollection The PlayerPoseCollection object.
00275  * @return The stream.
00276  */ 
00277 In& operator>>(In& stream,PlayerPoseCollection& playerPoseCollection);
00278  
00279 /**
00280  * Streaming operator that writes a PlayerPoseCollection to a stream.
00281  * @param stream The stream to write on.
00282  * @param playerPoseCollection The PlayerPoseCollection object.
00283  * @return The stream.
00284  */ 
00285 Out& operator<<(Out& stream, const PlayerPoseCollection& playerPoseCollection);
00286 
00287 
00288 #endif //__PlayerPoseCollection_h_

Generated on Mon Mar 20 22:00:01 2006 for GT2005 by doxygen 1.3.6