• Nenhum resultado encontrado

Protocols

No documento RoboCup Soccer Server (páginas 80-85)

5. The Soccer Monitor 51

6.1. Protocols

6. Soccer Client

If you connect to server with versions 7.00 or higher you will receive additional server parameters, player parameters and player types information ( the last two are related to the hetero players feature ). For the exact format refer to the appendix.

(server param Parameters . . .) (player param Parameters . . .) (player type id Parameters . . .)

Here the hand shaking is finished and your client is known as a valid player.

Reconnection

Reconnection is useful for changing the client program of a player without restarting the game. It can only be done in a non-PlayOn playing mode (e.g. in the half time).

For reconnection you should send a reconnect command in the following format:

(reconnect TeamName UniformNumber) And you will receive a response in the following format:

(reconnect Side PlayMode) Or one of the following errors:

(can’t reconnect)

if the game is in the PlayOn mode.

(error reconnect)

when no client reconnected due to an error. You may also receive the following error if the team name is invalid(error no more team or player or goalie)

Here again if you are connecting to the server with version 7.00 or higher you will receive additional server parameters, player parameters and player types information.

Disconnection

Before you disconnect, you can send a bye command to the server. This command will remove the player from the field.

(bye)

There will be no answers from the server.

6.1. Protocols Version Control

Due to the progressive development of the Soccer Server, new features have been added every year and this resulted in changes and improvements in the protocols to support these features. In order to keep compatibility with the older clients and making it easier to work with (specially for researchers), a system has been implemented for the Protocols Version Control. Every client should tell the server the version of its communication protocol in the initcommand so that the server would be able to send the messages in the proper format.

But note that although the communication protocol remains unchanged, the judg-ment and the simulation rules may change and this will affect the whole game.

6.1.2. Control Commands

During the game each player can send action commands. The server executes the mands at the end of the cycle and simulates the next cycle regarding the received com-mands and the previous cycles data.

Body Commands

All the playing and movement behaviors of the player are consisted from a few commands known as body commands that are presented briefly below.

The results of these commands are a little complicated and depend on many simula-tion factors. For the details of the execusimula-tion of each command refer to the Soccer Server Section.

(turn Moment)

The Moment is in degrees from −180 to 180. This command will turn the player’s body direction Moment degrees relative to the current direction.

(dash Power)

This command accelerates the player in the direction of its body (not direc-tion of the current speed). The Power is between minpower (used value:

−100) andmaxpower(used value: 100).

(kick Power Direction)

Accelerates the ball with the given Power in the givenDirection. The direc-tion is relative to the the Directionof the body of the player and the power is again between minpowerand maxparam.

(catch Direction)

73

Goalie special command: Tries to catch the ball in the givenDirectionrelative to its body direction. If the catch is successful the ball will be in the goalie’s hand until kicked away.

(move X Y)

This command can be executed only before kick off and after a goal. It moves the player to the exact position of X (between −54 and 54) and Y (between −32 and 32) in one simulation cycle. This is useful for before kick off arrangements.

Note that in each simulation cycle, only one of the above five commands can be executed (i.e. if the client sends more than one command in a single cycle, one of them will be executed randomly, usually the one received first)

(turn neck Angle)

This command can be sent (and will be executed) each cycle independently, along with other action commands. The neck will rotate with the givenAngle relative to pre-vious Angle. Note that the resulting neck angle will be betweenminneckang(default:

−90) and maxneckang (default: 90) relative to the player’s body direction.

Communication Commands

The only way of communication between two players is broadcasting of messages through thesaycommand and hearing through thehear sensor.

(say Message)

This command broadcasts theMessagethrough the field, and any player near enough (specified withaudio cut dist, default: 50.0 meters), with enough hearing capacity will hear theMessage. The message is a string of valid characters.

(ok say)

Command succeeded.

In case of error there will be the following response from the Server:

(error illegal command form) Misc. Commands

Other commands are usually of two forms:

Data Request Commands (sense body)

6.1. Protocols Requests the server to send sense body information. Note the server sends sense body information every cycle if you connect with version 6.00 or higher.

(score)

Request the server to send score information. The server’s reply will be in this format:

(score Time OurScore OpponentScore) Mode Change Commands

(change view Width Quality)

Changes the view parameters of the player. Width is one of narrow, normalor wideandQuality is one ofhighorlow. The amount and detail of the information returned by the visual sensor depends on the width of the view and the quality. But note that the frequency of sending information also depends on these parameters (e.g. if you change the quality from high to low, the frequency doubles, and the time between two see sensors will be cut to half).

6.1.3. Sensor Information

Sensor information are the messages that are sent to all players regularly (e.g. each cycle or each one and half a cycle). There is no need to send any message to the server to get these information.

All the returned information of the sensors have a time label, indication the cycle number of the game when the data have been sent (indicated by Time). This time is very useful.

Visual Sensor

Visual Sensor is the most important sensor, and is a little bit complicated. This sensor returns information about the objects that can be seen from the player’s view (i.e.

objects that are in the view angle and not very far).

The main format of the information is:

(see Time ObjInfo ObjInfo . . . ) TheObjInfos are of the format below:

(ObjName Distance Direction [DistChange DirChange [BodyFac-ingDir HeadFac[BodyFac-ingDir]])

or

75

(ObjName Direction)

Note that the amount of information returned for each object depends on its dis-tance. The more distant the object is the less information you get. For more detailed information regardingObjInfo refer to Appendix.

ObjName is in one of the following formats:

(p [TeamName [Unum]]) (b)

(f FlagInfo) (g Side)

p stands for player, b stands for ball,fstands for flag and g stands for goal.

Side is one of l for left or r for right. For more information on FlagInfo refer to Appendix.

Audio Sensor

Audio sensor returns the messages that can be heard through the field. They may come from the online coach, referee, or other players.

The format is as follows:

(hear Time Sender Message) Sender is one of the followings:

self: when the sender is yourself.

referee: when the sender is the referee of the game.

online coach l oronline coach r

Direction: when the sender is a player other than yourself the relative direction of the sender is returned instead.

Body Sensor

Body sensor returns all the states of the player such as remaining stamina, view mode and the speed of the player at the beginning of each cycle:

(sense body Time (view mode { high | low } { narrow | normal | wide}) (staminaStamina Effort) (speedSpeed Angle) (head angle Angle) (kickCount) (dashCount) (turnCount) (sayCount) (turn neck Count) (catch Count) (move Count) (change view Count))

The last eight parameters are counters of the received commands. Use the counters to keep track of lost or delayed messages.

No documento RoboCup Soccer Server (páginas 80-85)

Documentos relacionados