@@ -14,7 +14,7 @@ The `sr.robot` library contains support for detecting radio transmitters with th
14
14
Radio transmitters are attached to various items in the Student Robotics arena.
15
15
Each transmitter encodes their identity in a machine-readable way, which means that robots can identify these objects.
16
16
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
18
18
determine the distance and direction of a transmitter in 3D space relative to
19
19
the radio. Therefore, if the robot can detect transmitters that is at a fixed
20
20
location in the arena, a robot can calculate its exact position in the arena.
@@ -28,135 +28,55 @@ R = Robot()
28
28
transmitters = R.radio.sweep()
29
29
~~~~~
30
30
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 ) .
34
34
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 :
36
36
37
37
~~~~~ python
38
38
from sr.robot import *
39
39
R = Robot()
40
40
41
41
while True :
42
42
transmitters = R.radio.sweep()
43
- print (" I found" , len (transmitters), " transmitters :" )
43
+ print (" I found" , len (transmitters), " transmitter(s) :" )
44
44
45
45
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
+ ))
51
51
~~~~~
52
52
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.
80
53
81
54
[ Objects of the Radio System] ( #radio_objects ) {#radio_objects}
82
- ==============================
55
+ ===================================
83
56
84
- [ ` Transmitter ` ] ( #Transmitter ) {#Transmitter }
57
+ [ ` Target ` ] ( #Target ) {#Target }
85
58
----------
86
- A ` Transmitter ` object contains information about a * detected* transmitter.
87
- It has the following attributes:
88
59
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:
94
62
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.
97
65
98
- rot_y
99
- : An alias for ` position.polar.rot_y `
66
+ signal_strength
67
+ : The measured strength of the signal as a float.
100
68
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 .
103
71
104
- [ ` TransmitterInfo ` ] ( #TransmitterInfo ) {#TransmitterInfo }
72
+ [ ` TargetInfo ` ] ( #TargetInfo ) {#TargetInfo }
105
73
--------------
106
74
107
- The ` TransmitterInfo ` object contains information about a transmitter.
75
+ The ` TargetInfo ` object contains information about a transmitter.
108
76
It has the following attributes:
109
77
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.
157
80
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.
0 commit comments