Skip to content

Commit 7358a55

Browse files
author
Michelle Sintov
authored
Update from master for private alpha anki#13
1 parent ff7b8b4 commit 7358a55

8 files changed

Lines changed: 146 additions & 68 deletions

File tree

anki_vector/camera.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,24 @@ def latest_image(self) -> Image.Image:
9696

9797
return self._latest_image
9898

99-
# TODO Needs sample code
10099
@property
101100
def latest_image_id(self) -> int:
102101
"""The most recently processed image's id received from the robot.
103102
104103
Used only to track chunks of the same image.
105104
106105
:getter: Returns the id for the latest image
106+
107+
.. testcode::
108+
109+
import anki_vector
110+
import time
111+
112+
with anki_vector.Robot(enable_camera_feed=True) as robot:
113+
time.sleep(1)
114+
image = robot.camera.latest_image
115+
image.show()
116+
print(f"latest_image_id: {robot.camera.latest_image_id}")
107117
"""
108118
return self._latest_image_id
109119

anki_vector/faces.py

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,10 @@ def face_id(self) -> int:
134134
135135
import anki_vector
136136
137-
# Print the visible face ids
138-
for face in robot.world.visible_faces:
139-
print(f"Visible id: {face.face_id}")
137+
with anki_vector.Robot(enable_face_detection=True) as robot:
138+
# Print the visible face ids
139+
for face in robot.world.visible_faces:
140+
print(f"Visible id: {face.face_id}")
140141
"""
141142
return self._face_id if self._updated_face_id is None else self._updated_face_id
142143

@@ -154,9 +155,9 @@ def has_updated_face_id(self) -> bool:
154155
155156
import anki_vector
156157
157-
with anki_vector.Robot() as robot:
158-
face = robot.world.get_face(1)
159-
was_face_originally_unrecognized_but_is_now_recognized = face.has_updated_face_id
158+
with anki_vector.Robot(enable_face_detection=True) as robot:
159+
for face in robot.world.visible_faces:
160+
was_face_originally_unrecognized_but_is_now_recognized = face.has_updated_face_id
160161
"""
161162
return self._updated_face_id is not None
162163

@@ -168,9 +169,9 @@ def updated_face_id(self) -> int:
168169
169170
import anki_vector
170171
171-
with anki_vector.Robot() as robot:
172-
face = robot.world.get_face(1)
173-
updated_id = face.updated_face_id
172+
with anki_vector.Robot(enable_face_detection=True) as robot:
173+
for face in robot.world.visible_faces:
174+
print(f"updated_face_id: {face.updated_face_id}")
174175
"""
175176
if self._updated_face_id:
176177
return self._updated_face_id
@@ -186,9 +187,9 @@ def name(self) -> str:
186187
187188
import anki_vector
188189
189-
with anki_vector.Robot() as robot:
190-
face = robot.world.get_face(1)
191-
name = face.name
190+
with anki_vector.Robot(enable_face_detection=True) as robot:
191+
for face in robot.world.visible_faces:
192+
print(f"Face name: {face.name}")
192193
"""
193194
return self._name
194195

@@ -207,9 +208,9 @@ def expression(self) -> str:
207208
208209
import anki_vector
209210
210-
with anki_vector.Robot() as robot:
211-
face = robot.world.get_face(1)
212-
expression = face.expression
211+
with anki_vector.Robot(enable_face_detection=True) as robot:
212+
for face in robot.world.visible_faces:
213+
print(f"expression: {face.expression}")
213214
"""
214215
return self._expression
215216

@@ -225,9 +226,9 @@ def expression_score(self) -> List[int]:
225226
226227
import anki_vector
227228
228-
with anki_vector.Robot() as robot:
229-
face = robot.world.get_face(1)
230-
expression_score = face.expression_score
229+
with anki_vector.Robot(enable_face_detection=True) as robot:
230+
for face in robot.world.visible_faces:
231+
print(f"expression_score: {face.expression_score}")
231232
"""
232233
return self._expression_score
233234

