|
1 |
| -# Quick start |
2 |
| -## Installation |
| 1 | +# CLSF Sample Python Base Code (gRPC) |
| 2 | + |
| 3 | +[](https://clsframework.github.io/docs/introduction/) |
| 4 | +[](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 Python. This server is compatible with the [Cross Language Soccer Framework](https://arxiv.org/pdf/2406.05621). This server is written in Python 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 | +## Quick start |
| 13 | + |
| 14 | +### Preparation |
| 15 | + |
3 | 16 | Install the pre-requisites using the command below:
|
| 17 | + |
4 | 18 | ``` Bash
|
5 | 19 | sudo apt-get install fuse #Used to run AppImages
|
6 | 20 | ```
|
| 21 | + |
7 | 22 | Clone this repository & install the required python libraries (such as gRPC). Don't forget to activate your virtual environment!
|
| 23 | + |
8 | 24 | ``` Bash
|
9 | 25 | git clone https://github.com/CLSFramework/sample-playmaker-server-python-grpc.git
|
10 | 26 | cd sample-playmaker-server-python-grpc
|
11 | 27 | # Activate venv/anaconda before this step!
|
12 | 28 | pip install -r requirements.txt
|
| 29 | + |
| 30 | +./generate.sh # Generate the gRPC files |
13 | 31 | ```
|
14 |
| -To download RoboCup Soccer 2D Platform using the commands below: |
| 32 | + |
| 33 | +To download RoboCup Soccer 2D Server using the commands below: |
| 34 | + |
15 | 35 | ``` Bash
|
16 | 36 | pushd scripts
|
17 |
| -sh download-rcssserver.sh #install RoboCup Server |
| 37 | +sh download-rcssserver.sh # Download the soccer simulation server |
18 | 38 | popd
|
19 | 39 | ```
|
20 |
| -Next, install the soccer proxy, which uses C++ to read and pre-processes state data and passes them to the Python server (this project) for decision-making. |
| 40 | + |
| 41 | +Next, download the soccer proxy, which uses C++ to read and pre-processes state data and passes them to the Python server (this project) for decision-making. |
| 42 | + |
21 | 43 | ``` Bash
|
22 | 44 | pushd scripts
|
23 | 45 | sh download-proxy.sh #install C++ proxy
|
24 | 46 | popd
|
25 | 47 | ```
|
26 |
| -Finally, download the monitor from [the original repository](https://github.com/rcsoccersim/rcssmonitor/releases) in order to view the games. |
27 |
| -## Running a game |
| 48 | + |
| 49 | +Finally, to watch the game, download the monitor from [the original repository](https://github.com/rcsoccersim/rcssmonitor/releases) in order to view the games. |
| 50 | + |
| 51 | +### Running a game |
| 52 | + |
28 | 53 | This section assumes you have installed the server & proxy using the scripts (as mentioned above)
|
29 | 54 | We must first run a RoboCup Server, in order to host the game:
|
| 55 | + |
30 | 56 | ``` Bash
|
31 | 57 | cd scripts/rcssserver
|
32 | 58 | ./rcssserver
|
33 | 59 | ```
|
| 60 | + |
34 | 61 | Then we must run the proxy & the decisionmaking server:
|
| 62 | + |
35 | 63 | ``` Bash
|
36 | 64 | ./start-team.sh
|
37 | 65 | ```
|
| 66 | + |
38 | 67 | 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!
|
39 | 68 |
|
40 |
| -# How to change the code |
| 69 | +## How to change the code |
| 70 | + |
41 | 71 | The `server.py` file contains the logic in 3 main functions:
|
42 | 72 | `GetPlayerActions` receives a game state, and returns a list of actions for a player for for that cycle.
|
43 |
| -The actions we can output are equivalent to the Helios Base, which are abstracted into multiple levels. |
44 |
| -You can use actions such as `DoDash`, `DoTurn`, `DoKick` which directly apply force, or use actions such as `GoToPoint`, `SmartKick`, `Shoot` or more. |
| 73 | +The actions we can output are equivalent to the Helios Base (Proxy), which are abstracted into multiple levels. |
| 74 | +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/). |
45 | 75 |
|
46 | 76 | Similarly, you can change `GetCoachActions` which is responsible for coach communication & substitutions.
|
47 | 77 |
|
48 | 78 | You can also use `GetTrainerActions` to move the players & the ball to make repeatable scenarios (when the server is in trainer mode).
|
49 |
| -# Why & How it works |
| 79 | + |
| 80 | +## Why & How it works |
| 81 | + |
50 | 82 | 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.
|
51 | 83 | Due to the popularity of python in Machine Learning & AI spaces we decided to create a python platform which would be equivalent to Agent 2D.
|
52 | 84 | However, using python alone was too slow as preprocessing sensor information & tasks such as localization took too long.
|
53 | 85 |
|
54 | 86 | For this reason we have split up the code into two segments:
|
55 | 87 | The data processing section in proxy, which creates a World Model (state), and passes it to python 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.
|
56 | 88 |
|
| 89 | +```mermaid |
| 90 | +sequenceDiagram |
| 91 | + participant SS as SoccerSimulationServer |
| 92 | + participant SP as SoccerSimulationProxy |
| 93 | + participant PM as PlayMakerServer |
| 94 | + Note over SS,PM: Run |
| 95 | + SP->>SS: Connect |
| 96 | + SS->>SP: OK, Unum |
| 97 | + SP->>PM: Register |
| 98 | + PM->>SP: OK, ClientID |
| 99 | + SS->>SP: Observation |
| 100 | + Note over SP: Convert observation to State |
| 101 | + SP->>PM: State |
| 102 | + PM->>SP: Actions |
| 103 | + Note over SP: Convert Actions to Low-Level Commands |
| 104 | + SP->>SS: Commands |
| 105 | +``` |
| 106 | + |
57 | 107 | 
|
58 | 108 | 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.
|
59 | 109 |
|
60 |
| -# Configuration |
61 |
| -## RoboCup Server configuration |
| 110 | +## Configuration |
| 111 | + |
| 112 | +### RoboCup Server configuration |
| 113 | + |
62 | 114 | 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.
|
63 | 115 |
|
64 |
| -## Modifying Proxy & Running proxy and server seperately |
| 116 | +### Modifying Proxy & Running proxy and server seperately |
| 117 | + |
65 | 118 | 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 `python3 server.py` in this repo's directory. It is highly recommended to launch the python server before the proxy.
|
66 | 119 |
|
67 |
| -You can modify the rpc port by adding the argument `--rpc-port [VALUE]`, where the default is 50051. |
| 120 | +You can modify the rpc port by adding the argument `--rpc-port [VALUE]`, where the default is 50051. |
68 | 121 |
|
69 |
| -# Citation |
| 122 | +## Citation |
70 | 123 |
|
71 | 124 | - [Cross Language Soccer Framework](https://arxiv.org/pdf/2406.05621)
|
72 | 125 | - 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.
|
0 commit comments