|
| 1 | +--- |
| 2 | +layout: page |
| 3 | +title: Setting up the simulator |
| 4 | +--- |
| 5 | + |
| 6 | +Setting up the simulator |
| 7 | +======================== |
| 8 | + |
| 9 | +### Prerequisites |
| 10 | + |
| 11 | +You need to download and install [Webots](https://cyberbotics.com/#download) (the download is around 300MB). |
| 12 | +This is the platform we run our simulation in. |
| 13 | + |
| 14 | +Versions "R2022b" and "R2023a" of Webots are supported. |
| 15 | +*Note*: versions of the simulation prior to sr2023.3 did not support Webots "R2023a". |
| 16 | + |
| 17 | +#### Python Version |
| 18 | + |
| 19 | +You will also need Python installed. |
| 20 | + |
| 21 | +| Platform | Supported Python Version | |
| 22 | +|----------|--------------------------| |
| 23 | +| Windows | 3.8-3.10 (64-bit) | |
| 24 | +| macOS | 3.8-3.10 | |
| 25 | +| Linux | 3.8-3.10 | |
| 26 | + |
| 27 | +There are a small number of [external libraries]({{ site.baseurl }}/programming/python/libraries#simulator) |
| 28 | +which will be available to your robot code during the competition. Note that for |
| 29 | +local development you will need to install these yourself. |
| 30 | + |
| 31 | +### Installing the simulation |
| 32 | + |
| 33 | +1. Create a directory, perhaps called `simulation` where you will store your robot code. |
| 34 | +2. [Download the simulation](https://github.com/srobo/competition-simulator/releases/download/sr2023.5/competition-simulator-sr2023.5.zip), the latest version is sr2023.5, released on 2023-02-22. |
| 35 | +3. Unzip the simulation as a subdirectory of the directory you created in the first step: |
| 36 | + ``` |
| 37 | + simulation |
| 38 | + ├── competition-simulator-<version> |
| 39 | + │ ├── ... |
| 40 | + │ └─ worlds |
| 41 | + │ └── Arena.wbt |
| 42 | + └── robot.py |
| 43 | + ``` |
| 44 | + If there is not an existing `robot.py` an example one will be created when the simulator first runs. |
| 45 | +
|
| 46 | +4. Using the Webots IDE, open the `worlds/Arena.wbt` file. |
| 47 | +
|
| 48 | +You may receive a warning about your computer's GPU not being good enough, which can be ignored. |
| 49 | +
|
| 50 | +<div class="info"> |
| 51 | + On recent versions of macOS you may need to give Webots permission to access the directory where you have extracted the simulation files. |
| 52 | +</div> |
| 53 | +
|
| 54 | +#### Changing your version of Python |
| 55 | +
|
| 56 | +If webots is not picking any version of Python or is picking up the wrong one then you'll need to change it. |
| 57 | +When this happens Webots will print errors to its console and your robot will not move. |
| 58 | +
|
| 59 | +You will need the full path to the version of Python that you want to use. |
| 60 | +This will vary based on the system you have. |
| 61 | +One way to find the path is by launching the version of Python that you want to |
| 62 | +use and running the following code: |
| 63 | +
|
| 64 | +~~~~~ python |
| 65 | +import sys |
| 66 | +print(sys.executable) |
| 67 | +~~~~~ |
| 68 | +
|
| 69 | +On Windows you can set the path to the Python version to use in Webots UI via |
| 70 | +**Tools** → **Preferences** → **General** → **Python command**. |
| 71 | +Your Python path is likely similar to `C:\Users\<USERNAME>\AppData\Local\Programs\Python\Python39\python.exe` when using Python 3.9, where `<USERNAME>` is your login. |
| 72 | +
|
| 73 | +On Mac you can set the path to the Python version to use via **Webots** → **Preferences** <kbd>⌘</kbd><kbd>,</kbd>. |
| 74 | +Your Python path is likely similar to `/Library/Frameworks/Python.framework/Versions/3.9/bin/python3` when using Python 3.9. |
| 75 | +
|
| 76 | +You'll need to ensure a matching version of Python is installed. If you're still |
| 77 | +having problems, ask for help in [`#simulator-help`][simulator-help] in |
| 78 | +[Discord][discord]. |
| 79 | +
|
| 80 | +### Updates |
| 81 | +
|
| 82 | +Occasionally, we may release an update to the simulation. To update, you will need to delete the `competition-simulator-<version>` directory, and re-download it using the above link. |
| 83 | +
|
| 84 | +If you need a specific version of the simulator, or want to see what changes |
| 85 | +have been made with each version, please see the |
| 86 | +[list of releases](https://github.com/srobo/competition-simulator/releases). |
| 87 | +
|
| 88 | +[discord]: {{ site.baseurl }}/team_admin/discord |
| 89 | +[programming-help]: https://discord.com/channels/900501415548579842/900501416269971457 |
| 90 | +[simulator-help]: https://discord.com/channels/900501415548579842/900501416269971458 |
0 commit comments