@@ -239,9 +240,9 @@ def left_eye(self) -> List[protocol.CladPoint]:
239240
240241
import anki_vector
241242
242-
with anki_vector.Robot() as robot:
243-
face = robot.world.get_face(1)
244-
left_eye = face.left_eye
243+
with anki_vector.Robot(enable_face_detection=True) as robot:
244+
for face in robot.world.visible_faces:
245+
print(f"left_eye: {face.left_eye}")
245246
"""
246247
return self._left_eye
247248

@@ -253,9 +254,9 @@ def right_eye(self) -> List[protocol.CladPoint]:
253254
254255
import anki_vector
255256
256-
with anki_vector.Robot() as robot:
257-
face = robot.world.get_face(1)
258-
right_eye = face.right_eye
257+
with anki_vector.Robot(enable_face_detection=True) as robot:
258+
for face in robot.world.visible_faces:
259+
print(f"right_eye: {face.right_eye}")
259260
"""
260261
return self._right_eye
261262

@@ -267,9 +268,9 @@ def nose(self) -> List[protocol.CladPoint]:
267268
268269
import anki_vector
269270
270-
with anki_vector.Robot() as robot:
271-
face = robot.world.get_face(1)
272-
nose = face.nose
271+
with anki_vector.Robot(enable_face_detection=True) as robot:
272+
for face in robot.world.visible_faces:
273+
print(f"nose: {face.nose}")
273274
"""
274275
return self._nose
275276

@@ -281,9 +282,9 @@ def mouth(self) -> List[protocol.CladPoint]:
281282
282283
import anki_vector
283284
284-
with anki_vector.Robot() as robot:
285-
face = robot.world.get_face(1)
286-
mouth = face.mouth
285+
with anki_vector.Robot(enable_face_detection=True) as robot:
286+
for face in robot.world.visible_faces:
287+
print(f"mouth: {face.mouth}")
287288
"""
288289
return self._mouth
289290

@@ -332,6 +333,7 @@ async def request_enrolled_names(self) -> protocol.RequestEnrolledNamesRequest:
332333
333334
with anki_vector.Robot() as robot:
334335
name_data_list = robot.faces.request_enrolled_names()
336+
print(f"{name_data_list}")
335337
"""
336338
req = protocol.RequestEnrolledNamesRequest()
337339
return await self.grpc_interface.RequestEnrolledNames(req)

anki_vector/motors.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,11 @@ async def set_wheel_motors(self,
4141
.. testcode::
4242
4343
import anki_vector
44+
import time
4445
4546
with anki_vector.Robot() as robot:
4647
robot.motors.set_wheel_motors(25, 50)
48+
time.sleep(3.0)
4749
4850
:param left_wheel_speed: Speed of the left tread (in millimeters per second).
4951
:param right_wheel_speed: Speed of the right tread (in millimeters per second).
@@ -91,9 +93,13 @@ async def set_lift_motor(self,
9193
.. testcode::
9294
9395
import anki_vector
96+
import time
9497
9598
with anki_vector.Robot() as robot:
9699
robot.motors.set_lift_motor(-5.0)
100+
time.sleep(3.0)
101+
robot.motors.set_lift_motor(5.0)
102+
time.sleep(3.0)
97103
98104
:param speed: Motor speed for Vector's lift, measured in radians per second.
99105
"""

anki_vector/nav_map.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ def get_content(self, x: float, y: float) -> protocol.NavNodeContentType:
311311
time.sleep(1)
312312
latest_nav_map = robot.nav_map.latest_nav_map
313313
content = latest_nav_map.get_content(0.0, 100.0)
314-
print('Sampling point at 0.0, 100.0 and found content '.format(content))
314+
print(f"Sampling point at 0.0, 100.0 and found content: {content}")
315315
316316
Returns:
317317
The content included at that point. Will be :attr:`NavNodeContentTypes.Unknown`

0 commit comments

Comments
 (0)