You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This documentation refers to a feature which is only available on the physical robot kits.
11
11
</div>
12
12
13
-
The `sr.robot` library contains support for detecting libkoki markers with the provided webcam.
13
+
The `sr.robot3` library contains support for detecting fiducial markers with the provided webcam.
14
14
Markers are attached to various items in the Student Robotics arena.
15
15
Each marker encodes a number in a machine-readable way, which means that robots can identify these objects.
16
-
For information on which markers codes are which, see the [markers page](/docs/programming/sr/vision/markers).
16
+
For information on which markers codes are which, see the [markers page](./markers).
17
17
18
18
Using knowledge of the physical size of the different markers and the characteristics of the webcam,
19
-
libkoki can calculate the position of markers in 3D space relative to the camera.
19
+
your robot can calculate the position of markers in 3D space relative to the camera.
20
20
Therefore, if the robot can see a marker that is at a fixed location in the arena,
21
21
a robot can calculate its exact position in the arena.
22
22
23
-
The `sr.robot` library provides all of this power through a single function, `R.see`:
23
+
Under the hood, the vision system is based on [Zoloto](https://zoloto.readthedocs.io/), a wrapper around [OpenCV's ArUco library](https://docs.opencv.org/4.5.4/d5/dae/tutorial_aruco_detection.html), using the `36H11` marker set from [April](https://april.eecs.umich.edu/software/apriltag)
24
24
25
-
~~~~~python
26
-
from sr.robot import*
27
-
R = Robot()
28
-
markers = R.see()
29
-
~~~~~
25
+
[Camera](#camera) {#camera}
26
+
===========================
27
+
28
+
The interface to the vision system is through the camera, accessible through `R.camera`.
30
29
31
-
When called, this function takes a photo through the webcam and searches for markers within it.
32
-
It returns a list of `Marker` objects, each of which describes one of the markers that were found in the image.
33
-
A detailed description of the attributes of Marker objects is provided [later in this page](#Marker).
30
+
see
31
+
: Take a photo through the webcam, and return a list of [`Marker`](#Marker) instances, each of which describes one of the markers that were found in the image.
34
32
35
33
Here's an example that will repeatedly print out the distance to each arena marker that the robot can see:
36
34
37
35
~~~~~python
38
-
from sr.robotimport*
36
+
from sr.robot3import*
39
37
R = Robot()
40
38
41
39
whileTrue:
42
-
markers = R.see()
40
+
markers = R.camera.see()
43
41
print("I can see", len(markers), "markers:")
44
42
45
43
for m in markers:
46
-
if m.info.marker_type ==MARKER_ARENA:
47
-
print(" - Marker #{0} is {1} metres away".format(m.info.code, m.dist))
44
+
print(" - Marker #{0} is {1} metres away".format(m.id, m.distance))
: Take a photo through the webcam, and return a list of marker ids (**not** full `Marker` objects). This doesn't do the same [pose estimation](https://en.wikipedia.org/wiki/3D_pose_estimation) calculations as `see`, and so is much faster to run.
52
49
53
-
By default, the `R.see` function will take a photo at a resolution of 800x600.
54
-
The resolution that this image is taken at can be changed using the optional `res` argument:
50
+
~~~~~python
51
+
from sr.robot3 import*
52
+
R = Robot()
53
+
54
+
whileTrue:
55
+
marker_ids = R.camera.see_ids()
56
+
57
+
if0in marker_ids:
58
+
print("I can see marker 0!")
59
+
else:
60
+
print("I cannot see marker 0!")
61
+
~~~~~
62
+
63
+
save
64
+
: Take a photo through the webcam, and save it to the provided location.
Copy file name to clipboardExpand all lines: programming/sr/vision/markers.md
+16-20Lines changed: 16 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,23 +6,19 @@ title: Markers
6
6
Markers
7
7
=======
8
8
9
-
<imgsrc="{{ site.baseurl }}/images/content/marker-0.png"alt="An Example Marker: Arena marker 0"class="right" />
10
-
An example *libkoki* marker is given to the right; this one is *arena-0*.
11
-
There is a dot in the top-left corner of the black border. This corner is known as the *principal corner*, and its location is important if measuring the marker's orientation about the Z-axis.
12
-
There is also some text in the bottom-left corner of the black border.
13
-
This text will say something like `"libkoki marker #0 (v0.5) 'ARENA'"`.
14
-
Let's break that down:
15
-
`#0` means marker number 0;
16
-
`(v0.5)` tells you the version of the marker, it is important the latest version is used; and
17
-
`'ARENA'` is just a human-readable description of what the marker is for.
18
-
19
-
Details of the types and size of markers used in the SR2020 game can be found in the [rules](/docs/rules).
20
-
21
-
You can download all of the markers as a single [ZIP file](/docs/resources/2020/sr-dev-markers-sr2020.zip)
22
-
or individually from the [git repo](https://github.com/srobo/game-markers/tree/master/SR2020/dev).
23
-
The arena markers, due to their size, need to be printed on A3 paper.
24
-
Token markers can be printed on A4 so long as your printer can handle the very narrow 5mm page margins; if not, they will need to be printed on A3 as well.
25
-
Ensure you download the correct file for the paper size you intend to print on - the filenames all end in "-A3paper.pdf" or "-A4paper.pdf".
9
+
<imgsrc="{{ site.baseurl }}/images/content/vision/marker-0.png"alt="An Example Marker: 0"class="right half" />
10
+
11
+
An example marker is given to the right; this one is `0`. The marker is the correct way up, as shown by the text in the bottom left corner.
12
+
13
+
There is also some text in the bottom-left corner of the marker, in its padding: `Student Robotics APRILTAG_36H11 - Dev #0`.
14
+
15
+
-`#0` means marker number 0
16
+
-`APRILTAG_36H11` is the marker type
17
+
-`Dev` shows it's a development marker, rather than a competition marker
18
+
19
+
Details of the types and size of markers used in the game can be found in the [rules](/docs/rules).
20
+
21
+
You can download all the markers as a single [ZIP file](/docs/resources/2022/sr-dev-markers-sr2022.zip) or individually from the [git repo](https://github.com/srobo/game-markers/tree/master/SR2022/dev).
26
22
27
23
You must ensure that your PDF viewer is not resizing the documents when printing.
28
24
This can be checked by measuring the grey box around the marker and comparing this to the size defined in the rules.
@@ -32,6 +28,6 @@ Note that a different set of markers will be used in the arenas at the competiti
32
28
However, this is not something you need to worry about.
33
29
We will handle this for you automatically when your robot is started in competition mode.
34
30
35
-
The white space around the markers is very important -- without it, the markers probably won't be recognised.
36
-
If the markers become damaged (scuff markers, tears, etc...) they will not function as well (if at all).
37
-
If this happens, it is best to just print another one.
31
+
The white space around the markers is very important -- without it, the markers probably won't be recognised. This white border is needed to ensure there's enough contrast between the black marker and whatever it's attached to - its size isn't strictly important.
32
+
33
+
If the markers become damaged (scuff markers, tears, etc...) they will not function as well (if at all). If this happens, it is best to just print another one.
0 commit comments