File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed
Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -124,3 +124,41 @@ conventionally is in the top left corner of the image.
124124 for m in markers:
125125 print (m.pixel_corners) # Pixel positions of the marker corners within the image.
126126 print (m.pixel_centre) # Pixel positions of the centre of the marker within the image.
127+
128+ Example
129+ -------
130+
131+ .. code :: python
132+
133+ from sbot import *
134+ import sys
135+ from math import degrees
136+
137+ r = Robot()
138+
139+ # Find the nearest cube
140+ markers = r.camera.see()
141+
142+ while len (markers) == 0 : # Wait for some markers to appear
143+ markers = r.camera.see()
144+
145+ cubes = [] # Make a list for all the cube faces
146+ for marker in markers:
147+ if marker.size == 80 : # Markers on cubes are 80mm wide
148+ cubes.append(marker)
149+
150+ if len (cubes) == 0 :
151+ print (" no cubes :(" )
152+ sys.exit()
153+
154+ nearest = tokens[0 ] # Find the nearest one
155+ for marker in cubes:
156+ if marker.distance < nearest.distance:
157+ nearest = marker
158+
159+ print (" nearest marker:" )
160+ print (f " id { nearest.id} " )
161+ print (f " zone { nearest.id - 28 } " )
162+ print (f " { nearest.distance} metres away " )
163+ print (f " bearing { degrees(nearest.spherical.rot_y)} " )
164+
You can’t perform that action at this time.
0 commit comments