-
Notifications
You must be signed in to change notification settings - Fork 0
AIWC Development Guide Python P2
Previous Page - Section 3 - Development Guide (Python) (1/3)
In AI World Cup, the data provided by the simulation program are pre-modified in a way that you do not need to consider whether you are Team A or Team B. All coordinates and images are rotated by π and the robot marker colors are swapped to make your team Red and located on the left side of the field. You can always assume that your team is Red and located on the left side whether you are Team A or Team B, or whether it is first half or second half. In case of AI Commentator and AI Reporter, the data sent are identical to the data sent to Team A.
In AI World Cup, two different dictionaries are sent from the simulation program to provide information of the game. The keys are shown in Table 18 Dictionary ‘info’ and Table 19 Dictionary ‘f’. You can check ‘general_check-variables.py’ and ‘general_image-fetch.py’ to see how these data are accessible in the player program. You can check general_check-variables.py and general_image-fetch.py to see how these data are accessible in the player program.
3-1. Basic Information Dictionary ‘info’
The first dictionary is ‘info’ dictionary that contains basic information about the game. The information held in this dictionary are the values that don’t change throughout the game such as field dimensions and robot specifications. This dictionary is accessible through variable ‘info’ by the player program in the method ‘init_variables()’ (i.e. ‘info[‘game_time’]’ contains the game duration). You should save the information you wish to use in the callback method ‘on_event()’ as class variables. Note that the information contained in this dictionary will be identical to those shown in Section 1 – SPECIFICATIONS in this document.
Information Stored in Dictionary 'info' | ||
Member Variable | Data Type | Description |
field | list of floats (length 2) | Soccer field dimensions [x, y] in m |
goal | list of floats (length 2) | Goal dimensions [x, y] in m |
penalty_area | list of floats (length 2) | Penalty area dimensions [x, y] in m |
goal_area | list of floats (length 2) | Goal area dimensions [x, y] in m ※ Note that none of rules is rulated to this region. |
ball_radius | float | Soccer ball radius in m |
ball_mass | float | Soccer ball mass in kg |
robot_size | list of floats (length 5) | Robot sizes of [GK, D1, D2, F1, F2] in m |
robot_height | list of floats (length 5) | Robot heights of [GK, D1, D2, F1, F2] in m |
axle_length | list of floats (length 5) | Axle lengths of [GK, D1, D2, F1, F2] in m |
robot_body_mass | list of floats (length 5) | Robot body masses of [GK, D1, D2, F1, F2] in kg |
wheel_radius | list of floats (length 5) | Wheel radii of [GK, D1, D2, F1, F2] in m |
wheel_mass | list of floats (length 5) | Wheel masses of [GK, D1, D2, F1, F2] in kg |
max_linear_velocity | list of floats (length 5) | Maximum linear velocity available on each wheel of [GK, D1, D2, F1, F2] in m/s |
max_torque | list of floats (length 5) | Maximum torque available on each wheel of [GK, D1, D2, F1, F2] in N*m |
resolution | list of ints (length 2) | Image size [width, height] in pixel dimensions |
number_of_robots | int | Number of robots |
codewords | list of ints (length 5) | The hamming codes in decimal values attached as the robot identifier in the image sent to the players. The order is [GK, D1, D2, F1, F2]. ※ Details are explained in 3-3. Image Data. |
game_time | float | Game duration in s |
3-2. Frame Dictionary ‘f’
The second dictionary is ‘f’ dictionary that contains each game frame’s information. The information held in this dictionary are the values that change throughout the game such as the robot and ball coordinates. Therefore, new ‘f’ is introduced as the input data structure whenever ‘on_event()’ is called (i.e. f[‘coordinates’][0][0][0] contains your team’s GK robot’s x-position).
Information Stored in Dictionary 'f' | ||
Member Variable | Data Type | Description |
time | float | Current game time in s |
score | list of ints (length 2) | Current scores of [your team, opponent's team] |
reset_reason | int (enumeration) | Reason for the game pause before current frame The value can be one of following enumerations: 0. NONE – No pause happened. 1. GAME_START – Game just began and the game is going into a kick-off. 2. SCORE_MYTEAM – Your team scored and the game is going into a kick-off. 3. SCORE_OPPONENT – Opponent’s team scored and the game is going into a kick-off. 4. GAME_END – Game just ended. 5. DEADLOCK – A ball relocation happened. 6. GOALKICK – Game is going into a goal kick. 7. CORNERKICK – Game is going into a corner kick. 8. PENALTYKICK – Game is going into a penalty kick. 9. HALFTIME – Second half just began and game is going into a kick-off. 10. EPISODE_END – Game just ended (replaces GAME_END when ‘repeat’ is true). ※ About ‘repeat’, please refer to the online system documentation. |
game_state | int (enumeration) | Current game state The value can be one of following enumerations: 0. STATE_DEFAULT – Default state 1. STATE_KICKOFF – Kick-off state 2. STATE_GOALKICK – Goal kick state 3. STATE_CORNERKICK – Corner kick state 4. STATE_PENALTYKICK – Penalty kick state |
ball_ownership | bool | Indicator for whether your team owns the ball (true) or not (false) in special states such as kick-off, corner kick, penalty kick, and goal kick ※ This value does not mean anything in default state. |
half_passed | bool | Indicator for whether the game is currently in first half (false) or in second half (true). |
subimages | list of items | Image fragments need to be merged with previous image frame to obtain the new frame. ※ Details are explained in 3-3. Image Data. |
coordinates | list of [your team coordinates list, opponent team coordinates list, ball coordinate list] | Current robots and ball states ※ Although it says optional, coordinates will always be provided in this competition. ※ Details are explained in Tables below |
EOF | bool | Marker for the end of frame |
Information Stored in List 'your team coordinates' or 'opponent team coordinates' | ||
Index | Data Type | Description |
[0] | robot coordinate list | GK robot's coordinate |
[1] | robot coordinate list | D1 robot's coordinate |
[2] | robot coordinate list | D2 robot's coordinate |
[3] | robot coordinate list | F1 robot's coordinate |
[4] | robot coordinate list | F2 robot's coordinate |
Information Stored in List 'robot_coordinate' | ||
Index | Data Type | Description |
[0] | float | x-position of the robot in m |
[1] | float | y-position of the robot in m |
[2] | float | Orientation of the robot in rad
※ The value is not necessarily in range [-π, π]. Check the actual value and convert it to the range you wish to use. |
[3] | bool | Indicator for whether the robot can currently move or not. Some robots cannot move in special states such as kick-off, corner kick, penalty kick, and goal kick. Also, a robot cannot move when it is sent out from the field. |
[4] | bool | Indicator for whether the robot touched the soccer ball within last time frame. This value is provided since it is hard to find whether the ball and the robot are in contact through coordinates or image. |
Information Stored in List 'ball_coordinate' | ||
Index | Data Type | Description |
[0] | float | x-position of the soccer ball in m |
[1] | float | y-position of the soccer ball in m |
3-3. Image Data
In AI World Cup, the images sent to the players are not the raw images but a modified image containing same field status. The image size is 640 x 480.
AI World Cup with Player Views Shown
In the figure above, the modified images sent to the player programs are shown with a game frame. The green field is replaced with a black field, the soccer ball is replaced with an orange ball, and the robot role markers are replaced with special markers. The image on upper-left corner is sent to Team A and the image on upper-right corner is sent to Team B. Note that Team B’s image is rotated by π and the team colors are swapped.
Your Team | Opponent's Team | |
Team Marker |
GK | D1 | D2 | F1 | F2 | |
Role Marker | |||||
Hamming Code | 000000000 | 000011111 | 011100011 | 101101100 | 110110101 |
Decimal Value | 0 | 31 | 227 | 364 | 437 |
Marker Construction
As can be seen in the table above, the player view marker is an additive color mixture of a red-colored or blue-colored team marker and a green-colored role marker. Thus, by putting a mask on each of RGB channels, the player view marker can be separated back to a team marker and a role marker.
From the ∏–shaped team marker, you can determine whether the robot is your robot (red) or opponent’s robot (blue). Also, you can determine the robot’s position and orientation by how the shape is positioned and oriented in the frame image.
From the green-colored role marker, you can identify which robot it is. 9-bit Hamming code schema was used to generate the five distinguishable patterns. For example, the binary Hamming code for F2 robot is ‘110110101’. The square role marker is sliced into 9 small squares. From the highest bit to the lowest bit, the bits are assigned to the small squares located on upper row’s left to right, middle row’s left to right, and lower row’s left to right. Each small square is colored green if the corresponding bit is 1 and colored black if the corresponding bit is 0.
In AI World Cup, image frames are sent in fragments in order to save the communication bandwidth. To use images, please check ‘update()’ implementation in general_image-fetch.py example to adopt the recombination method.