Skip to content

Commit cc06521

Browse files
authored
Merge pull request #172 from sourcebots/simulator-section
Create dedicated simulator section
2 parents e36e41c + c945e94 commit cc06521

File tree

14 files changed

+147
-39
lines changed

14 files changed

+147
-39
lines changed

content/api/_index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: API
3-
weight: 3
3+
weight: 2
44
---
55

66
Programming your robot is done in [Python](https://www.python.org/),

content/api/arduino.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
---
22
title: Arduino API
3-
weight: 5
43
---
54

65
The [Arduino](https://store.arduino.cc/arduino-uno-rev3) provides a

content/api/game-state.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
---
22
title: Game State
3-
weight: 9
43
---
54

65
## Mode

content/api/motor-board.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
---
22
title: Motor Board API
3-
weight: 1
43
---
54

65
The kit can control multiple motors simultaneously. One Motor Board can

content/faqs/_index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: FAQs
3-
weight: 7
3+
weight: 6
44
---
55

66
Teams often ask us questions, so we've put the most common ones below, so others can learn from them.

content/kit/_index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
---
22
title: Kit
3-
weight: 9
3+
weight: 5
44
---
55

66
{{% notice warning %}}
7-
These kit docs are only relevant for the physical robot, as opposed to the [simulator](../tutorials/simulator).
7+
These kit docs are only relevant for the physical robot, as opposed to the [simulator](/simulator/).
88
{{% /notice %}}
99

1010
## Boards

content/rules/_index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Rules
3-
weight: 5
3+
weight: 4
44
---
55

66
You can find the rules for Smallpeice 2021 competition here!:

content/simulator/_index.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
title: Simulator
3+
weight: 3
4+
---
5+
6+
{{% notice note %}}
7+
Should you wish to run the simulator locally, this is fine, however it will drastically limit your ability to collaborate with the rest of your team.
8+
{{% /notice %}}
9+
10+
## Running simulations
11+
12+
To ease the load on your computers, the Webots simulator will be run by us, which you can interact with through our runner interface. The runner allows you to run simulations, and view the logs and recordings afterwards.
13+
14+
To run a simulation, click the "Run Simulation" button. The button will prevent you from running additional simulations whilst a simulation is running. Once the simulation has finished, the button will return to "Run Simulation", and an entry will be shown below it with a link to the logs and animation for your simulation run. Note that this always uses the files in the `zone-0` / `zone-1` directory.
15+
16+
## Directory structure
17+
18+
In VSCode, you will see a directory structure which looks similar to this:
19+
20+
``` plain
21+
.
22+
├── competition-simulator
23+
│ ├── controllers
24+
│ │ ├── example_controller
25+
│ │ └── sr_controller
26+
│ ├── ...
27+
│ └── worlds
28+
├── output
29+
│ └── 2021-08-07T19_20_46.108422
30+
│ ├── 2021-08-07T18_31_56.html
31+
│ ├── 2021-08-07T18_31_56.json
32+
│ ├── 2021-08-07T18_31_56.x3d
33+
│ └── logs.txt
34+
└── zone-0
35+
├── crane.py
36+
└── forklift.py
37+
```
Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
---
2-
title: Simulator
3-
weight: 5
2+
title: Local installation
43
---
54

6-
To test out your robot code, you can use our Simulator. This gives you a realistic environment to run your code, against a dummy robot, without the need for a physical arena. This simulator is currently only available on Windows.
5+
Should you wish to run the simulator locally, this is fine, however it will drastically limit your ability to collaborate with the rest of your team.
76

87
## Installation
98

@@ -17,7 +16,9 @@ You will also need Python 3.9 installed.
1716

1817
There are a small number of [external libraries](/api#included-libraries) which will be available to your robot code during the competition. For local development you will need to install these yourself.
1918

20-
{{% notice warning %}} If you are installing python on Windows, you will need to add python to PATH otherwise Webots will not be able to find the python installation {{% /notice %}}
19+
{{% notice warning %}}
20+
If you are installing python on Windows, you will need to add python to `PATH` otherwise Webots will not be able to find the python installation
21+
{{% /notice %}}
2122

2223
### Installing the simulation
2324

@@ -30,7 +31,6 @@ You may receive a warning about your computer’s GPU not being good enough, whi
3031

3132
If Webots is picking up the incorrect version of Python, you’ll need to change it. This can be done using Tools > Preferences > General > Python command. You’ll need to ensure a matching version of Python is installed.
3233

33-
3434
## Overview
3535

3636
Within the Webots IDE, there are a few different panels:
@@ -40,25 +40,6 @@ Within the Webots IDE, there are a few different panels:
4040
- At the bottom is the console, where output from your robot code will be displayed
4141
- At the top are your general controls which include the time controls. Press the centre play button to run the simulation at normal speed.
4242

43-
## Other robots
44-
45-
There is another robot in the arena, in its starting zone. By default, this robot will not move.
46-
47-
To control the other robot, you will need to provide its code:
48-
49-
Create the robot code in `zone-1/robot.py`. Your code at `robot.py` will be used for zone 0, though you are encouraged to move your code to `zone-0/robot.py` when running multiple robots. Robots which do not have any robot code in their `zone-x` directory will not do anything.
50-
51-
``` plain
52-
.
53-
├── competition-simulator
54-
│ ├── controllers
55-
│ │ ├── example_controller
56-
│ │ └── sr_controller
57-
│ ├── ...
58-
│ └── worlds
59-
└── robot.py
60-
```
61-
6243
## Time
6344

6445
In the simulated environment, time advances only at the pace that the simulator is run. The relation between this time and the real passage of time depends on a couple of factors: the speed the simulation is configured to run at and the ability of the computer running the simulation to process it fast enough.
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
---
2+
title: Programming
3+
weight: 1
4+
---
5+
6+
On first run, the robot will execute an example program for convenience. On first run, this will be copied into `zone-0` in the same directory that `competition-simulator-<version>` is stored in:
7+
8+
```plain
9+
.
10+
├── competition-simulator-<version>
11+
│ ├── ...
12+
│ └── worlds
13+
│ └── Arena.wbt
14+
├── zone-0
15+
│ ├── crane.py
16+
│ └── forklift.py
17+
└── zone-1
18+
```
19+
20+
Your code for the forklift robot should go in `forklift.py` and the crane in `crane.py`.
21+
22+
{{% notice warning %}}
23+
Only your controller code will be present in the competition environment.
24+
{{% /notice %}}
25+
26+
### Time
27+
28+
In the simulated environment, time advances only at the pace that the simulator
29+
is run. As a result, using `time.time` to know how long your robot has been
30+
running for or `time.sleep` to wait for some duration will be unreliable.
31+
32+
As a result the API present in the simulator supports a slightly different
33+
approach to handling time. See the documentation about [simulated time](./time)
34+
for more details.
35+
36+
## Other robots
37+
38+
There is another robot in the arena; its starting zone is zone 1. By default, this robot will not move.
39+
40+
To control the zone 1 robot, you will need to provide its code:
41+
42+
Create the robot code in `zone-1/forklift.py` and `zone-1/crane.py`. Your original code in `zone-0/` will still be used to control zone 0 robots. Robots which do not have any robot code in their `zone-x` directory will not do anything.
43+
44+
``` plain
45+
.
46+
├── competition-simulator
47+
│ ├── controllers
48+
│ │ ├── example_controller
49+
│ │ └── sr_controller
50+
│ ├── ...
51+
│ └── worlds
52+
├── zone-0
53+
│ └── crane.py
54+
└── zone-1
55+
└── crane.py
56+
```

0 commit comments

Comments
 (0)