Skip to content

Commit c96ea5a

Browse files
committed
add more docs to protobuf file
1 parent ab23f2d commit c96ea5a

File tree

3 files changed

+120
-87
lines changed

3 files changed

+120
-87
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,4 @@ src/thrift-generated/Game.cpp
4848
src/thrift-generated/Game.h
4949
src/thrift-generated/soccer_service_types.cpp
5050
src/thrift-generated/soccer_service_types.h
51+
idl/test.md

idl/generate-local-md.sh

100644100755
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@
1717
# # Move the binary to /usr/local/bin
1818
# sudo mv protoc-gen-doc /usr/local/bin/
1919

20-
protoc --doc_out=./test.md --doc_opt=markdown,readme.md ./grpc/service.proto
20+
protoc --doc_out=./ --doc_opt=markdown,test.md ./grpc/service.proto
2121

2222
VERSION=$(grep -oP '(?<=version\s)[0-9]+\.[0-9]+' ./grpc/service.proto)
23-
echo "VERSION=$VERSION" >> $GITHUB_ENV
23+
echo "VERSION=$VERSION"
2424

25-
sed -i '3a\\n## Version: '"${{ env.VERSION }}"'\n' ./readme.md
25+
sed -i '3a\\n## Version: '"$VERSION"'\n' ./test.md
2626

27-
sed -i 's/&gt;/>/g' ./readme.md
28-
sed -i 's/&lt;/</g' ./readme.md
27+
sed -i 's/&gt;/>/g' ./test.md
28+
sed -i 's/&lt;/</g' ./test.md

idl/grpc/service.proto

Lines changed: 114 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,28 @@ enum ViewWidth {
1414
WIDE = 2; // Wide view width (180 degrees).
1515
}
1616

17+
/**
18+
* RpcVector2D represents a 2D vector with additional properties.
19+
* If you want to have access to geometric operations, you can use Vector2D class in [pyrusgeom package](https://github.com/Cyrus2D/PyrusGeom)
20+
* To use this class, you need to install pyrusgeom package, import Vector2D class and create a Vector2D object with x and y values.
21+
*/
1722
message RpcVector2D {
18-
float x = 1;
19-
float y = 2;
20-
float dist = 3;
21-
float angle = 4;
23+
float x = 1; // The x-coordinate of the vector.
24+
float y = 2; // The y-coordinate of the vector.
25+
float dist = 3; // The distance magnitude of the vector.
26+
float angle = 4; // The angle of the vector in degrees. In soccer simulation 2D environment, the 0 degree is opponent's goal, and the angle increases in the counter-clock direction. So, if your team is in left side, -90 degree is up, 0 degree is right (opponent gole), 90 degree is down.
2227
}
2328

29+
/**
30+
* RegisterRequest is the message that the client sends to the server to register itself.
31+
* The client should send this message to the server to register itself.
32+
* The server will respond with a RegisterResponse message.
33+
*/
2434
message RegisterRequest {
25-
AgentType agent_type = 1;
26-
string team_name = 2;
27-
int32 uniform_number = 3;
28-
int32 rpc_version = 4;
35+
AgentType agent_type = 1; // The type of the agent. It can be PlayerT, CoachT, or TrainerT.
36+
string team_name = 2; // The name of the team that the agent belongs to.
37+
int32 uniform_number = 3; // The uniform number of the agent.
38+
int32 rpc_version = 4; // The version of the RPC protocol that the client supports.
2939
}
3040

