Last active
November 17, 2018 05:13
-
-
Save invokesus/f5243536b0a74db212596b0280b2aae0 to your computer and use it in GitHub Desktop.
This file contains 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 os | |
import naoqi | |
import sys | |
from naoqi import ALProxy | |
IP = "" | |
PORT = "" | |
try: | |
tts = ALProxy("ALTextToSpeech", IP, PORT) | |
motionProxy = ALProxy("ALMotion", IP, PORT) | |
postureProxy = ALProxy("ALRobotPosture", IP, PORT) | |
except Exception, e: | |
print "Could not create proxy to ALTextToSpeech" | |
print "Error was: ", e | |
sys.exit(1) | |
initial_time = os.path.getmtime('./label.txt') | |
responses = {"person": "Hello. Nice to meet you!", | |
"ball": "Want to play?", "bottle": "Thanks! I was thirsty.", | |
"book": "Tell me a story!"} | |
curr_time = None | |
flag = false | |
while True: | |
curr_time = os.path.getmtime('./label.txt') | |
if (curr_time != initial_time and not flag): | |
flag = true | |
with open("./label.txt", "r") as f: | |
word = f.readline() | |
if word != "": | |
tts.say(responses.get(word)) | |
if word == "ball": | |
motionProxy.wakeUp() | |
postureProxy.goToPosture("StandZero", 1.0) | |
elif word == "book": | |
motionProxy.goToPosture("SitRelax", 1.0) | |
elif word == "bottle": | |
x = 0.4 | |
y = 0.4 | |
theta = 0 | |
motionProxy.moveTo(x, y, theta) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment