-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathLight ex.py
More file actions
20 lines (19 loc) · 811 Bytes
/
Light ex.py
File metadata and controls
20 lines (19 loc) · 811 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import asyncio
import time
import cozmo
def light_when_face(robot: cozmo.robot.Robot):
robot.move_lift(-3)
robot.set_head_angle(cozmo.robot.MAX_HEAD_ANGLE).wait_for_completed()
face = None
while True:
if face and face.is_visible:
robot.set_all_backpack_lights(cozmo.lights.green_light)
robot.say_text("Hello, I can see you!").wait_for_completed()
else:
robot.set_backpack_lights_off()
try:
face = robot.world.wait_for_observed_face(timeout=30)
robot.say_text("I cannot see you now!").wait_for_completed()
except asyncio.TimeoutError:
return
cozmo.run_program(light_when_face, use_viewer=True, force_viewer_on_top=True)