messages.h

00001 
00002 /***************************************************************************
00003  *  messages.h - World Info Transceiver Messages
00004  *
00005  *  Created: Wed May 02 10:25:56 2007
00006  *  Copyright  2006-2007  Tim Niemueller [www.niemueller.de]
00007  *
00008  ****************************************************************************/
00009 
00010 /*  This program is free software; you can redistribute it and/or modify
00011  *  it under the terms of the GNU General Public License as published by
00012  *  the Free Software Foundation; either version 2 of the License, or
00013  *  (at your option) any later version. A runtime exception applies to
00014  *  this software (see LICENSE.GPL_WRE file mentioned below for details).
00015  *
00016  *  This program is distributed in the hope that it will be useful,
00017  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  *  GNU Library General Public License for more details.
00020  *
00021  *  Read the full text in the LICENSE.GPL_WRE file in the doc directory.
00022  */
00023 
00024 #ifndef __NETCOMM_WORLDINFO_MESSAGES_H_
00025 #define __NETCOMM_WORLDINFO_MESSAGES_H_
00026 
00027 #include <netcomm/worldinfo/defs.h>
00028 #include <stdint.h>
00029 
00030 #pragma pack(push,4)
00031 
00032 namespace fawkes {
00033 
00034 /** WorldInfo message IDs. */
00035 typedef enum {
00036   WORLDINFO_MSGTYPE_POSE           = 1, /**< Sending robot's pose */
00037   WORLDINFO_MSGTYPE_VELO           = 2, /**< Sending robot's velocity */
00038   WORLDINFO_MSGTYPE_RELBALL        = 3, /**< Observed relative ball position */
00039   WORLDINFO_MSGTYPE_RELBALLVELO    = 4, /**< Observed relative ball velocity */
00040   WORLDINFO_MSGTYPE_OPP_POSE       = 5, /**< Observed opponent pose */
00041   WORLDINFO_MSGTYPE_OPP_DISAPP     = 6, /**< Observed opponent disappered */
00042   WORLDINFO_MSGTYPE_FAT_WORLDINFO  = 7, /**< Fat message containing all the information, @deprecated */
00043   WORLDINFO_MSGTYPE_GAMESTATE      = 8, /**< Gamestate info */
00044   WORLDINFO_MSGTYPE_PENALTY        = 9, /**< Penalty info */
00045   WORLDINFO_MSGTYPE_GLOBBALL       = 10,/**< Global ball position */
00046   WORLDINFO_MSGTYPE_GLOBBALLVELO   = 11 /**< Global ball velocity */
00047 } worldinfo_msgid_t;
00048 
00049 
00050 /** Per-message header.
00051  * In the sent buffer each message is preceeded by a per-message header which
00052  * contains the message type ID and the message length.
00053  */
00054 typedef struct {
00055   uint16_t type;        /**< message type in network byte order */
00056   uint16_t size;        /**< message size in network byte order */
00057 } worldinfo_message_header_t;
00058 
00059 
00060 /** World info header.
00061  * Every message conglomerate (each packet) is prefixed by this general
00062  * header. It is used to determine if decryption has been successful, if protocol
00063  * versions are compatible and if the received sequence number is valid to prevent
00064  * replay attacks or problems with packets received out-of-order.
00065  */
00066 typedef struct {
00067   uint16_t beef;        /**< has to contain 0xBEEF in network byte order */
00068   uint8_t  version;     /**< version of the following content */
00069   uint8_t  reserved;    /**< reserved for future use */
00070   uint32_t seq;         /**< sequence number in network byte order */
00071 } worldinfo_header_t;
00072 
00073 
00074 /** Robot pose message.
00075  * This message ought to be send by a robot to distribute its belief about its
00076  * position. This is NOT meant to be send with information about positions of
00077  * any other object or robot. There is a strong binding between the sender and
00078  * the object which this data describes.
00079  */
00080 typedef struct {
00081   float x;      /**< X coordinate */
00082   float y;      /**< Y coordinate */
00083   float theta;  /**< orientation */
00084   float covariance[WORLDINFO_COVARIANCE_SIZE_3X3];      /**< position covariance matrix */
00085 } worldinfo_pose_message_t;
00086 
00087 
00088 /** Robot velocity message.
00089  * This message ought to be send by a robot to distribute its belief about its
00090  * velocity. This is NOT meant to be send with information about velocities of
00091  * any other object or robot. There is a strong binding between the sender and
00092  * the object which this data describes.
00093  */
00094 typedef struct {
00095   float vel_x;  /**< Velocity in X direction */
00096   float vel_y;  /**< Velocity in Y direction */
00097   float vel_theta;      /**< Rotational velocity */
00098   float covariance[WORLDINFO_COVARIANCE_SIZE_3X3];      /**< velocity covariance matrix */
00099 } worldinfo_velocity_message_t;
00100 
00101 
00102 /** Relative ball position message.
00103  * This message describes a robots belief about the position of a ball relative
00104  * to itself.
00105  * This is NOT meant to be send with information about any other object but the ball.
00106  * There is a strong binding between the sender and the object which this data
00107  * describes which means that with this message a robot may not distribute another
00108  * robots belief of a ball position.
00109  */
00110 typedef struct {
00111   int32_t  history  : 24;       /**< visibility history, positive means number of positive
00112                                  * observations in a row, 0 means vision has just been
00113                                  * initialized, negative number means the number of negative
00114                                  * observations in a row (not seen for three loops results
00115                                  * in a history of -3). */
00116   int32_t  visible  :  1;       /**< -1 if ball visible, 0 otherwise. If the ball is not
00117                                  * visible the position will be the last known position.
00118                                  */
00119   int32_t  reserved :  7;       /**< reserved for future use. */
00120   float bearing;        /**< bearing to the ball, this is the angle between the robots
00121                          * forward direction and the ball on the ground plane (azimuth)*/
00122   float dist;           /**< distance to the robot */
00123   float slope;          /**< slope to the ball, this is the angle between the robots
00124                          * center position on the ground plane and the ball (declination) */
00125   float covariance[WORLDINFO_COVARIANCE_SIZE_3X3];      /**< ball covariance matrix */
00126 } worldinfo_relballpos_message_t;
00127 
00128 
00129 /** Global ball position message.
00130  * This message describes a robots belief about the global position of a ball.
00131  * This is NOT meant to be send with information about any other object but the ball.
00132  */
00133 typedef struct {
00134   int32_t  history  : 24;       /**< visibility history, positive means number of positive
00135                                  * observations in a row, 0 means vision has just been
00136                                  * initialized, negative number means the number of negative
00137                                  * observations in a row (not seen for three loops results
00138                                  * in a history of -3). */
00139   int32_t  visible  :  1;       /**< -1 if ball visible, 0 otherwise. If the ball is not
00140                                  * visible the position will be the last known position.
00141                                  */
00142   int32_t  reserved :  7;       /**< reserved for future use. */
00143   float x;               /**< x-coordinate of the global ball positions */
00144   float y;               /**< y-coordinate of the global ball positions */
00145   float z;               /**< z-coordinate of the global ball positions */
00146   float covariance[WORLDINFO_COVARIANCE_SIZE_3X3];      /**< ball covariance matrix */
00147 } worldinfo_globballpos_message_t;
00148 
00149 
00150 /** Relative ball velocity message.
00151  * This message describes a robots belief about the velocity of a ball relative
00152  * to itself.
00153  * This is NOT meant to be send with information about any other object but the ball.
00154  * There is a strong binding between the sender and the object which this data
00155  * describes which means that with this message a robot may not distribute another
00156  * robots belief of a ball position.
00157  */
00158 typedef struct {
00159   float vel_x;  /**< relative velocity of the ball in x direction */
00160   float vel_y;  /**< relative velocity of the ball in y direction */
00161   float vel_z;  /**< relative velocity of the ball in z direction */
00162   float covariance[WORLDINFO_COVARIANCE_SIZE_3X3];      /**< ball velocity covariance matrix */
00163 } worldinfo_relballvelo_message_t;
00164 
00165 
00166 /** Global ball velocity message.
00167  * This message describes a robots belief about the velocity wrt. the global frame.
00168  */
00169 typedef struct {
00170   float vel_x;  /**< global velocity of the ball in x direction */
00171   float vel_y;  /**< global velocity of the ball in y direction */
00172   float vel_z;  /**< global velocity of the ball in z direction */
00173   float covariance[WORLDINFO_COVARIANCE_SIZE_3X3];      /**< ball velocity covariance matrix */
00174 } worldinfo_globballvelo_message_t;
00175 
00176 
00177 /** Opponent message.
00178  * This message should be sent for every opponent that a robot detects. The position
00179  * is given in robot-relative polar coordinates on the ground plane.
00180  * This is NOT meant to be send with information about any other object but an opponent.
00181  * There is a strong binding between the sender and the object which this data
00182  * describes which means that with this message a robot may not distribute another
00183  * robots belief of an opponent position.
00184  * The sending robot assigns an ID to each opponent. The ID is unique on the robot, which
00185  * means that if two messages are sent with the same ID it can be assumed that it is for
00186  * the exact same opponents.
00187  */
00188 typedef struct {
00189   uint32_t uid;         /**< unique ID of this opponent */
00190   float    dist;        /**< distance to the opponent. */
00191   float    bearing;     /**< bearing to the opponent, this is the angle between the robots
00192                          * forward direction and the opponent on the ground plane (azimuth)*/
00193   float    covariance[WORLDINFO_COVARIANCE_SIZE_2X2];   /**< opponent position covariance matrix */
00194 } worldinfo_opppose_message_t;
00195 
00196 
00197 /** Opponent disappeared.
00198  * This message should be sent for every opponent that disappeared or that cannot be
00199  * tracked any longer. The UID is the uid that had been sent with an earlier opponent
00200  * pose message.
00201  */
00202 typedef struct {
00203   uint32_t uid;         /**< unique ID of the disappeared opponent */
00204 } worldinfo_oppdisappeared_message_t;
00205 
00206 
00207 /** Fat worldinfo message.
00208  * Legacy adapter message to communicate with TU Graz team.
00209  */
00210 typedef struct {
00211   uint32_t                        valid_pose          :  1;     /**< 1 if pose is valid, 0 otherwise*/
00212   uint32_t                        valid_velo          :  1;     /**< 1 if velo is valid, 0 otherwise*/
00213   uint32_t                        valid_relball_pos   :  1;     /**< 1 if relball_pos is valid, 0 otherwise*/
00214   uint32_t                        valid_relball_velo  :  1;     /**< 1 if relball_velo is valid, 0 otherwise*/
00215   uint32_t                        num_opponents       :  8;     /**< number of opponents with valid data in opponents */
00216   uint32_t                        reserved            : 20;     /**< reserved for future use */
00217   worldinfo_pose_message_t        pose;                         /**< sending robot's pose */
00218   worldinfo_velocity_message_t    velo;                         /**< sending robot's velocity */
00219   worldinfo_relballpos_message_t  relball_pos;                  /**< ball position relative to sending robot */
00220   worldinfo_relballvelo_message_t relball_velo;                 /**< ball velocity relative to sending robot */
00221   worldinfo_opppose_message_t     opponents[WORLDINFO_FATMSG_NUMOPPS];  /**< best seen opponents */
00222 } worldinfo_fat_message_t;
00223 
00224 
00225 /** Game state message.
00226  * This message is sent by the refbox repeater to indicate the current game state.
00227  */
00228 typedef struct {
00229   uint32_t   game_state     : 4;        /**< Current game state, can be freely chosen,
00230                                          * worldinfo_gamestate_t provides recommended
00231                                          * values for soccer games. */
00232   uint32_t   state_team     : 2;        /**< Team the game state references */
00233   uint32_t   score_cyan     : 8;        /**< Score of team cyan */
00234   uint32_t   score_magenta  : 8;        /**< Score of team magenta */
00235   uint32_t   our_team       : 2;        /**< Our team color */
00236   uint32_t   our_goal_color : 1;        /**< Our own goal color */
00237   uint32_t   half           : 1;        /**< Game time half */
00238   uint32_t   reserved       : 6;        /**< Reserved for future use */
00239 } worldinfo_gamestate_message_t;
00240 
00241 /** Penalty message.
00242  * This message is sent by the refbox repeater to indicate individual penalties
00243  * for particular robots. This is optional and used in the SPL.
00244  */
00245 typedef struct {
00246   uint32_t   player            :  4;    /**< Number of penalized robot. */
00247   uint32_t   penalty           :  6;    /**< Penalty code, cf. worldinfo_penalty_t. */
00248   uint32_t   reserved          :  6;    /**< Reserved for future use. */
00249   uint32_t   seconds_remaining : 16;    /**< Estimate in seconds when unpenalized. */ 
00250 } worldinfo_penalty_message_t;
00251 
00252 } // end namespace fawkes
00253 
00254 #pragma pack(pop)
00255 
00256 #endif

Generated on Tue Feb 22 13:31:25 2011 for Fawkes API by  doxygen 1.4.7