Skip to content

Commit 7004c6f

Browse files
committed
add proxy and sample thrift and fix some minor issues
1 parent 5804f1d commit 7004c6f

File tree

10 files changed

+367
-171
lines changed

10 files changed

+367
-171
lines changed

docs/0-introduction/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ Developing a base code for each language is a time-consuming task that requires
5454

5555
To overcome these challenges, the CLSFramework can denoise information, create models, and send them to the PlayMaker-Server. The PlayMaker-Server can be developed in any language supported by gRPC and is responsible for making decisions and sending actions to the SoccerSimulationProxy, which then sends the actions to the RCSSServer. This approach simplifies the development process and allows for more efficient implementation of the required functionalities.
5656

57-
## Work floW
57+
## Workflow
5858

5959
```mermaid
6060
sequenceDiagram
File renamed without changes.
Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
# Sample Python Base Code (Thrift)
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 Playmaker server written in Python using Thrift, designed to facilitate the development of a Soccer Simulation 2D team.
7+
8+
Traditionally, teams in the Soccer Simulation 2D league are implemented in C++ using existing base codes. Each agent in the team receives observations from the Soccer Simulation 2D server and sends actions back to it. However, with the Cross Language Soccer Framework (CLSF), we have enhanced the Helios base code([SoccerSimulationProxy](https://github.com/CLSFramework/soccer-simulation-proxy)) to interact with a Thrift/gRPC server(PlaymakerServer).
9+
10+
This server-based approach allows the simulation to send the necessary information for decision-making to a rpc server and receive the corresponding actions, which are then communicated back to the Soccer Simulation 2D server.
11+
12+
This flexibility enables you to develop your team in any programming language of your choice, breaking the constraints of C++.
13+
14+
This repository provides a sample server implemented in Python using Thrift. You can use this server as a starting point to develop and customize your own team.
15+
16+
Also, you can find some scripts to download the RCSSServer, SoccerSimulationProxy, and run the sample server and proxy. To use this framework, you need to have Ubuntu or WSL.
17+
18+
To learn more about the Cross Language Soccer Framework, visit the [official repository](https://github.com/CLSFramework/cross-language-soccer-framework/wiki)
19+
20+
![cls](https://github.com/user-attachments/assets/4daee216-1479-4acd-88f2-9e772b8c7837)
21+
22+
## Preparation
23+
24+
To run a Soccer Simulation 2D game using the CLSF, you need to have RCSSServer, SoccerSimulationProxy, and Monitor to visualize the game.
25+
26+
### RCSSServer
27+
To download the latest AppImage of the RCSSServer, you can run the following command:
28+
29+
```bash
30+
cd scripts
31+
./download-rcssserver.sh
32+
```
33+
34+
To run the RCSSServer AppImage, you need to install FUSE. You can install it by running the following command:
35+
36+
```bash
37+
sudo apt-get install fuse
38+
```
39+
40+
<u>Notes:</u>
41+
- You can build the RCSSServer from the source code. For more information, visit the [official repository](https://github.com/rcsoccersim/rcssserver).
42+
- The RCSSServer should be run on <u>Linux (preferably Ubuntu) or WSL</u>.
43+
44+
45+
46+
### SoccerSimulationProxy
47+
48+
To download the latest AppImage of the SoccerSimulationProxy, you can run the following command:
49+
50+
```bash
51+
cd scripts
52+
./download-proxy.sh
53+
```
54+
55+
To run the SoccerSimulationProxy AppImage, you need to install FUSE. You can install it by running the following command:
56+
57+
```bash
58+
sudo apt-get install fuse
59+
```
60+
61+
<u>Notes:</u>
62+
- You can build the SoccerSimulationProxy from the source code. For more information, visit the [official repository](https://github.com/CLSFramework/soccer-simulation-proxy)
63+
- The SoccerSimulationProxy should be run on <u>Linux (preferably Ubuntu) or WSL</u>.
64+
65+
### Monitor
66+
67+
To download the latest AppImage of the Monitor, you can download it from the [official repository](https://github.com/rcsoccersim/rcssmonitor/releases).
68+
69+
To run the monitor, you need to install FUSE. You can install it by running the following command:
70+
71+
```bash
72+
sudo apt-get install fuse
73+
```
74+
75+
### Create Python Virtual Environment and Install Dependencies
76+
77+
To create a Python virtual environment and install the dependencies, you can run the following commands:
78+
79+
```bash
80+
python3 -m venv venv
81+
source venv/bin/activate
82+
pip install -r requirements.txt
83+
./generate.sh # To generate thrift python files
84+
```
85+
86+
## Running a game
87+
88+
To run a game, you need to run the RCSSServer and then the SoccerSimulationProxy and the sample server. To visualize the game, you can run the Monitor.
89+
90+
### Running the RCSSServer
91+
If you have downloaded the RCSSServer AppImage, you can run it by running the following command:
92+
93+
```bash
94+
cd scripts/rcssserver
95+
./rcssserver
96+
```
97+
98+
Otherwise, you built and install the RCSSServer from the source code, you can run the server by running the following command:
99+
100+
```bash
101+
rcssserver
102+
```
103+
104+
## Running the Sample Server and Proxy
105+
106+
There are three different ways to run the sample server:
107+
108+
- Using start-team.py
109+
- Using start-team.sh
110+
- Running the server and client separately
111+
112+
### Using start-team.py (This script can be used in Ubuntu or WSL)
113+
114+
Note: To use this script you need to download the proxy by using `scripts/download-proxy.sh`.
115+
116+
Run the `start-team.py` script:
117+
118+
```bash
119+
python start-team.py
120+
```
121+
122+
You can pass the following arguments to the script:
123+
- `--team-name`: The name of the team (default: `CLSF`)
124+
- `--rpc-port`: The port number for the RPC server (default: `50051`)
125+
126+
### Using start-team.sh (This script can be used in Linux)
127+
128+
Note: To use this script you need to download the proxy by using `scripts/download-proxy.sh`.
129+
130+
Run the `start-team.sh` script:
131+
132+
```bash
133+
./start-team.sh
134+
```
135+
136+
You can pass the following arguments to the script:
137+
- `--team-name`: The name of the team (default: `CLSF`)
138+
- `--rpc-port`: The port number for the RPC server (default: `50051`)
139+
140+
### Running the server and client separately
141+
142+
(This method can be used in Windows and Linux, but the proxy can only be run in Linux)
143+
144+
To run the server, you can run the following command:
145+
146+
```bash
147+
python server.py
148+
```
149+
150+
You can pass the following arguments to the server:
151+
- `--rpc-port`: The port number for the RPC server (default: `50051`)
152+
153+
If you want to run the proxy agents, you can run the following command:
154+
155+
```bash
156+
cd scripts/proxy
157+
./start.sh
158+
```
159+
160+
To learn more about the Soccer Simulation Proxy, arguments you can pass, and how to run it, build it from source, visit the [official repository](https://github.com/CLSFramework/soccer-simulation-proxy)
161+
162+
#### Running the playmaker server in Windows (Not recommended)
163+
If you want to run the playmaker server in Windows, you need to somehow connect the proxy to the playmaker server. You can find ip of your local machine(Windows) and use it in the proxy.
164+
<u>Right now due to some issues with Python multiprocessing, the playmaker server can't be run in Windows.</u>
165+
166+
## How does it work?
167+
Berifly, the Soccer Simulation 2D server sends the observations to the proxy, which forwards them to the playmaker server. The playmaker server processes the observations and sends the actions back to the proxy, which forwards them to the Soccer Simulation 2D server.
168+
169+
## Citation
170+
171+
- [Cross Language Soccer Framework](https://arxiv.org/pdf/2406.05621)
172+
- Zare, N., Sayareh, A., Sadraii, A., Firouzkouhi, A. and Soares, A., 2024. Cross Language Soccer Framework: An Open Source Framework for the RoboCup 2D Soccer Simulation. arXiv preprint arXiv:2406.05621.
Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
# Soccer Simulation Proxy
2+
[![GitHub license](https://img.shields.io/github/license/helios-base/helios-base)](https://github.com/helios-base/helios-base/blob/master/LISENCE)
3+
4+
Developing a team can be complex due to the environment's intricacy, typically necessitating C++ programming. However, our framework allows for development in other languages by leveraging the [helios-base](https://github.com/helios-base/helios-base) features. By using **SoccerSimulationProxy**, you can develop a team in any language supported by **gRPC** or **Thrift**, such as **C#, C++, Dart, Go, Java, Kotlin, Node.js, Objective-C, PHP, Python, and Ruby**.
5+
6+
To use **gRPC**, you can check out our [gRPC server](https://github.com/CLSFramework/sample-playmaker-server-python-grpc), which is based on proto messages and gRPC services. This server provides a helpful base to get more familiar with the gRPC implementation.
7+
8+
To use **Thrift**, you can check out our [thrift server](https://github.com/CLSFramework/sample-playmaker-server-python-thrift), which is based on proto messages and thrift services. This server provides a helpful base to get more familiar with the thrift implementation.
9+
10+
This allows you to focus on developing your team's strategy and AI algorithms without worrying about the server's underlying complexity.
11+
12+
![image](https://github.com/user-attachments/assets/4daee216-1479-4acd-88f2-9e772b8c7837)
13+
14+
15+
If you would like to develop a team or conduct research using **Python**, **C#**, or **JavaScript**, you can check the following links:
16+
17+
- [Playmaker-Server-Python-grpc](https://github.com/CLSFramework/sample-playmaker-server-python-grpc)
18+
- [Playmaker-Server-Python-thrift](https://github.com/CLSFramework/sample-playmaker-server-python-thrift)
19+
- [Playmaker-Server-CSharp](https://github.com/CLSFramework/playmaker-server-csharp)
20+
- [Playmaker-Server-NodeJs](https://github.com/CLSFramework/playmaker-server-nodejs)
21+
22+
This new base code is powered by Helios-Base and gRPC, designed to assist researchers in developing a Soccer Simulation 2D team or conducting research in this area. It supports development in any language compatible with gRPC.
23+
## How To Use it?
24+
25+
To use this framework, follow the steps below in order:
26+
27+
### 1. Start the **rcssserver**
28+
The **rcssserver** hosts the game. You can follow the instructions for setting it up in the [soccersimulation server](./../5-soccersimulation/0-server/index.md).
29+
30+
### 2. Run the **Playmaker-Server**
31+
Next, run one of the sample Playmaker Servers, such as this [gRPC Server](https://github.com/CLSFramework/sample-playmaker-server-python-grpc), to receive information from the agents and send appropriate actions back to the game.
32+
33+
### 3. Set up the **Soccer Simulation Proxy**
34+
Now, run the **Soccer Simulation Proxy** to connect to the **rcssserver** and handle information exchange between agents and the server. You can do this using AppImage, Docker, or by building from source.
35+
36+
Here, we’ll explain how to run the Soccer Simulation Proxy using AppImage and build from the source.
37+
38+
### 1 - AppImage
39+
40+
#### 1. Download the AppImage
41+
You can download the AppImage from the [release page](https://github.com/CLSFramework/soccer-simulation-proxy/releases) or use the following command to download the latest version:
42+
```bash
43+
wget $(curl -s "https://api.github.com/repos/clsframework/soccer-simulation-proxy/releases/latest" | grep -oP '"browser_download_url": "\K[^"]*' | grep "soccer-simulation-proxy.tar.gz")
44+
```
45+
#### 2. Extract the AppImage
46+
After downloading, extract the tar.gz file:
47+
```bash
48+
tar -xvf soccer-simulation-proxy.tar.gz
49+
```
50+
#### 3. Run the Proxy
51+
After downloading, you can run the proxy:
52+
```bash
53+
cd SoccerSimulationProxy
54+
./start.sh
55+
```
56+
If you want to connect the proxy to a grpc server change this parameter to `grpc` in start.sh file.
57+
```bash
58+
rpc_type="thrift"
59+
```
60+
#### 4. Watch the Game
61+
To watch the game, you can use either of the following:
62+
63+
- **[rcssmonitor](https://github.com/rcsoccersim/rcssmonitor)**: A tool to visualize the game.
64+
- **[SoccerWindow2](https://github.com/helios-base/soccerwindow2)**: Another visualization tool for RoboCup Soccer Simulation.
65+
66+
For instructions on how to run **rcssmonitor**, check the [Soccer Simulation Monitor Wiki](https://github.com/CLSFramework/cross-language-soccer-framework/wiki/Soccer-Simulation-Monitor).
67+
68+
![Screenshot 2024-04-07 012226](https://github.com/Cyrus2D/SoccerSimulationProxy/assets/25696836/abb24e0c-61b9-497d-926f-941d1c90e2ee)
69+
70+
71+
72+
### 2 - Build from source, install, and run (Linux, WSL)
73+
74+
To build the soccer simulation proxy, you need to install the following dependencies:
75+
76+
#### 1. LibRCSC
77+
78+
```bash
79+
git clone git@github.com:helios-base/librcsc.git
80+
cd librcsc
81+
git checkout 19175f339dcb5c3f61b56a8c1bff5345109f22ef
82+
mkdir build
83+
cd build
84+
cmake ..
85+
make
86+
make install
87+
```
88+
89+
#### 2. gRPC - follow the instructions provided in the [repository](https://grpc.io/docs/languages/cpp/quickstart/)
90+
91+
```bash
92+
export MY_INSTALL_DIR=$HOME/.local
93+
mkdir -p $MY_INSTALL_DIR
94+
export PATH="$MY_INSTALL_DIR/bin:$PATH"
95+
sudo apt install -y build-essential autoconf libtool pkg-config
96+
git clone --recurse-submodules -b v1.62.0 --depth 1 --shallow-submodules https://github.com/grpc/grpc
97+
cd grpc/
98+
mkdir -p cmake/build
99+
pushd cmake/build
100+
cmake -DgRPC_INSTALL=ON -DgRPC_BUILD_TESTS=OFF -DCMAKE_INSTALL_PREFIX=$MY_INSTALL_DIR ../..
101+
make -j 4
102+
make install
103+
```
104+
105+
then, add the following lines at the end of $HOME/.bashrc
106+
107+
```bash
108+
export MY_INSTALL_DIR=$HOME/.local
109+
export PATH="$MY_INSTALL_DIR/bin:$PATH"
110+
```
111+
112+
then, run the following command
113+
114+
```bash
115+
source $HOME/.bashrc
116+
```
117+
118+
To test grpc, go to grpc directory (in this example it is in $HOME/grpc) and run the following commands:
119+
120+
```bash
121+
cd examples/cpp/helloworld
122+
mkdir -p cmake/build
123+
cd cmake/build/
124+
cmake -DCMAKE_PREFIX_PATH=$MY_INSTALL_DIR ../..
125+
make
126+
run ./greeter_server in one tab
127+
run ./greeter_client in another tab
128+
```
129+
130+
#### 3. SoccerSimulationProxy
131+
132+
```bash
133+
git clone git@github.com:CLSFramework/soccer-simulation-proxy.git
134+
cd soccer-simulation-proxy
135+
mkdir build
136+
cd build
137+
cmake ..
138+
make
139+
```
140+
141+
142+
#### 4. Run Soccer Simulation Proxy
143+
144+
To run the Soccer Simulation Proxy, you can use the following command: (You should run the Soccer Simulation Server and a PlayMaker Server before running the Soccer Simulation Proxy)
145+
146+
```bash
147+
cd build/bin
148+
./start.sh
149+
```
150+
151+
To run the Soccer Simulation Proxy in debug mode, you can use the following command:
152+
153+
```bash
154+
cd build/bin
155+
./start-debug.sh
156+
```
157+
158+
#### 5. Watch the Game
159+
To watch the game, you can use either of the following:
160+
161+
- **[rcssmonitor](https://github.com/rcsoccersim/rcssmonitor)**: A tool to visualize the game.
162+
- **[SoccerWindow2](https://github.com/helios-base/soccerwindow2)**: Another visualization tool for RoboCup Soccer Simulation.
163+
164+
For instructions on how to run **rcssmonitor**, check the [rcssmonitor](/docs/5-soccersimulation/1-monitor/index.md) or [soccer window 2](/docs/5-soccersimulation/2-soccerwindow/index.md).
165+
166+
![Screenshot 2024-04-07 012226](https://github.com/Cyrus2D/SoccerSimulationProxy/assets/25696836/abb24e0c-61b9-497d-926f-941d1c90e2ee)
167+
168+
169+
170+
171+
## References
172+
173+
The paper about HELIOS Base:
174+
- Hidehisa Akiyama, Tomoharu Nakashima, HELIOS Base: An Open Source
175+
Package for the RoboCup Soccer 2D Simulation, In Sven Behnke, Manuela
176+
Veloso, Arnoud Visser, and Rong Xiong editors, RoboCup2013: Robot
177+
World XVII, Lecture Notes in Artificial Intelligence, Springer Verlag,
178+
Berlin, 2014. http://dx.doi.org/10.1007/978-3-662-44468-9_46
179+
180+
# Citation
181+
182+
- [Cross Language Soccer Framework](https://arxiv.org/pdf/2406.05621)
183+
- Zare, N., Sayareh, A., Sadraii, A., Firouzkouhi, A. and Soares, A., 2024. Cross Language Soccer Framework: An Open Source Framework for the RoboCup 2D Soccer Simulation. arXiv preprint arXiv:2406.05621.
184+
185+
186+
187+

docs/4-proxy/develop-playmaker.md renamed to docs/4-Proxy/1-develop-other-playmaker/index.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
---
2-
sidebar_position: 4
3-
---
4-
51
# Develop a New Playmaker Server
62

73
To develop a Playmaker server, you need to creat a gRPC or Thrift server that receives data from the Soccer Simulation Proxy and sends actions back to it. This way, you can focus on developing your team's strategy and AI algorithms without worrying about the server's complexity.

0 commit comments

Comments
 (0)