Skip to content

Commit 26c94e3

Browse files
authored
Merge pull request #174 from sourcebots/andy-sp2021
Update docs for SP2021 game
2 parents 5b6e8a3 + fb245a5 commit 26c94e3

File tree

13 files changed

+310
-184
lines changed

13 files changed

+310
-184
lines changed

.spelling

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
1+
×
12
100x100mm
23
11.1V
4+
15cm
5+
2.2A.
6+
2.5m
37
20000Hz
48
20Hz
59
2200mAh
6-
2.2A.
710
250x250mm
11+
2m
812
2mm
913
3.3V
1014
3.81mm
1115
3m
1216
4mm
1317
5mm
14-
70x84x20mm
15-
7.5mm
1618
7-zip
19+
7.5mm
20+
70x84x20mm
1721
83x99x24mm
1822
Adafruit
1923
AprilTag
@@ -25,7 +29,9 @@ Codecademy
2529
Datacamp
2630
dropdown
2731
elif
32+
energised
2833
enum
34+
forklift
2935
FreeCodeCamp
3036
H0-1
3137
iMAX
@@ -38,6 +44,7 @@ LiPo
3844
macOS
3945
Math
4046
matplotlib
47+
microswitch
4148
microswitches
4249
numpy
4350
piezo
@@ -46,19 +53,20 @@ Programiz
4653
PyCharm
4754
pyplot
4855
python3
56+
r.zone
4957
R2021b
5058
scikit-learn
5159
scipy
52-
SourceBots
5360
Smallpeice
61+
SourceBots
5462
square-ish
5563
StackOverflow
5664
submodule
65+
TargetInfo
5766
TeckNet
5867
Tutorialspoint
5968
Uno
6069
vcc
6170
VSCode
6271
W3Schools
6372
Webots
64-
×

content/api/compass.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
title: Compass
3+
weight: 10
4+
---
5+
6+
The forklift robot has a compass unit. This allows [robots](../../robots/) to determine the direction it's facing in the arena.
7+
8+
```python
9+
# Get the heading of the robot.
10+
heading = r.compass.get_heading() # Radians
11+
```
12+
13+
When called, the `get_heading` method will return the heading of the robot in radians as a float. The heading is in the range 0 to tau (2π), where 0 is the robot facing directly North, and values increasing clockwise.

content/api/encoder.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
title: Motor Encoder API
3+
weight: 8
4+
---
5+
6+
Most moving parts of the robot have encoders attached. There are two kinds of encoders, linear encoders and rotary encoders. You can tell which is which by the joint it is attached to; if the joint rotates it is a Rotary encoder, whilst if it slides, it is a linear encoder.
7+
8+
## Linear Encoders
9+
10+
Linear encoders are attached to joints that move in a straight line (i.e. raising/lowering the forklift).
11+
12+
Linear encoders measure the distance the joint has moved from its start position, in *metres*.
13+
14+
All encoders are stored in a list called `encoders`, you can access the encoder with `encoders[i]`, where `i` is the slot the encoder is plugged into. You can find this number in the [documentation for the robot](/robots/).
15+
16+
```python
17+
# Get the distance from the start position
18+
distance_from_start = r.encoders[1].displacement # in Metres
19+
```
20+
21+
## Rotary Encoders
22+
23+
Rotary encoders are attached to joints that rotate (i.e. wheel rotations).
24+
25+
Rotary encoders measure the total rotation the joint has moved from its start position, in *radians*.
26+
27+
All encoders are stored in a list called `encoders`, you can access the encoder with `encoders[i]`, where `i` is the slot the encoder is plugged into. You can find this number in the [documentation for the robot](/robots/).
28+
29+
```python
30+
# Get the total rotation from the start position
31+
rotation_from_start = r.encoders[1].rotation # in Radians
32+
```

content/api/game-state.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,4 @@ r.zone
3535
```
3636

3737
During a competition match, a USB drive will be used to tell your robot
38-
which corner it's in. By default during development, this is `0`.
38+
which corner it's in. By default during development, this is `0`.

content/api/magnet.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
title: Magnet API
3+
weight: 8
4+
---
5+
6+
The magnet is only available on the [Crane robot](../../robots/crane).
7+
8+
The magnet of the crane will only stick to containers.
9+
10+
## Getting the magnet's status
11+
12+
A magnet can be either energised or de-energised, you can turn the magnet on or off by setting `r.magnet.energised` like so:
13+
```python
14+
# Turn on the magnet
15+
r.magnet.energised = True
16+
# Turn off the magnet
17+
r.magnet.energised = False
18+
```
19+
20+
{{% notice warning %}}
21+
Check the spelling of `energised`, it's in British English, `energized` will not work!
22+
{{% /notice %}}
23+
24+
You can get the current state of the magnet by getting the value of `energized` like so:
25+
26+
```python
27+
magnet_on = r.magnet.energised
28+
```
29+
30+
## Checking if a container is nearby
31+
32+
The magnet can tell you if there is an object in range to be picked up. You can check if any object is in range by accessing the `nearby` method:
33+
```python
34+
# Is there a container nearby?
35+
is_nearby = r.magnet.nearby() # True or False
36+
```

content/api/power-board.md

Lines changed: 0 additions & 114 deletions
This file was deleted.

content/api/radio.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
---
2+
title: Radio API
3+
weight: 6
4+
---
5+
6+
Radio transmitters and receivers are attached to various items in the arena.
7+
Each transmitter encodes their identity, which means that receivers can identify these objects.
8+
9+
Using the signal strength and bearing of the received radio signals, you're able to
10+
determine the distance and direction of a transmitter relative to the radio in 2D.
11+
12+
Our library provides this through a `radio` attached to your `Robot`,
13+
which has a `sweep` function that detects transmitters that are in range:
14+
15+
``` python
16+
# Get all transmitters that are in range.
17+
transmitters = r.radio.sweep()
18+
```
19+
20+
When called, the `sweep()` function uses the radio receiver to scan for all transmitters in range.
21+
It returns a list of `Target` objects, each of which describes one of the transmitters that were found within range.
22+
A detailed description of the attributes of `Target` objects is provided at the bottom of this page.
23+
24+
Here's an example that will repeatedly print out the information, bearing, and signal strength of each transmitter in range:
25+
26+
``` python
27+
# Continuously prints details of nearby transmitters.
28+
while True:
29+
transmitters = r.radio.sweep()
30+
print("I found", len(transmitters), "transmitter(s):")
31+
32+
for tx in transmitters:
33+
print("Transmitter ID:", tx.target_info.id)
34+
print(" Type:", tx.target_info.type)
35+
print(" Owner:", tx.target_info.owner)
36+
print(" Bearing:", tx.bearing)
37+
print(" Signal Strength:", tx.signal_strength)
38+
```
39+
40+
## Detecting beacons
41+
42+
There are 4 beacons in the arena, see [the rules](/rules/) for their locations. These beacons continually transmit their identity. Beacons can be detected up to 2.5m away.
43+
44+
The beacons have the `target_info.type` value of `0` (`TargetType.BEACON`), which can be used to detect if it is a beacon. See '[Objects of the Radio System](#objects-of-the-radio-system)' below for all available information.
45+
46+
## Detecting containers
47+
48+
There are many containers in the arena, which are each owned by a specific team. Containers can be detected up to 2.5m away.
49+
50+
The beacons have the `target_info.type` value of `1` (`TargetType.CONTAINER`), which can be used to detect if it is a container. See '[Objects of the Radio System](#objects-of-the-radio-system)' below for all available information.
51+
52+
53+
## Objects of the Radio System
54+
55+
### Target
56+
57+
A `Target` object contains information about a _detected_ transmitter.
58+
It has the following attributes:
59+
60+
`target_info`
61+
: A [`TargetInfo`](#targetinfo) object containing information about the transmitter that was detected.
62+
63+
`signal_strength`
64+
: The measured strength of the signal as a float.
65+
66+
`bearing`
67+
: The angle to the `Target` in radians as a float.
68+
A bearing of `0` is in front of the robot. Positive bearings are to the robot's right.
69+
70+
### TargetInfo
71+
72+
The `TargetInfo` object contains information about a transmitter.
73+
It has the following attributes:
74+
75+
`id`
76+
: The ID of the transmitter, either 1-16 for containers, or 100-103 for beacons. See [the rules](/rules/) for the arena layout.
77+
78+
`type`
79+
: The type of the transmitter, either `0` (`TargetType.BEACON`) for a beacon, or `1` (`TargetType.CONTAINER`) for a container.
80+
81+
`owner`
82+
: The zone id of the robot that currently owns the stations territory. This can be `0` (`Owner.ZONE_0`), `1` (`Owner.ZONE_1`), or `-1` (`Owner.NULL`). which indicates it does not have an owner (i.e. it's a beacon). Remember, you can find out which zone your robot is in using [r.zone](/api/game-state)

0 commit comments

Comments
 (0)