📄 soccertypes.h
字号:
/*!The ObjectSetT enumerations holds the different object sets, which consists of one or multiple ObjectT types. */enum ObjectSetT{ OBJECT_SET_TEAMMATES, /*!< teammates */ OBJECT_SET_OPPONENTS, /*!< opponents */ OBJECT_SET_PLAYERS, /*!< players */ OBJECT_SET_TEAMMATES_NO_GOALIE,/*!< teammates without the goalie */ OBJECT_SET_FLAGS, /*!< flags */ OBJECT_SET_ILLEGAL /*!< illegal */} ;/*!The PlayModeT enumeration contains all playmodes of the soccer playmode. The associated string values can be returned using the methods in the SoccerTypes class */enum PlayModeT { PM_BEFORE_KICK_OFF = 0, /*!< before_kick_off: before kick off */ PM_KICK_OFF_LEFT, /*!< kick_off_l: kick off for left team */ PM_KICK_OFF_RIGHT, /*!< kick_off_r: kick off for right team */ PM_PLAY_ON, /*!< play_on: play on (during match) */ PM_KICK_IN_LEFT, /*!< kick_in_l: kick in for left team */ PM_KICK_IN_RIGHT, /*!< kick_in_r: kick in for right team */ PM_CORNER_KICK_LEFT, /*!< corner_kick_l: corner kick left team */ PM_CORNER_KICK_RIGHT, /*!< corner_kick_r: corner kick right team */ PM_GOAL_KICK_LEFT, /*!< goal_kick_l: goal kick for left team */ PM_GOAL_KICK_RIGHT, /*!< goal_kick_r: goal kick for right team*/ PM_OFFSIDE_LEFT, /*!< offside_l: offside for left team */ PM_OFFSIDE_RIGHT, /*!< offside_r: offside for right team */ PM_QUIT, /*!< quit */ PM_GOAL_LEFT, /*!< goal_l: goal scored by team left*/ PM_GOAL_RIGHT, /*!< goal_r: goal scored by team righ*/ PM_FREE_KICK_LEFT, /*!< free_kick_l: free kick for left team */ PM_FREE_KICK_RIGHT, /*!< free_kick_r: free kick for right team*/ PM_ILLEGAL /*!< unknown playmode */} ;/*!The SideT enumeration contains the two sides */enum SideT { SIDE_NONE = 0, /*!< Our Side */ SIDE_LEFT, /*!< Left side */ SIDE_RIGHT, /*!< Right side */ SIDE_ILLEGAL /*!< Illegal side */} ;/*!The CommandT enumeration contains the different types for the SoccerCommand that are possible. */enum CommandT { CMD_ILLEGAL, /*!< illegal command */ CMD_JOINT, /*!< Joint handling command */ CMD_SAY, /*!< say command */ CMD_MAX_COMMANDS /*!< maximum number of commands */} ;/*!The PlayerT enumeration contains the different playertypes that are defined in a formation. This should not be confused with the later introducted player_types in soccerserver 7.xx that denotes the different possible heterogeneous players. A player type in the context PlayerT denotes the kind of player (midfielder, attacker) on the field. Its role on the pitch.*/enum PlayerT { PT_ILLEGAL, /*!< illegal player type */ PT_GOALKEEPER, /*!< goalkeeper */ PT_DEFENDER_CENTRAL, /*!< central defender */ PT_DEFENDER_SWEEPER, /*!< sweeper defender */ PT_DEFENDER_WING, /*!< wing defender */ PT_MIDFIELDER_CENTER, /*!< central midfielder */ PT_MIDFIELDER_WING, /*!< wing midfielder */ PT_ATTACKER_WING, /*!< wing attacker */ PT_ATTACKER, /*!< central attacker */ MAX_PLAYER_TYPES} ;/*! The PlayerSetT enumeration contains different sets of playertypes that are defined in a formation. Possible sets are all midfielders, etc. */enum PlayerSetT { PS_DEFENDERS, /*!< all defenders */ PS_MIDFIELDERS, /*!< all midfielders */ PS_ATTACKERS, /*!< all attackers */ PS_ALL /*!< all players */} ;/*!The FormationT enumeration contains the different formation types that are defined. */enum FormationT { FT_ILLEGAL, /*!< illegal formation type */ FT_INITIAL, /*!< initial formation type (before kick off)*/ FT_433_OFFENSIVE, /*!< 433 offensive formation */ FT_334_OFFENSIVE, /*!< 434 offensive formation */ FT_343_ATTACKING, /*!< attacking formation type */ MAX_FORMATION_TYPES} ;/*! The MarkT enumeration contains different marking techniques. */enum MarkT { MARK_ILLEGAL, /*!< illegal marking */ MARK_GOAL, /*!< mark goal (stand on obj-goal line) */ MARK_BISECTOR, /*!< mark bisector stand between goal,obj and ball,obj */ MARK_BALL /*!< mark ball (stand on obj-ball line) */} ;/*! The ClearBallT enumeration contains different clear ball possibilities. */enum ClearBallT { CLEAR_BALL_ILLEGAL, /*!< illegal clear ball */ CLEAR_BALL_OFFENSIVE, /*!< clear ball to the front of the field */ CLEAR_BALL_DEFENSIVE, /*!< clear ball to the center line of the field */ CLEAR_BALL_OFFENSIVE_SIDE, /*!< clear ball to front and side of the field */ CLEAR_BALL_GOAL /*!< clear ball to position in front of the goal */} ;/*! The SucceedT enumeration contains the different succeed rate probabilites*/enum SucceedT { SUCCEED_ILLEGAL, /*!< illegal message */ SUCCEED_ALWAYS, /*!< wil always succeed */ SUCCEED_DOUBTFUL, /*!< in some occassions it may succeed */ SUCCEED_NEVER /*!< this will never succeed */} ;/*****************************************************************************//********************* CLASS SOCCERCOMMAND ***********************************//*****************************************************************************//*!This class resembles a SoccerCommand that contains all the information about a command that can be sent to the server, but the format is independent from the server implementation. A SoccerCommand can be created and before it is sent to the server, be converted to the actual string representation understood by the server. */class SoccerCommand{ // private methods to generate text string to send to server bool makeCommandString ( char *str ) const;public: // different variables that are used by the different possible commands // only the variables that are related to the current commandType have // legal values CommandT commandType; /*!< type of this command */ JointT JID; /*!< Joint to change within this command */ double dSpeed1; /*!< speed of first angle of joint */ double dSpeed2; /*!< speed of second angle joint */ char str[MAX_SAY_MSG]; /*!< str (for say) */ SoccerCommand ( CommandT com = CMD_ILLEGAL, JointT jid = JID_ILLEGAL, double d1=UnknownDoubleValue, double d2=UnknownDoubleValue ); SoccerCommand ( CommandT com, char *msg ); // command to set the different values of the SoccerCommand void makeCommand ( CommandT com, JointT jid, double d1 = UnknownDoubleValue, double d2 = UnknownDoubleValue ); void makeCommand ( CommandT com, char *msg ); bool isIllegal ( ); friend ostream& operator << (ostream &os, SoccerCommand cmd ); void show ( ostream& os = cout ); // used to return the string representation of this SoccerCommand bool getCommandString ( char *str ) const;} ;/*****************************************************************************//********************** CLASS SOCCERTYPES ************************************//*****************************************************************************//*! The class SoccerTypes contains different methods to work with the different enumerations defined in SoccerTypes.h. It is possible to convert soccertypes to strings and strings to soccertypes. It is also possible to get more specific information about some of the soccertypes. All methods are static so it is possible to call the methods without instantiating the class. */class SoccerTypes{ public: // methods that deal with the different objects static char* getObjectStr ( char *strBuf, ObjectT o ); static ObjectT getObjectFromStr ( char *str ); static bool isInSet ( ObjectT o, ObjectSetT o_g, ObjectT objectGoalie= OBJECT_TEAMMATE_1 ); static bool isPlayerTypeInSet ( PlayerT p, PlayerSetT p_s ); static bool isGoal ( ObjectT o ); static bool isFlag ( ObjectT o ); static bool isBall ( ObjectT o ); static bool isTeammate ( ObjectT o ); static bool isOpponent ( ObjectT o ); static bool isGoalie ( ObjectT o ); static bool isPlayer ( ObjectT o ); static int getIndex ( ObjectT o ); static ObjectT getTeammateObjectFromIndex( int iIndex ); static ObjectT getOpponentObjectFromIndex( int iIndex ); static bool isKnownPlayer ( ObjectT o ); // methods that deal with the different play modes static const char* getPlayModeStr ( PlayModeT p ); static PlayModeT getPlayModeFormStr ( const char *str ); // methods that deal with the side information static const char* getSideStr ( SideT s ); static SideT getSideFromStr ( char* str ); // methods that deal with joint namings static JointT getJointFromStr ( const char * str ); static const char * getJointStr ( JointT joint ); static const char * getJointServerMsg ( JointT joint ); // methods that deal with sensors static const char * getSensorString ( SensorT sense ); static const SensorT getSensorFromString ( const char *str );} ;#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -