Skip to content

Commit 68e3955

Browse files
authored
Merge pull request #23 from CLSFramework/develop_sadra
Update documentation structure and content, adjust sidebar positions,…
2 parents ed90445 + 315a2c9 commit 68e3955

File tree

9 files changed

+206
-27
lines changed

9 files changed

+206
-27
lines changed
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
# Sample Go Base Code (gRPC)
2+
3+
[![Documentation Status](https://readthedocs.org/projects/clsframework/badge/?version=latest)](https://clsframework.github.io/docs/introduction/)
4+
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5+
6+
This repository contains a sample decision-making server for the RoboCup 2D Soccer Simulation, which allows you to create a team by using Go. This server is compatible with the [Cross Language Soccer Framework](https://arxiv.org/pdf/2406.05621). This server is written in Golang and uses gRPC to communicate with the [proxy](https://github.com/CLSFramework/soccer-simulation-proxy).
7+
8+
The Soccer Simulation Server sends the observations to the proxy, which processes the data, create state message and sends it to the decision-making server. The decision-making server then sends the actions to the proxy, and then the proxy convert actions to the server commands and sends them to the server.
9+
10+
For more information, please refer to the [documentation](https://clsframework.github.io/).
11+
12+
You can find more information about the services and messages in the [IDL section](../../3-idl/protobuf.md).
13+
14+
## Quick start
15+
16+
### Preparation
17+
18+
Install the pre-requisites using the command below:
19+
20+
``` Bash
21+
sudo apt-get install fuse #Used to run AppImages
22+
```
23+
24+
Clone this repository & install the required Golang libraries (such as gRPC). Don't forget to activate your virtual environment!
25+
26+
``` Bash
27+
git clone #add repo link
28+
cd sample-playmaker-server-go-grpc
29+
30+
go mod tidy # Install the required Golang libraries
31+
32+
33+
./generate.sh # Generate the gRPC files
34+
```
35+
36+
To download RoboCup Soccer 2D Server using the commands below:
37+
38+
``` Bash
39+
pushd scripts
40+
sh download-rcssserver.sh # Download the soccer simulation server
41+
popd
42+
```
43+
44+
Next, download the soccer proxy, which uses C++ to read and pre-processes state data and passes them to the Golang server (this project) for decision-making.
45+
46+
``` Bash
47+
pushd scripts
48+
sh download-proxy.sh #install C++ proxy
49+
popd
50+
```
51+
52+
Finally, to watch the game, download the monitor from [the original repository](https://github.com/rcsoccersim/rcssmonitor/releases) in order to view the games.
53+
54+
### Running a game
55+
56+
This section assumes you have installed the server & proxy using the scripts (as mentioned above)
57+
We must first run a RoboCup Server, in order to host the game:
58+
59+
``` Bash
60+
cd scripts/rcssserver
61+
./rcssserver
62+
```
63+
64+
Then we must run the proxy & the decisionmaking server:
65+
66+
``` Bash
67+
./start-team.sh
68+
```
69+
70+
### Options
71+
72+
- `-t team_name`: Specify the team name.
73+
- `--rpc-port PORT`: Specify the RPC port (default: 50051).
74+
- `-d`: Enable debug mode.
75+
76+
77+
Launch the opponent team, start the monitor app image. press <kbd>Ctrl</kbd> + <kbd>C</kbd> to connect to the server, and <kbd>Ctrl</kbd> + <kbd>K</kbd> for kick-off!
78+
79+
### Tutorial Video (English)
80+
81+
[![IMAGE ALT TEXT HERE](https://img.youtube.com/vi/hH-5rkhiQHg/0.jpg)](https://www.youtube.com/watch?v=hH-5rkhiQHg)
82+
83+
### Tutorial Video (Persian)
84+
85+
[![IMAGE ALT TEXT HERE](https://img.youtube.com/vi/97YDEumcVWU/0.jpg)](https://www.youtube.com/watch?v=97YDEumcVWU&t=0s)
86+
87+
## How to change the code
88+
89+
The `server.go` file contains the logic in 3 main functions:
90+
`GetPlayerActions` receives a game state, and returns a list of actions for a player for for that cycle.
91+
The actions we can output are equivalent to the Helios Base (Proxy), which are abstracted into multiple levels.
92+
You can use actions such as `DoDash`, `DoTurn`, `DoKick` which directly apply force, or use actions such as `GoToPoint`, `SmartKick`, `Shoot` or [more](https://clsframework.github.io/docs/idl/).
93+
94+
Similarly, you can change `GetCoachActions` which is responsible for coach communication & substitutions.
95+
96+
You can also use `GetTrainerActions` to move the players & the ball to make repeatable scenarios (when the server is in trainer mode).
97+
98+
## Why & How it works
99+
100+
Originally the RoboCup 2D Soccer Simulation teams used C++, as the main code base (Agent2D aka Helios Base) was written in this language due to its performance.
101+
Due to the popularity of Golang we decided to create a Golang platform which would be equivalent to Agent 2D.
102+
However, using Golang alone was too slow as preprocessing sensor information & tasks such as localization took too long.
103+
104+
For this reason we have split up the code into two segments:
105+
The data processing section in proxy, which creates a World Model (state), and passes it to Golang for planning to occur. This repository uses gRPC to pass along the World Model, but there is a sister-repo which is compatible with thrift.
106+
107+
```mermaid
108+
sequenceDiagram
109+
participant SS as SoccerSimulationServer
110+
participant SP as SoccerSimulationProxy
111+
participant PM as PlayMakerServer
112+
Note over SS,PM: Run
113+
SP->>SS: Connect
114+
SS->>SP: OK, Unum
115+
SP->>PM: Register
116+
PM->>SP: OK, ClientID
117+
SS->>SP: Observation
118+
Note over SP: Convert observation to State
119+
SP->>PM: State
120+
PM->>SP: Actions
121+
Note over SP: Convert Actions to Low-Level Commands
122+
SP->>SS: Commands
123+
```
124+
125+
![cls](https://github.com/user-attachments/assets/4daee216-1479-4acd-88f2-9e772b8c7837)
126+
As seen in the figure, the proxy handles connecting to the server, receiving sensor information and creating a world-model, and finds the action to take via a remote procedure call to a decision-making server, which is this repository.
127+
128+
## Configuration
129+
130+
### RoboCup Server configuration
131+
132+
You can change the configuration of the RoboCup server and change parameters such as players' stamina, game length, field length, etc. by modifying `~/.rcssserver/server.conf`. Refer to the server's documents and repo for a more detailed guide.
133+
134+
### Modifying Proxy & Running proxy and server seperately
135+
136+
If you want to modify the algorithms of the base (such as ball interception, shooting, localization, etc.) you must modify the code of the [proxy repo](https://github.com/CLSFramework/soccer-simulation-proxy). After re-building from source, you can run the proxy by using `./start.sh --rpc-type grpc` in the bin folder of the proxy, and run the gRPC server with `go run server.go` in this repo's directory. It is highly recommended to launch the Golang server before the proxy.
137+
138+
You can modify the rpc port by adding the argument `--rpc-port [VALUE]`, where the default is 50051.
139+
140+
## Citation
141+
142+
- [Cross Language Soccer Framework](https://arxiv.org/pdf/2406.05621)
143+
- Zare, N., Sayareh, A., Sadraii, A., Firouzkouhi, A. and Soares, A., 2024. Cross Language Soccer Framework

docs/2-sampleserver/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Playmaker servers are the decision-making servers that control the agents in the
1212
- Sample Playmaker Servers in Python by using Thrift [GitHub](https://github.com/CLSFramework/sample-playmaker-server-python-thrift)
1313
- Sample Playmaker Servers in C# by using gRPC [GitHub](https://github.com/CLSFramework/playmaker-server-csharp)
1414
- Sample Playmaker Servers in NodeJs by using gRPC [GitHub](https://github.com/CLSFramework/playmaker-server-nodejs)
15+
- Sample Playmaker Servers in Go by using gRPC [GitHub](https://github.com/CLSFramework/sample-playmaker-server-go-gRPC)
1516

1617
## Base Code
1718

docs/3-idl/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
---
2-
sidebar_position: 3
2+
sidebar_position: 4
33
title: IDL
44
---

docs/4-proxy/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
sidebar_position: 4
2+
sidebar_position: 5
33
title: Soccer Simulation Proxy
44
---
55
# Soccer Simulation Proxy

docs/5-soccersimulation/index.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
---
2-
sidebar_position: 5
2+
sidebar_position: 6
33
title: Soccer Simulation
44
---
55

6+
To use the **CLSFramework**, you need two additional components:
7+
8+
- **Soccer Simulation Server**
9+
- This is the core server [`rcssserver`](/docs/5-soccersimulation/0-server/index.md) that connects the agents and runs the simulation.
10+
11+
- **Monitor**
12+
- A monitor is used to visualize the game. You can use either[`rcssmonitor`](/docs/5-soccersimulation/1-monitor/index.md) or [`soccerwindow2`](/docs/5-soccersimulation/2-soccerwindow/index.md) for this purpose.

docs/6-basecode/index.md

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,11 @@
11
---
2-
sidebar_position: 2
2+
sidebar_position: 3
33
title: Base Codes
44
---
55

6-
In this section, we will cover the Playmaker servers.
7-
Playmaker servers are the decision-making servers that control the agents in the RoboCup Soccer 2D simulation environment. You can choose one of the sample servers provided in this documentation or create your own server [from scratch](/docs/proxy/develop-playmaker).
8-
9-
## Sample Playmaker Servers
10-
11-
- Sample Playmaker Servers in Python by using gRPC [GitHub](https://github.com/CLSFramework/sample-playmaker-server-python-grpc) [Docs](/docs/sampleserver/sample-python-base-code-gRPC/)
12-
- Sample Playmaker Servers in Python by using Thrift [GitHub](https://github.com/CLSFramework/sample-playmaker-server-python-thrift)
13-
- Sample Playmaker Servers in C# by using gRPC [GitHub](https://github.com/CLSFramework/playmaker-server-csharp)
14-
- Sample Playmaker Servers in NodeJs by using gRPC [GitHub](https://github.com/CLSFramework/playmaker-server-nodejs)
6+
In this section, we will cover the Base Codes that developed by the CLSFramework.
157

168
## Base Code
179

10+
- PY2D Base Code in Python by using gRPC [GitHub](https://github.com/CLSFramework/py2d)
1811
- Starter Base Code in Python by using Thrift [GitHub](https://github.com/CLSFramework/starter-playmaker-server-python-thrift)

docs/6-sampleteam/index.md

Lines changed: 0 additions & 11 deletions
This file was deleted.

docs/ToturialVideos/index.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
---
2-
sidebar_position: 6
2+
sidebar_position: 7
33
title: Tutorial Videos
44
---
55

6+
In this section, we will cover the tutorial videos that developed for the CLSFramework.
7+
8+
## Tutorial Videos
9+
There are 2 languages available for the tutorial videos. You can watch the tutorial videos in [English](/docs/ToturialVideos/english.md) or [Persian](/docs/ToturialVideos/persian.md).

docusaurus.config.ts

100644100755
Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,52 @@ const config: Config = {
7373
},
7474
items: [
7575
{
76-
type: 'docSidebar',
77-
sidebarId: 'tutorialSidebar',
76+
type: 'dropdown',
77+
to: 'docs/introduction/',
7878
position: 'left',
7979
label: 'Tutorial',
80+
items: [
81+
{
82+
type: 'doc',
83+
docId: 'introduction/index',
84+
label: 'Introduction',
85+
},
86+
{
87+
type: 'doc',
88+
docId: 'definitions/index',
89+
label: 'Defenitions',
90+
},
91+
{
92+
type: 'doc',
93+
docId: 'sampleserver/index',
94+
label: 'Playmaker Server',
95+
},
96+
{
97+
type: 'doc',
98+
docId: "basecode/index",
99+
label: 'Base Code',
100+
},
101+
{
102+
type: 'doc',
103+
docId: 'idl/index',
104+
label: 'IDL',
105+
},
106+
{
107+
type: 'doc',
108+
docId: 'proxy/index',
109+
label: 'Soccer Simulation Proxy',
110+
},
111+
{
112+
type: 'doc',
113+
docId: 'soccersimulation/index',
114+
label: 'Soccer Simulation',
115+
},
116+
{
117+
type: 'doc',
118+
docId: 'ToturialVideos/index',
119+
label: 'Tutorial Videos',
120+
},
121+
]
80122
},
81123
{to: '/blog', label: 'Blog', position: 'left'},
82124
{to: '/release', label: 'Release', position: 'left'},

0 commit comments

Comments
 (0)