def run(self, behaviour): #if behavior starts with sound stand_position() if "sound" in str(behaviour): if "1" in behaviour: return sound_1() if "2" in behaviour: return sound_2() if "3" in behaviour: return sound_3() elif "left" in str(behaviour): print("randomly calling left") return self.leftKey() elif "right" in str(behaviour): print("randomly calling right") return self.rightKey() elif "up" in str(behaviour): print("randomly calling up") return self.upKey() elif "down" in str(behaviour): print("randomly calling down") return self.downKey() #else else: managerProxy = ALProxy("ALBehaviorManager", IP_ADDRESS, PORT) managerProxy.runBehavior( str(self.movement_mappings_dict[behaviour]))
def react_movement(self): stand_position() print(self.movement_mappings_dict.keys()) movement = random.choice(list(self.movement_mappings_dict.keys())) self.writeToFile(movement) print("random movement: " + str(movement)) managerProxy = ALProxy("ALBehaviorManager", IP_ADDRESS, PORT) managerProxy.runBehavior(str(movement))
def eye_color(): session = qi.Session() session.connect("tcp://" + IP_ADDRESS + ":9559") leds_service = session.service("ALLeds") # Example showing how to fade the eyes to green stand_position() name = 'FaceLeds' leds_service.rasta(2)
def make_sound(): stand_position() x = random.choice([0, 1, 2]) print("x is " + str(x)) if x == 0: return sound_1() if x == 1: return sound_2() if x == 2: return sound_3()
def gaze_follow(): stand_position() next_move = gazeFollowInteration.get_next_move() if next_move == GazeFollowInteraction.LEFT_HEAD_MOVE: move_head_diagonal(0.45, 0.45) elif next_move == GazeFollowInteraction.RIGHT_HEAD_MOVE: move_head_diagonal(0.45, -0.45) #hold for 5 seconds time.sleep(5) stand_position() return
def make_sound(self): stand_position() print("in make sound") stand_position() x = random.choice([0, 1, 2]) print("x is " + str(x)) self.writeToFile("sound_" + str(x)) if x == 0: return sound_1() if x == 1: return sound_2() if x == 2: return sound_3()
def gaze_follow(self): stand_position() #choose random jingle sound self.play_sound() time.sleep(2) next_move = self.gazeFollowInteration.get_next_move() if next_move == GazeFollowInteraction.LEFT_HEAD_MOVE: self.move_head_diagonal(0.45, 0.45) elif next_move == GazeFollowInteraction.RIGHT_HEAD_MOVE: self.move_head_diagonal(0.45, -0.45) elif next_move == "6/6 done": print("all done") tkMessageBox.showinfo("End of Experiment", "6/6 gaze following done") #hold for 5 seconds time.sleep(5) stand_position() return
def come_on_func(): stand_position() managerProxy = ALProxy("ALBehaviorManager", IP_ADDRESS, PORT) managerProxy.runBehavior("animations/Stand/Gestures/ComeOn_1")
def hand_wave_func(): stand_position() managerProxy = ALProxy("ALBehaviorManager", IP_ADDRESS, PORT) managerProxy.runBehavior("animations/Stand/Gestures/Hey_1")
def dance(): stand_position() managerProxy = ALProxy("ALBehaviorManager", IP_ADDRESS, PORT) managerProxy.runBehavior('gangnamstyle4-9610b3/GangnamStyle')
import Tkinter as tk from StartPage import StartPage from Timer import TimerApp from settings import IP_ADDRESS from settings import PORT from naoqi import ALProxy from stand_position import stand_position stand_position() class MainApp(tk.Tk): def __init__(self): tk.Tk.__init__(self) self._frame = None self.switch_frame(StartPage) self.bind('<Left>', self.leftKey) self.bind('<Right>', self.rightKey) self.bind('<Up>', self.upKey) self.bind('<Down>', self.downKey) def switch_frame(self, frame_class): new_frame = frame_class(self) if self._frame is not None: self._frame.destroy() self._frame = new_frame self._frame.pack() def leftKey(self, event): print "Left key pressed" self.changeAngles("HeadYaw", 0.3)
def peekaboo(self): stand_position() managerProxy = ALProxy("ALBehaviorManager", IP_ADDRESS, PORT) managerProxy.runBehavior("animations/Stand/Waiting/HideEyes_1") self.writeToFile("animations/Stand/Waiting/HideEyes_1")
def wave(self): stand_position() managerProxy = ALProxy("ALBehaviorManager", IP_ADDRESS, PORT) managerProxy.runBehavior("animations/Stand/Gestures/Hey_1") self.writeToFile("animations/Stand/Gestures/Hey_1")