Created
May 21, 2019 23:12
-
-
Save severin-lemaignan/f63e68a7e08971aa6d78b44b8359ca89 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import anki_vector | |
import asyncio | |
from anki_vector.util import degrees, distance_mm, speed_mmps | |
async def on_face(robot, event_type, event): | |
# when a face is detected, say something | |
print("Face seen!") | |
await asyncio.wrap_future(robot.behavior.say_text("I don't like you")) | |
def main(): | |
args = anki_vector.util.parse_command_args() | |
with anki_vector.AsyncRobot(args.serial, enable_face_detection=True) as robot: | |
off_charger_future = robot.behavior.drive_off_charger() | |
off_charger_future.result() # wait until we are out of the charger | |
robot.behavior.set_head_angle(anki_vector.util.degrees(40)) | |
robot.events.subscribe(on_face, anki_vector.events.Events.robot_observed_face) # get notified when a face is seen | |
for _ in range(4): | |
print("Drive Vector straight...") | |
drive_future = robot.behavior.drive_straight(distance_mm(50), speed_mmps(50)) | |
robot.behavior.say_text("Spam") | |
drive_future.result() | |
print("Turn Vector in place...") | |
turn_future = robot.behavior.turn_in_place(degrees(90)) | |
robot.behavior.say_text("Spam") | |
turn_future.result() | |
robot.events.unsubscribe(on_face, anki_vector.events.Events.robot_observed_face) # get notified when a face is seen | |
print("Go back to charger") | |
on_charger_future = robot.behavior.drive_on_charger() | |
robot.behavior.say_text("Boring! Going home.") | |
on_charger_future.result() | |
print("Done!") | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment