Skip to content

Commit 2a8cc0c

Browse files
committed
Change radio docs to mirror the current shape of the robot API
1 parent 0f43776 commit 2a8cc0c

File tree

2 files changed

+27
-111
lines changed

2 files changed

+27
-111
lines changed

programming/sr/radio/index.md

Lines changed: 27 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ The `sr.robot` library contains support for detecting radio transmitters with th
1414
Radio transmitters are attached to various items in the Student Robotics arena.
1515
Each transmitter encodes their identity in a machine-readable way, which means that robots can identify these objects.
1616

17-
Using the signal strength of received radio signals, the robot api is able to
17+
Using the signal strength and bearing of the received radio signals, you are able to
1818
determine the distance and direction of a transmitter in 3D space relative to
1919
the radio. Therefore, if the robot can detect transmitters that is at a fixed
2020
location in the arena, a robot can calculate its exact position in the arena.
@@ -28,135 +28,55 @@ R = Robot()
2828
transmitters = R.radio.sweep()
2929
~~~~~
3030

31-
When called, the `sweep` function uses the radio reciever as a secondary radio, searching for nearby transmitters.
32-
It returns a list of `Transmitter` objects, each of which describes one of the transmitters that were found within range.
33-
A detailed description of the attributes of Transmitter objects is provided [later in this page](#Transmitter).
31+
When called, the `sweep` function uses the radio reciever to scan for nearby transmitters.
32+
It returns a list of `Target` objects, each of which describes one of the transmitters that were found within range.
33+
A detailed description of the attributes of `Target` objects is provided [later in this page](#Target).
3434

35-
Here's an example that will repeatedly print out the distance to each arena transmitter that the robot can see:
35+
Here's an example that will repeatedly print out the bearing and signal stength of each arena transmitter in range:
3636

3737
~~~~~ python
3838
from sr.robot import *
3939
R = Robot()
4040

4141
while True:
4242
transmitters = R.radio.sweep()
43-
print("I found", len(transmitters), "transmitters:")
43+
print("I found", len(transmitters), "transmitter(s):")
4444

4545
for tx in transmitters:
46-
if tx.info.transmitter_type == TransmitterType.BEACON:
47-
print(" - Transmitter #{0} is {1} metres away".format(
48-
tx.info.code,
49-
tx.dist,
50-
))
46+
print(" - Transmitter {0} Bearing: {1} with a signal strength of {2}".format(
47+
tx.target_info.station_code,
48+
tx.bearing,
49+
tx.signal_strength,
50+
))
5151
~~~~~
5252

53-
[Definition of Axes](#axes) {#axes}
54-
===================================
55-
56-
<!-- Note: these are the same as the camera. We should keep these in sync. -->
57-
58-
The radio system describes the transmitters it can see using three coordinate
59-
systems. These are intended to be complementary to each other and contain the
60-
same information in different forms.
61-
62-
The individual coordinate systems used are detailed below on the
63-
[`Point`](#Point) object, which represents a point in space.
64-
65-
The axis definitions match those in common use, as follows:
66-
67-
x-axis
68-
: The horizontal axis running left-to-right in front of the robot.
69-
Rotation about this axis is equivalent to leaning towards or away from
70-
the robot.
71-
72-
y-axis
73-
: The vertical axis running top-to-bottom in front of the robot.
74-
Rotation about this axis is equivalent to turning on the spot,
75-
to the left or right.
76-
77-
z-axis
78-
: The axis leading away from the front of the robot to infinity.
79-
Rotation about this axis is equivalent to being rolled sideways.
8053

8154
[Objects of the Radio System](#radio_objects) {#radio_objects}
82-
==============================
55+
===================================
8356

84-
[`Transmitter`](#Transmitter) {#Transmitter}
57+
[`Target`](#Target) {#Target}
8558
----------
86-
A `Transmitter` object contains information about a *detected* transmitter.
87-
It has the following attributes:
8859

89-
info
90-
: A [`TransmitterInfo`](#TransmitterInfo) object containing information about the type of transmitter that was detected.
91-
92-
position
93-
: A [`Point`](#Point) describing the position of the transmitter.
60+
A `Target` object contains information about a _detected_ transmitter.
61+
It has the following attributes:
9462

95-
dist
96-
: An alias for `position.polar.length`
63+
target_info
64+
: A [`TargetInfo`](#TargetInfo) object containing information about the transmitter that was detected.
9765

98-
rot_y
99-
: An alias for `position.polar.rot_y`
66+
signal_strength
67+
: The measured strength of the signal as a float.
10068

101-
timestamp
102-
: The timestamp at which the sweep happened (a float).
69+
bearing
70+
: A float giving the angle to the `Target` in radians.
10371

104-
[`TransmitterInfo`](#TransmitterInfo) {#TransmitterInfo}
72+
[`TargetInfo`](#TargetInfo) {#TargetInfo}
10573
--------------
10674

107-
The `TransmitterInfo` object contains information about a transmitter.
75+
The `TargetInfo` object contains information about a transmitter.
10876
It has the following attributes:
10977

110-
code
111-
: The numeric code of the transmitter.
112-
113-
transmitter_type
114-
: The type of object that this transmitter represents.<br />
115-
The possible values of this are part of the `TransmitterType` enum:
116-
117-
* `TransmitterType.BEACON`
118-
* `TransmitterType.TOWER`
119-
* `TransmitterType.ROBOT`
120-
121-
offset
122-
: The offset of the numeric code of the transmitter from the lowest numbered transmitter of its type.
123-
For example: transmitters 2 and 3, which are the lowest numbered transmitters that represent towers, have offsets of 0 and 1 respectively.
124-
125-
[`Point`](#Point) {#Point}
126-
---------
127-
128-
<!-- Note: this is almost identical to the equivalent type in the vision system. We should keep these in sync. -->
129-
130-
A `Point` object describes a position in three different ways.
131-
These are accessed through the following attributes:
132-
133-
<!-- Deliberately no `image` member -->
134-
135-
world
136-
: The [Cartesian coordinates](https://en.wikipedia.org/wiki/Cartesian_coordinate_system) of the point in 3D space.
137-
This has three attributes: `x`, `y`, and `z`, each of which specifies a distance in metres.
138-
Positions in front of, to the right, or above the robot are positive.
139-
Positions to the left or below are negative.
140-
141-
polar
142-
: The [polar coordinates](https://en.wikipedia.org/wiki/Polar_coordinate_system) of the point in 3D space.<br />
143-
This has three attributes:
144-
145-
length
146-
: The distance to the point.
147-
148-
rot_x
149-
: Rotation about the x-axis in degrees.
150-
Positions above the radio are positive.
151-
152-
rot_y
153-
: Rotation about the y-axis in degrees.
154-
Positions to the right of the radio are positive.
155-
156-
For example, the following code displays the polar coordinate of a `Point` object `p`:
78+
station_code
79+
: The two character identifier of the transmitter.
15780

158-
~~~~~ python
159-
print("length", p.polar.length)
160-
print("rot_x", p.polar.rot_x)
161-
print("rot_y", p.polar.rot_y)
162-
~~~~~
81+
owned_by
82+
: The zone id of the robot that currently owns the stations territory. A `None` value indicates an unclaimed territory.

programming/sr/vision/index.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,6 @@ The Logitech C500 has a [field of view][fov] of 72&deg; and the C270 has a field
9393
[Definition of Axes](#axes) {#axes}
9494
===================================
9595

96-
<!-- Note: these are the same as the radio. We should keep these in sync. -->
97-
9896
The vision system describes the markers it can see using three coordinate
9997
systems. These are intended to be complementary to each other and contain
10098
the same information in different forms.
@@ -188,8 +186,6 @@ size
188186
[`Point`](#Point) {#Point}
189187
---------
190188

191-
<!-- Note: this is almost identical to the equivalent type in the radio system. We should keep these in sync. -->
192-
193189
A `Point` object describes a position in three different ways.
194190
These are accessed through the following attributes:
195191

0 commit comments

Comments
 (0)