00001 /** 00002 * @file Representations/WLan/TeamMessage.h 00003 * 00004 * Declaration of class TeamMessage 00005 * 00006 * @author <A href=mailto:roefer@tzi.de>Thomas Röfer</A> 00007 * @author <A href=mailto:sebastian.schmidt@udo.edu>Sebastian Schmidt</A> 00008 * @author <A href=mailto:m_wachter@gmx.de>Michael Wachter</A> 00009 */ 00010 00011 #ifndef __TeamMessage_h_ 00012 #define __TeamMessage_h_ 00013 00014 #include "Tools/Streams/InOut.h" 00015 #include "Tools/Player.h" 00016 #include "Representations/Cognition/RobotPose.h" 00017 #include "Representations/Cognition/BallModel.h" 00018 #include "Representations/WLan/BehaviorTeamMessage.h" 00019 00020 class TeamMessage; 00021 00022 /** 00023 * Streaming operator that reads a team message from a stream. 00024 * @param stream The stream from which is read. 00025 * @param teamMessage The object to be read. 00026 * @return The stream. 00027 */ 00028 In& operator>>(In& stream,TeamMessage& teamMessage); 00029 00030 /** 00031 * Streaming operator that writes a team message to a stream. 00032 * @param stream The stream to write on. 00033 * @param teamMessage The object to be written. 00034 * @return The stream. 00035 */ 00036 Out& operator<<(Out& stream, const TeamMessage& teamMessage); 00037 00038 00039 /** 00040 * @class TeamMessage 00041 * 00042 * Represents a collection of all data that is exchanged between the different robots. 00043 */ 00044 class TeamMessage 00045 { 00046 public: 00047 00048 unsigned timeStamp, /**< The time stamp of the sending robot. */ 00049 lastReceivedTimeStamp, /**< The timeStamp of the last package received from the receiving robot. */ 00050 incomingTimeStamp; /**< The local receiving time of the last package received from the receiving robot. */ 00051 00052 RobotPose robotPose; /**< The robot pose of the robot. */ 00053 bool sendRobotPose; /**< Send robotPose if true. */ 00054 00055 SeenBallPosition seenBallPosition; /**< The ball seen by the robot. */ 00056 bool sendSeenBallPosition; /**< Send seenBallPosition if true. */ 00057 00058 BehaviorTeamMessage behaviorTeamMessage; /**< Messages by the behavior */ 00059 bool sendBehaviorTeamMessage; /**< Send behaviorTeamMessage if true */ 00060 00061 signed long timeOffset; /**< timeOffset Remote time - local time */ 00062 00063 Player::playerNumber playerNumberOfSender; /**< The player number of the Sender */ 00064 00065 /** 00066 * Constructor. 00067 */ 00068 TeamMessage() { 00069 timeStamp = lastReceivedTimeStamp = incomingTimeStamp = 0; 00070 sendRobotPose = sendSeenBallPosition = sendBehaviorTeamMessage = false; 00071 } 00072 00073 /** 00074 * The function determines, whether the team message is actual. 00075 * @return Did the communication take less than 1 seconds? 00076 */ 00077 bool isActual() const; 00078 00079 /** 00080 * This function returns the time of the remote player in the time 00081 * system of the local player 00082 */ 00083 long getTimeStampInOwnTime() const ; 00084 00085 /** 00086 * This function converts a remote timeStamp to the local time system 00087 * @param time the timeStamp to be converted 00088 */ 00089 long getTimeInOwnTime(long time) const; 00090 00091 /** 00092 * This function converts a local timeStamp to the remote time system 00093 * @param time the timeStamp to be converted 00094 */ 00095 long getTimeInRemoteTime(long time) const; 00096 00097 private: 00098 static void read(In& stream,Vector2<double>& v); 00099 static void read(In& stream,Pose2D& p); 00100 static void write(Out& stream,const Vector2<double>& v); 00101 static void write(Out& stream,const Pose2D& p); 00102 friend In& operator>>(In& stream,TeamMessage& teamMessage); 00103 friend Out& operator<<(Out& stream, const TeamMessage& teamMessage); 00104 }; 00105 00106 /** A TeamMessage from team mate 1 */ 00107 class TeamMessage1 : public TeamMessage {}; 00108 00109 /** A TeamMessage from team mate 2 */ 00110 class TeamMessage2 : public TeamMessage {}; 00111 00112 /** A TeamMessage from team mate 3 */ 00113 class TeamMessage3 : public TeamMessage {}; 00114 00115 class TeamMessage4 : public TeamMessage {}; 00116 00117 #endif //__TeamMessage_h_ 00118 00119 /* 00120 * Change log : 00121 * 00122 * $Log: TeamMessage.h,v $ 00123 * Revision 1.1.1.1 2004/05/22 17:26:05 cvsadm 00124 * created new repository GT2004_WM 00125 * 00126 * Revision 1.5 2004/05/14 14:12:08 wachter 00127 * - Added communication support for 5 robots 00128 * - rewrote parts of team-communication to be faster and more stable 00129 * 00130 * Revision 1.4 2004/02/03 13:19:50 spranger 00131 * renamed all references to class BallPosition to BallModel 00132 * 00133 * Revision 1.3 2003/12/06 17:45:33 loetzsch 00134 * replaced Player::playerRole (goalie, defender, striker1, striker2) 00135 * by Player::playerNumber (one, two, three, four) 00136 * 00137 * Revision 1.2 2003/11/30 01:53:18 loetzsch 00138 * prepared RobotControl port to Visual C++ .Net 00139 * 00140 * Revision 1.1 2003/10/07 10:09:36 cvsadm 00141 * Created GT2004 (M.J.) 00142 * 00143 * Revision 1.4 2003/09/26 15:27:27 juengel 00144 * Renamed DataTypes to representations. 00145 * 00146 * Revision 1.3 2003/08/09 14:53:10 dueffert 00147 * files and docu beautified 00148 * 00149 * Revision 1.2 2003/07/02 19:14:23 loetzsch 00150 * bug fixes, removed unused functions 00151 * 00152 * Revision 1.1.1.1 2003/07/02 09:40:23 cvsadm 00153 * created new repository for the competitions in Padova from the 00154 * tamara CVS (Tuesday 2:00 pm) 00155 * 00156 * removed unused solutions 00157 * 00158 * Revision 1.8 2003/05/06 22:19:11 dueffert 00159 * Greenhills compilability restored 00160 * 00161 * Revision 1.7 2003/05/02 12:57:13 loetzsch 00162 * TeamMessage now contains a SeenBallPosition instead of a BallPercept 00163 * 00164 * Revision 1.6 2003/03/30 11:57:27 loetzsch 00165 * removed backward warnings 00166 * 00167 * Revision 1.5 2003/02/28 17:02:55 wachter 00168 * Reenabled trainer-syncronisation for RuhrpottHellhound-Behavior 00169 * 00170 * Revision 1.4 2003/02/18 13:24:36 wachter 00171 * added new TeamMessageCollection and TeamMessage 00172 * 00173 * Revision 1.3 2002/11/27 13:47:21 dueffert 00174 * doxygen docu added 00175 * 00176 * Revision 1.2 2002/09/22 18:40:51 risler 00177 * added new math functions, removed GTMath library 00178 * 00179 * Revision 1.1 2002/09/10 15:26:41 cvsadm 00180 * Created new project GT2003 (M.L.) 00181 * - Cleaned up the /Src/DataTypes directory 00182 * - Removed Challenge Code 00183 * - Removed processing of incoming audio data 00184 * - Renamed AcousticMessage to SoundRequest 00185 * 00186 * Revision 1.6 2002/07/23 13:32:57 loetzsch 00187 * new streaming classes 00188 * 00189 * removed many #include statements 00190 * 00191 * Revision 1.5 2002/06/09 15:24:51 loetzsch 00192 * Added TeamMessageCollection and BehaviorTeamMessage to the execute of BehaviorControl 00193 * 00194 * Revision 1.4 2002/06/06 16:10:46 roefer 00195 * Robot pose and ball percept added 00196 * 00197 * Revision 1.3 2002/06/03 15:27:30 roefer 00198 * BallLocator gets TeamMessageCollection 00199 * 00200 * Revision 1.2 2002/05/26 14:55:25 roefer 00201 * Team communication is working 00202 * 00203 * Revision 1.1 2002/05/16 22:36:11 roefer 00204 * Team communication and GTMath bugs fixed 00205 * 00206 * 00207 */