Skip to content

Commit 64500a1

Browse files
authored
Merge pull request #16 from CLSFramework/update-README-py2d-3830
Update py2d documentation
2 parents 0e01e3c + b0cc556 commit 64500a1

File tree

1 file changed

+91
-29
lines changed

1 file changed

+91
-29
lines changed

docs/6-basecode/py2d/index.md

Lines changed: 91 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ custom_edit_url: 'https://github.com/CLSFramework/py2d/blob/main/README.md'
44

55
# PY2D Base Code
66

7-
87
[![Documentation Status](https://readthedocs.org/projects/clsframework/badge/?version=latest)](https://clsframework.github.io/docs/introduction/)
98
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
109

1110
![alt text](image.png)
11+
1212
PY2D Soccer Simulation Base Code is a base code for RoboCup 2D Soccer Simulation teams, which is written in Python.
1313
This base code is powered by the [Cross Language Soccer Framework](https://arxiv.org/pdf/2406.05621), which allows you to create a team by using any programming language that supports gRPC or Thrift.
1414
This base code uses `Helios Base` as a proxy to communicate with the RoboCup 2D Soccer Simulation server.
@@ -18,14 +18,16 @@ For more information, please refer to the [documentation](https://clsframework.g
1818

1919
You can find more information about the services and messages in the [IDL section](../../3-idl/protobuf.md).
2020

21+
there are many different ways to run the base code, in the next section, we will explain the easiest way to run the base code.
22+
2123
## Quick start
2224

2325
### Preparation
2426

2527
Install the pre-requisites using the command below:
2628

2729
``` Bash
28-
sudo apt-get install fuse #Used to run AppImages
30+
sudo apt-get install fuse #Used to run AppImages (Proxy, Monitor and RoboCup Server)
2931
```
3032

3133
Clone this repository & install the required python libraries (such as gRPC). Don't forget to activate your virtual environment!
@@ -59,49 +61,102 @@ Finally, to watch the game, download the monitor from [the original repository](
5961

6062
### Running a game
6163

62-
This section assumes you have installed the server & proxy using the scripts (as mentioned above)
64+
This section assumes you have installed the server & proxy using the scripts (as mentioned above).
65+
66+
To run a game, you must first run the RoboCup Soccer Server, then your team and opponent team, and finally the monitor.
67+
6368
We must first run a RoboCup Server, in order to host the game:
6469

70+
| Running the RoboCup Soccer Server
71+
6572
``` Bash
6673
cd scripts/rcssserver
6774
./rcssserver
6875
```
6976

70-
Then we must run the proxy & the decisionmaking server:
77+
| Running your team
78+
79+
We must run the proxy, and rpc server, you can run `start.py` or `start.sh` to run both the proxy and the server.
7180

7281
``` Bash
73-
./start.sh
74-
// or
7582
python3 start.py
83+
// or
84+
./start.sh
7685
```
7786

78-
### Options
87+
This script, by default, will run a gRPC server on port 50051, and 12 proxy agents (11 players and 1 coach). In each cycle of the game, the soccer server sends the state of the game to the proxy, which processes the state, creates state message and sends it to the rpc server. The rpc server receives the state message, processes it, and sends the actions to the proxy. The proxy receives the actions, processes them, and sends the commands to the soccer server.
7988

80-
- `-t team_name`: Specify the team name.
81-
- `--rpc-port PORT`: Specify the RPC port (default: 50051).
82-
- `-d`: Enable debug mode.
89+
| Running the opponent team
8390

91+
You can download an opponent team binary from the [RoboCup Soccer Simulation Repository](https://archive.robocup.info/Soccer/Simulation/2D/binaries/RoboCup/) for example `CYRUS` team from [here](https://archive.robocup.info/Soccer/Simulation/2D/binaries/RoboCup/2023/Day4/CYRUS_SS2D_RC2023_D4_BIN.tar.gz). After extracting the binary, you can run the team using the command below:
8492

85-
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!
93+
``` Bash
94+
cd CYRUS_SS2D_RC2023_D4_BIN/bin
95+
./start.sh
96+
```
8697

87-
### Tutorial Video (English)
98+
| Running the monitor
8899

89-
[![IMAGE ALT TEXT HERE](https://img.youtube.com/vi/hH-5rkhiQHg/0.jpg)](https://www.youtube.com/watch?v=hH-5rkhiQHg)
100+
To watch the game, you must run the rcssmonitor or soccerwindow2. press <kbd>Ctrl</kbd> + <kbd>C</kbd> to connect to the server, and <kbd>Ctrl</kbd> + <kbd>K</kbd> for kick-off!
90101

91-
### Tutorial Video (Persian)
102+
### start.py Arguments
92103

93-
[![IMAGE ALT TEXT HERE](https://img.youtube.com/vi/97YDEumcVWU/0.jpg)](https://www.youtube.com/watch?v=97YDEumcVWU&t=0s)
104+
##### Team and Name Customization
94105

95-
## How to change the code
106+
| Argument | Short | Description | Default Value |
107+
|---------------------------|-------|------------------------------------------------------------------|-----------------|
108+
| `--team_name` | `-t` | The name of the team. | `CLS` |
109+
| `--use-random-name` | | Use a randomly generated team name. | `False` |
96110

97-
The `server.py` file contains the logic in 3 main functions:
98-
`GetPlayerActions` receives a game state, and returns a list of actions for a player for for that cycle.
99-
The actions we can output are equivalent to the Helios Base (Proxy), which are abstracted into multiple levels.
100-
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/).
111+
---
112+
113+
##### RPC Server Configuration
114+
115+
| Argument | Short | Description | Default Value |
116+
|---------------------------|-------|------------------------------------------------------------------|-----------------|
117+
| `--rpc-port` | | The port used by the RPC server. | `50051` |
118+
| `--use-random-rpc-port` | | Use a randomly assigned port for the RPC server. | `False` |
119+
| `--use-different-rpc-port`| | Use a different port for the RPC server (useful for multi-server setups). By using this option, the script will run a rpc server for each agents| `False` |
120+
| `--auto-close-rpc-server` | | Automatically close the RPC server after finishing agent processing. | `False` |
121+
122+
---
101123

102-
Similarly, you can change `GetCoachActions` which is responsible for coach communication & substitutions.
124+
##### RoboCup Soccer Server Configuration
103125

104-
You can also use `GetTrainerActions` to move the players & the ball to make repeatable scenarios (when the server is in trainer mode).
126+
| Argument | Short | Description | Default Value |
127+
|---------------------------|-------|------------------------------------------------------------------|-----------------|
128+
| `--server-host` | | The host of the RoboCup Soccer server. | `localhost` |
129+
| `--server-port` | | The port of the RoboCup Soccer server. | `6000` |
130+
131+
---
132+
133+
##### Agent Proxies
134+
135+
| Argument | Short | Description | Default Value |
136+
|---------------------------|-------|------------------------------------------------------------------|-----------------|
137+
| `--player` | | Run a proxy for a single player agent. | `False` |
138+
| `--coach` | | Run a proxy for a single coach agent. | `False` |
139+
| `--goalie` | | Run a proxy for a single goalie agent. | `False` |
140+
| `--debug` | `-d` | Enable debug mode for the agents. | `False` |
141+
142+
---
143+
144+
##### Debug and Logging Options
145+
146+
| Argument | Short | Description | Default Value |
147+
|---------------------------|-------|------------------------------------------------------------------|-----------------|
148+
| `--disable-log-file` | | Disable logging to a file. | `False` |
149+
| `--log-dir` | | The directory where logs are stored. If not provided, logs are stored in the default directory with a timestamp. | `None` |
150+
151+
---
152+
153+
### CLSF Tutorial Video (English)
154+
155+
[![IMAGE ALT TEXT HERE](https://img.youtube.com/vi/hH-5rkhiQHg/0.jpg)](https://www.youtube.com/watch?v=hH-5rkhiQHg)
156+
157+
### CLSF Tutorial Video (Persian)
158+
159+
[![IMAGE ALT TEXT HERE](https://img.youtube.com/vi/97YDEumcVWU/0.jpg)](https://www.youtube.com/watch?v=97YDEumcVWU&t=0s)
105160

106161
## Why & How it works
107162

@@ -130,20 +185,27 @@ sequenceDiagram
130185
SP->>SS: Commands
131186
```
132187

133-
![cls](https://github.com/user-attachments/assets/4daee216-1479-4acd-88f2-9e772b8c7837)
134188
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.
135189

136-
## Configuration
190+
## Other Solutions To Run The Base Code
191+
192+
TODO
193+
194+
## Create Binary
195+
196+
TODO
197+
198+
## Test Performance by using AutoTest
137199

138-
### RoboCup Server configuration
200+
TODO
139201

140-
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.
202+
## How to improve the performance of the team
141203

142-
### Modifying Proxy & Running proxy and server seperately
204+
TODO
143205

144-
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.
206+
## Documentation
145207

146-
You can modify the rpc port by adding the argument `--rpc-port [VALUE]`, where the default is 50051.
208+
TODO
147209

148210
## Citation
149211

0 commit comments

Comments
 (0)