Skip to content

Commit 96b4ad1

Browse files
committed
First pass of simulator programming docs
1 parent d91253a commit 96b4ad1

File tree

1 file changed

+37
-26
lines changed

1 file changed

+37
-26
lines changed

simulator/programming/index.md

Lines changed: 37 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ title: Simulator Programming
99

1010
## Developing your code
1111

12-
On first run, the robot will execute an example program for convenience. On first run, this will be copied to the directory `competition-simulator-<version>` is stored in:
12+
On first run, the robot will execute an example program for convenience. This program will be copied to the directory `competition-simulator-<version>` is stored in:
1313

1414
```
1515
.
@@ -27,61 +27,72 @@ Your code should be developed in `robot.py`.
2727
Only your controller code will be present in the competition environment.
2828
</div>
2929

30-
## Programming Interface
30+
## Robot
3131

32-
Unless otherwise stated, the simulator’s API is the same as the real SR API described in the [programming docs]({{ site.baseurl }}/programming/).
32+
There is a pre-built robot used in the simulator.
33+
To allow this simulated robot to move around and sense its environment a set of motors and sensors have been connected as detailed below.
34+
35+
The simulator’s API is very similar to the real SR API described in the [programming docs]({{ site.baseurl }}/programming/), with the exception of `R.time` and `R.sleep`.
3336

3437
### Motors
3538

36-
Your robot has one motor board attached, the left wheel in port `m0`, and the right wheel in `m1`.
39+
Your robot has one motor board attached, the left wheel is connected to the first port, and the right wheel to the second.
40+
41+
The motor board has the part code `srABC1`, since only a single motor board is attached it can be referenced as `R.motor_board`.
42+
43+
### Servos
44+
45+
Your robot has one servo board attached, the jaws of the robot are controlled by a pair of servos:
46+
47+
| Servo | Location |
48+
|-------|-----------|
49+
| 0 | Left Jaw |
50+
| 1 | Right Jaw |
51+
52+
Setting each servo to -1 fully opens the respective jaw.
3753

38-
The motor board does not have a part code, so it needs to be indexed using `0`.
54+
The servo board has the part code `srXYZ2`, since only a single servo board is attached it can be referenced as `R.servo_board`.
3955

4056
### Ruggeduino
4157

42-
Your robot has two microswitches and six distance sensors, attached to the digital and analogue pins respectively. These are all attached to a single ruggeduino.
58+
Your robot has a microswitch and six distance sensors, attached to the digital and analogue pins respectively. These are all attached to a single ruggeduino.
4359

4460
Because these sensors are pre-attached to the ruggeduino, you do not need to set its `pin_mode`.
4561

4662
#### Microswitches
4763

48-
The microswitches are attached to digital pins 2 and 3:
64+
The microswitch is attached to digital pin 2:
4965

5066
| Pin | Location |
5167
|-----|----------|
52-
| 2 | Front |
53-
| 3 | Back |
68+
| 2 | Back |
5469

55-
These are shown as red coloured blocks on the robot. Using the `digital_read` method, you'll receive a `bool` telling you whether the switch is current actuated.
70+
This is shown as a red coloured block on the robot. Using the `digital_read` method, you'll receive a `bool` telling you whether the switch is currently actuated.
5671

5772
#### Distance Sensors
5873

59-
Analogous to ultrasound sensors, distance sensors allow you to retrieve the distance between your robot and an object. These are attached to analogue pins 0-5:
74+
Analogous to ultrasound sensors, distance sensors allow you to retrieve the distance between your robot and an object. These are attached to analogue pins A0-A5:
6075

6176
| Pin | Location |
6277
|-----|----------|
63-
| 0 | Front Left |
64-
| 1 | Front Right |
65-
| 2 | Left |
66-
| 3 | Right |
67-
| 4 | Back Left |
68-
| 5 | Back Right |
69-
70-
These are shown as blue coloured blocks on the robot. The `analogue_read` method will return the distance in metres. They can see in a narrow cone up to a maximum of about 2m away.
78+
| A0 | Front Left |
79+
| A1 | Front Right |
80+
| A2 | Left |
81+
| A3 | Right |
82+
| A4 | Front |
83+
| A5 | Back |
84+
85+
These are shown as blue boards with silver transceivers on the robot. The `analogue_read` method will return the distance in metres. They can see in a narrow cone up to a maximum of about 2m away.
7186
Since these sensors rely on echoes being reflected back from objects, if the angle of incidence between the sensor's pulse and the contacted surface exceeds 22.5 degrees then the sensor will be unable to detect the object.
7287

7388
#### LEDs
7489

75-
The LEDs are attached to digital pins 4-9:
90+
The LEDs are attached to digital pins 3-4:
7691

7792
| Pin | Location |
7893
|-----|----------|
79-
| 4 | Red (right) |
80-
| 5 | Green (right) |
81-
| 6 | Blue (right) |
82-
| 7 | Blue (left) |
83-
| 8 | Green (left) |
84-
| 9 | Red (left) |
94+
| 3 | Red (Left) |
95+
| 4 | Green (right) |
8596

8697
Using the `digital_write` method, you can set these to True (On) or False (Off).
8798

0 commit comments

Comments
 (0)