Skip to content

Commit 05ab145

Browse files
committed
Merge branch 'update-vision-docs'
2 parents cd5ecfb + 3dc777c commit 05ab145

File tree

3 files changed

+90
-39
lines changed

3 files changed

+90
-39
lines changed

images/content/vision/spherical.png

-41.2 KB
Binary file not shown.
-29.2 KB
Binary file not shown.

programming/sr/vision/index.md

Lines changed: 90 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,10 @@ size
134134
: The physical size of the marker, as the vision system expects it.
135135

136136
pixel_centre
137-
: A [`Coordinate`](#Coordinate) describing the position of the centre of the marker.
137+
: A [`PixelCoordinates`](#PixelCoordinates) describing the position of the centre of the marker.
138138

139139
pixel_corners
140-
: A list of 4 [`Coordinate`](#Coordinate) instances, each representing the position of the corners of the marker.
140+
: A list of 4 [`PixelCoordinates`](#PixelCoordinates) instances, each representing the position of the corners of the marker.
141141

142142
distance
143143
: The distance between the camera and the centre of the marker, in millimetres.
@@ -146,20 +146,35 @@ orientation
146146
: An [`Orientation`](#Orientation) instance describing the orientation of the marker.
147147

148148
spherical
149-
: A [`Spherical`](#Spherical) instance describing the position relative to the camera.
149+
: A [`SphericalCoordinate`](#SphericalCoordinate) instance describing the position of the marker relative to the camera.
150150

151151
cartesian
152-
: A [`ThreeDCoordinate`](#ThreeDCoordinate) instance describing the absolute position of the marker relative to the camera.
152+
: A [`CartesianCoordinates`](#CartesianCoordinates) instance describing the position of the marker relative to the camera.
153153

154-
[`Coordinate`](#Coordinate) {#Coordinate}
154+
<a id="Coordinate"/>
155+
156+
[`PixelCoordinates`](#PixelCoordinates) {#PixelCoordinates}
155157
---------
156158

157-
A `Coordinate` object contains an `x` and `y` attribute. The exact meaning and unit of these attributes depends on its source.
159+
A named tuple of `x` and `y` coordinates for the point, in pixels relative to the top left of the image.
160+
161+
~~~~~ python
162+
# Print the x and y coordinates of the pixel location
163+
print(marker.pixel_centre.x, marker.pixel_centre.y)
164+
~~~~~
165+
166+
<a id="ThreeDCoordinate"/>
158167

159-
[`ThreeDCoordinate`](#ThreeDCoordinate) {#ThreeDCoordinate}
168+
[`CartesianCoordinates`](#CartesianCoordinates) {#CartesianCoordinates}
160169
---------
161170

162-
A `ThreeDCoordinate` object contains an `x`, `y` and `z` attribute. The exact meaning and unit of these attributes depends on its source.
171+
A named tuple of `x`, `y` and `z` coordinates for the point, in millimeters relative to the camera.
172+
Increasing values are to the right, below and away from the camera respectively.
173+
174+
~~~~~ python
175+
# Print the x, y and z coordinates of the marker's location
176+
print(marker.cartesian.x, marker.cartesian.y, marker.cartesian.z)
177+
~~~~~
163178

164179
[`Orientation`](#Orientation) {#Orientation}
165180
---------------
@@ -171,62 +186,98 @@ One (possibly both) of them may change to resolve this.
171186

172187
An `Orientation` object describes the orientation of a marker.
173188

174-
![A visual representation of how the orientation axes work. Source: SourceBots]({{ site.baseurl }}/images/content/vision/yaw-pitch-roll.png)
175-
176-
pitch
177-
: Rotation of the marker about the cartesian x-axis, in radians.
189+
rot_x
190+
: Rotation of the marker about the cartesian x-axis, in radians. This is a
191+
pitch-like rotation.
178192

179-
Leaning a marker away from the camera increases the value of `rot_x`, while
180-
leaning it towards the camera decreases it. A value of 0 indicates that the
181-
marker is upright.
193+
Leaning a marker towards the camera increases the value of `rot_x`, while
194+
leaning it away from the camera decreases it. A value of either π or -π
195+
indicates that the marker is upright (there is a discontinuity in the value
196+
at π and -π, as both values represent the same position).
182197

183-
yaw
184-
: Rotation of the marker about the cartesian y-axis, in radians.
198+
rot_y
199+
: Rotation of the marker about the cartesian y-axis, in radians. This is a
200+
yaw-like rotation.
185201

186-
Turning a marker clockwise (as viewed from above) increases the value of
187-
`rot_y`, while turning it anticlockwise decreases it. A value of 0 means
202+
Turning a marker clockwise (as viewed from above) decreases the value of
203+
`rot_y`, while turning it anticlockwise increases it. A value of 0 means
188204
that the marker is perpendicular to the line of sight of the camera.
189205

190-
roll
191-
: Rotation of the marker about the cartesian z-axis, in radians.
206+
rot_z
207+
: Rotation of the marker about the cartesian z-axis, in radians. This is a
208+
roll-like rotation.
192209

193210
Turning a marker anticlockwise (as viewed from the camera) increases the
194211
value of `rot_z`, while turning it clockwise decreases it. A value of 0
195212
indicates that the marker is upright.
196213

197-
rot_x
198-
: An alias for `pitch`.
214+
There are additional attributes for the [principal axis rotations](https://en.wikipedia.org/wiki/Aircraft_principal_axes) of the marker.
199215

200-
rot_y
201-
: An alias for `yaw`.
216+
yaw
217+
: A rotation about the about the vertical axis, in radians (an axis top to
218+
bottom through the token). Turning a marker clockwise (as viewed from above)
219+
increases the value of `yaw`, while turning it anticlockwise decreases it. A
220+
value of 0 means that the marker is perpendicular to the line of sight of
221+
the camera.
202222

203-
rot_z
204-
: An alias for `roll`.
223+
This differs from `rot_y` in the direction that increases the value.
224+
225+
pitch
226+
: A rotation about the transverse axis, in radians (an axis right to left
227+
across the token). Tilting the marker backward increases the value of
228+
`pitch`, while tilting it forwards decreases it. A value of 0 indicates that
229+
the marker is facing the camera square-on.
230+
231+
This differs from `rot_x` in the zero point and direction to increase the value.
232+
233+
roll
234+
: A rotation about the longitudinal axis, in radians (an axis normal from the
235+
apparent front to the back of the token, normal to the marker). Rotating the
236+
marker anti-clockwise (from the perspective of the camera) increases the
237+
value of `roll`, while rotating it clockwise decreases it. A value of 0
238+
indicates that the marker is upright.
239+
240+
This differs from `rot_x` in the zero point and direction to increase the value.
241+
242+
Finally there are attributes which express the orientation in other forms:
205243

206244
rotation_matrix
207-
: The rotation matrix represented by this orientation. A list of 3 lists, each with 3 items.
245+
: The [rotation matrix](https://en.wikipedia.org/wiki/Rotation_matrix) represented by this orientation.
246+
This 3×3 matrix is represented by a list of 3 lists, each with 3 values, in an arrangement compatible with tools such as `numpy`.
208247

209248
quaternion
210-
: The [Quarternion](https://kieranwynn.github.io/pyquaternion/#quaternion-features) instance represented by this orientation.
249+
: The [quaternion](https://en.wikipedia.org/wiki/Quaternion) represented by this orientation.
250+
On the physical kits this is implemented as a [`pyquaternion.Quaternion`](https://kieranwynn.github.io/pyquaternion/#quaternion-features) instance.
251+
252+
<a id="Spherical"/>
211253

212-
[`Spherical`](#Spherical) {#Spherical}
254+
[`SphericalCoordinate`](#SphericalCoordinate) {#SphericalCoordinate}
213255
---------------
214256

215257
The spherical coordinates system has three values to specify a specific point in space.
216258

217-
![A visual representation of Spherical coordinates. Source: SourceBots]({{ site.baseurl }}/images/content/vision/spherical.png)
259+
distance
260+
: The radial distance, the distance from the origin to the point, in millimetres.
261+
262+
theta
263+
: This is the angle from directly in front of the camera to the vector which
264+
points to the location in the horizontal plane, in radians. A positive value
265+
indicates a counter-clockwise rotation. Zero is at the centre of the image.
218266

219-
- r - The radial distance, the distance from the origin to the point, in millimetres.
220-
- θ (theta) - The angle from the azimuth to the point, in radians.
221-
- φ (phi) - The polar angle from the plane of the camera to the point, in radians.
267+
phi
268+
: The polar angle from the y-axis of the camera "down" to the vector which
269+
points to the location, in radians. Zero is directly upward.
270+
271+
Also available are two computed angles which express the same location slightly differently:
222272

223273
rot_x
224-
: Rotation around the X-axis, in radians, corresponding to `theta` on the diagram.
274+
: Approximate rotation around the X-axis, in radians.
275+
This is the angle from the camera's horizontal plane to the vector which
276+
points to the location. Zero is at the centre of the image. Values increase
277+
towards the bottom of the image.
225278

226279
rot_y
227-
: Rotation around the Y-axis, in radians, corresponding to `phi` on the diagram.
228-
229-
dist
230-
: Distance, in millimetres, corresponding to `r` on the diagram.
280+
: Rotation around the Y-axis, in radians. This is similar to `theta`, however
281+
values increase towards the right of the image. Zero is at the centre of the image.
231282

232283
The camera is located at the origin, where the coordinates are (0, 0, 0).

0 commit comments

Comments
 (0)