3141
enum RpcServerLanguageType {
@@ -39,32 +49,40 @@ enum RpcServerLanguageType {
3949
GO = 7;
4050
}
4151

52+
/**
53+
* RegisterResponse is the message that the server sends to the client in response to a RegisterRequest message.
54+
* The server will respond with this message after receiving a RegisterRequest message.
55+
* The client should use the information in this message to identify itself to the server.
56+
*/
4257
message RegisterResponse {
43-
int32 client_id = 1;
44-
AgentType agent_type = 2;
45-
string team_name = 3;
46-
int32 uniform_number = 4;
47-
RpcServerLanguageType rpc_server_language_type = 5;
58+
int32 client_id = 1; // The unique identifier assigned to the client by the server.
59+
AgentType agent_type = 2; // The type of the agent. It can be PlayerT, CoachT, or TrainerT.
60+
string team_name = 3; // The name of the team that the agent belongs to.
61+
int32 uniform_number = 4; // The uniform number of the agent.
62+
RpcServerLanguageType rpc_server_language_type = 5; // The language that the server is implemented in.
4863
}
4964

65+
/**
66+
* Ball is the message that represents the ball in the soccer simulation.
67+
*/
5068
message Ball {
51-
RpcVector2D position = 1;
52-
RpcVector2D relative_position = 2;
53-
RpcVector2D seen_position = 3;
54-
RpcVector2D heard_position = 4;
55-
RpcVector2D velocity = 5;
56-
RpcVector2D seen_velocity = 6;
57-
RpcVector2D heard_velocity = 7;
58-
int32 pos_count = 8;
59-
int32 seen_pos_count = 9;
60-
int32 heard_pos_count = 10;
61-
int32 vel_count = 11;
62-
int32 seen_vel_count = 12;
63-
int32 heard_vel_count = 13;
64-
int32 lost_count = 14;
69+
RpcVector2D position = 1; // The position of the ball.
70+
RpcVector2D relative_position = 2; // The relative position of the ball to the agent who is sending the message.
71+
RpcVector2D seen_position = 3; // The position of the ball that the agent has seen.
72+
RpcVector2D heard_position = 4; // The position of the ball that the agent has heard.
73+
RpcVector2D velocity = 5; // The velocity of the ball.
74+
RpcVector2D seen_velocity = 6; // The velocity of the ball that the agent has seen.
75+
RpcVector2D heard_velocity = 7; // The velocity of the ball that the agent has heard.
76+
int32 pos_count = 8; // How many cycles ago the agent has seen or heard the ball.
77+
int32 seen_pos_count = 9; // How many cycles ago the agent has seen the ball.
78+
int32 heard_pos_count = 10; // How many cycles ago the agent has heard the ball.
79+
int32 vel_count = 11; // How many cycles ago the agent has seen or heard the velocity of the ball.
80+
int32 seen_vel_count = 12; // How many cycles ago the agent has seen the velocity of the ball.
81+
int32 heard_vel_count = 13; // How many cycles ago the agent has heard the velocity of the ball.
82+
int32 lost_count = 14; // How many cycles ago the agent has lost the ball.
6583
int32 ghost_count = 15;
66-
float dist_from_self = 16;
67-
float angle_from_self = 17;
84+
float dist_from_self = 16; // The distance of the ball from the agent who is sending the message.
85+
float angle_from_self = 17; // The angle of the ball from the agent who is sending the message.
6886
}
6987

7088
enum Side {
@@ -116,37 +134,41 @@ message PenaltyKickState {
116134
bool is_kick_taker = 7;
117135
}
118136

137+
/**
138+
* Player is the message that represents a player in the soccer simulation.
139+
* To get type information of the player, you can use the type_id field and player type information.
140+
*/
119141
message Player {
120-
RpcVector2D position = 1;
121-
RpcVector2D seen_position = 2;
122-
RpcVector2D heard_position = 3;
123-
RpcVector2D velocity = 4;
124-
RpcVector2D seen_velocity = 5;
125-
int32 pos_count = 6;
126-
int32 seen_pos_count = 7;
127-
int32 heard_pos_count = 8;
128-
int32 vel_count = 9;
129-
int32 seen_vel_count = 10;
130-
int32 ghost_count = 11;
131-
float dist_from_self = 12;
132-
float angle_from_self = 13;
133-
int32 id = 14;
134-
Side side = 15;
135-
int32 uniform_number = 16;
136-
int32 uniform_number_count = 17;
137-
bool is_goalie = 18;
138-
float body_direction = 19;
139-
int32 body_direction_count = 20;
140-
float face_direction = 21;
141-
int32 face_direction_count = 22;
142-
float point_to_direction = 23;
143-
int32 point_to_direction_count = 24;
144-
bool is_kicking = 25;
145-
float dist_from_ball = 26;
146-
float angle_from_ball = 27;
147-
int32 ball_reach_steps = 28;
148-
bool is_tackling = 29;
149-
int32 type_id = 30;
142+
RpcVector2D position = 1; // The position of the player.
143+
RpcVector2D seen_position = 2; // The position of the player that the agent has seen.
144+
RpcVector2D heard_position = 3; // The position of the player that the agent has heard.
145+
RpcVector2D velocity = 4; // The velocity of the player.
146+
RpcVector2D seen_velocity = 5; // The velocity of the player that the agent has seen.
147+
int32 pos_count = 6; // How many cycles ago the agent has seen or heard the player.
148+
int32 seen_pos_count = 7; // How many cycles ago the agent has seen the player.
149+
int32 heard_pos_count = 8; // How many cycles ago the agent has heard the player.
150+
int32 vel_count = 9; // How many cycles ago the agent has seen or heard the velocity of the player.
151+
int32 seen_vel_count = 10; // How many cycles ago the agent has seen the velocity of the player.
152+
int32 ghost_count = 11; // How many cycles ago the agent has lost the player.
153+
float dist_from_self = 12; // The distance of the player from the agent who is sending the message.
154+
float angle_from_self = 13; // The angle of the player from the agent who is sending the message.
155+
int32 id = 14; // The unique identifier of the player.
156+
Side side = 15; // The side of the player. It can be LEFT or RIGHT or UNKNOWN if the side is not known.
157+
int32 uniform_number = 16; // The uniform number of the player.
158+
int32 uniform_number_count = 17; // How many cycles ago the agent has seen the uniform number of the player.
159+
bool is_goalie = 18; // Whether the player is a goalie or not.
160+
float body_direction = 19; // The body direction of the player.
161+
int32 body_direction_count = 20; // How many cycles ago the agent has seen the body direction of the player.
162+
float face_direction = 21; // The face direction of the player. In soccer simulation 2D, face direction is the direction that the player is looking at.
163+
int32 face_direction_count = 22; // How many cycles ago the agent has seen the face direction of the player.
164+
float point_to_direction = 23; // The direction that the player is pointing to.
165+
int32 point_to_direction_count = 24; // How many cycles ago the agent has seen the point to direction of the player.
166+
bool is_kicking = 25; // Whether the player is kicking or not.
167+
float dist_from_ball = 26; // The distance of the player from the ball.
168+
float angle_from_ball = 27; // The angle of the player from the ball.
169+
int32 ball_reach_steps = 28; // How many cycles the player needs to reach the ball.
170+
bool is_tackling = 29; // Whether the player is tackling or not.
171+
int32 type_id = 30; // The type identifier of the player.
150172
}
151173

152174
message Self {
@@ -1320,29 +1342,39 @@ service Game {
13201342
/*
13211343
* The Game service provides various RPC methods for interacting with a soccer simulation.
13221344
*
1323-
* Methods:
1324-
* - GetPlayerActions(State): Retrieves actions available to a player based on the current state.
1325-
* - GetCoachActions(State): Retrieves actions available to a coach based on the current state.
1326-
* - GetTrainerActions(State): Retrieves actions available to a trainer based on the current state.
1327-
* - SendInitMessage(InitMessage): Sends an initialization message to the server.
1328-
* - SendServerParams(ServerParam): Sends server parameters to the server.
1329-
* - SendPlayerParams(PlayerParam): Sends player parameters to the server.
1330-
* - SendPlayerType(PlayerType): Sends player type information to the server. (Note: Should be PlayerTypes)
1331-
* - Register(RegisterRequest): Registers a new entity and returns a registration response.
1332-
* - SendByeCommand(RegisterResponse): Sends a bye command to the server.
1333-
* - GetBestPlannerAction(BestPlannerActionRequest): Retrieves the best planner action based on the request.
1334-
```mermaid
1335-
sequenceDiagram
1336-
participant Alice
1337-
participant Bob
1338-
Alice->>John: Hello John, how are you?
1339-
loop HealthCheck
1340-
John->>John: Fight against hypochondria
1341-
end
1342-
Note right of John: Rational thoughts <br/>prevail!
1343-
John-->>Alice: Great!
1344-
John->>Bob: How about you?
1345-
Bob-->>John: Jolly good!
1345+
```mermaid
1346+
sequenceDiagram
1347+
participant SS as SoccerSimulationServer
1348+
participant SP as SoccerSimulationProxy
1349+
participant PM as PlayMakerServer
1350+
Note over SS,PM: Run
1351+
SP->>SS: Connect
1352+
SS->>SP: OK, Unum
1353+
SS->>SP: ServerParam
1354+
SS->>SP: PlayerParam
1355+
SS->>SP: PlayerType (0)
1356+
SS->>SP: PlayerType (1)
1357+
SS->>SP: PlayerType (17)
1358+
SP->>PM: Register(RegisterRequest)
1359+
PM->>SP: RegisterResponse
1360+
SP->>PM: SendInitMessage(InitMessage)
1361+
PM->>SP: Empty
1362+
SP->>PM: SendServerParams(ServerParam)
1363+
PM->>SP: Empty
1364+
SP->>PM: SendPlayerParams(PlayerParam)
1365+
PM->>SP: Empty
1366+
SP->>PM: SendPlayerType(PlayerType(0))
1367+
PM->>SP: Empty
1368+
SP->>PM: SendPlayerType(PlayerType(1))
1369+
PM->>SP: Empty
1370+
SP->>PM: SendPlayerType(PlayerType(17))
1371+
PM->>SP: Empty
1372+
SS->>SP: Observation
1373+
Note over SP: Convert observation to State
1374+
SP->>PM: GetPlayerActions(State)
1375+
PM->>SP: PlayerActions
1376+
Note over SP: Convert Actions to Low-Level Commands
1377+
SP->>SS: Commands
13461378
```
13471379
*/
13481380

0 commit comments

Comments
 (0)