def botLoser(): print("Bot Interaction: Game Loser") speak("You are the winner!", "You_win.mp3") speak("I am sad.", "sad.mp3") face.sad() time.sleep(3) arms.reset()
def playMusic(): print("Bot Interaction: Playing music") speak("Look at me playing music!", "Playing_music.mp3") arms.reset() arms.bangDrumLeft() arms.bangDrumRight() arms.bangDrumRight() arms.bangDrumLeft()
def playGame(self): print("Playing game...") speak("OK. Let's play rock paper scissors.", "RPC.mp3") time.sleep(0.5) # Do countdown for the user print("Ready?...") speak("Ready?", "ready.mp3") time.sleep(1) print("Rock...") speak("Rock", "rock.mp3") time.sleep(1) print("Paper...") speak("Paper", "paper.mp3") time.sleep(1) print("Scissors...") speak("Scissors", "scissors.mp3") time.sleep(1) print("Go!") speak("Go!", "go.mp3") time.sleep(1) # Get the user gesture user_gest = "unknown" while user_gest != 'rock' and user_gest != 'paper' and user_gest != 'scissors': take_image() user_gest = get_gesture() print("User gesture: " + user_gest) if user_gest != 'rock' and user_gest != 'paper' and user_gest != 'scissors': print("Bot Confused") speak("Please try again.") # Calculate robot gesture and determine winner bot_gesture = self.generateGesture() result = self.gameResult(bot_gesture, user_gest) if (result == WINNER): print("User is the winner") botWinner() if (result == LOSER): print("User is the loser") botLoser() else: print("User and robot tied") botTied() # Reset the robot servos arms.reset() face.reset() time.sleep(3) print("Finished playing game")
def botTied(): print("Bot Interaction: Game Tied") speak("We tied the game.", "Tie.mp3") arms.reset() face.reset()
def MainTest(): time.sleep(0.8) print("Running main test") servos.setMovementFrame(0) arms.reset() # Test audio output speak( 'I am running a test on my body! If my movement is not matched to my words, it means something is broken!', "Diagnostic.mp3") time.sleep(TEST_SLEEP_TIME) speak("right eyebrow up", "right_eyebrow_up.mp3") servos.setServoPosition(EYEBROW_R, 100) servos.beginMotion() speak("right eyebrown down", "right_eyebrow_down.mp3") servos.setServoPosition(EYEBROW_R, 50) servos.beginMotion() speak("right eyebrow flat", "right_eyebrow_flat.mp3") servos.setServoPosition(EYEBROW_R, 80) servos.beginMotion() speak("left eyebrow up", "left_eyebrow_up.mp3") servos.setServoPosition(EYEBROW_L, 100) servos.beginMotion() speak("left eyebrow down", "left_eyebrow_down.mp3") servos.setServoPosition(EYEBROW_L, 50) servos.beginMotion() speak("left eyebrow flat", "left_eyebrow_flat.mp3") servos.setServoPosition(EYEBROW_L, 80) servos.beginMotion() #speak("eyes close", "eyes_close.mp3") #servos.setServoPosition(servoID, pos) #servos.beginMotion() #speak("eyes open", "eyes_open.mp3") #servos.setServoPosition(servoID, pos) #servos.beginMotion() speak("mouth open", "mouth_open.mp3") servos.setServoPosition(MOUTH, 50) servos.beginMotion() speak("mouth close", "mouth_close.mp3") servos.setServoPosition(MOUTH, 20) servos.beginMotion() speak("right shoulder up", "right_shoulder_up.mp3") servos.setServoPosition(ARM_UPDOWN_R, 30) servos.beginMotion() speak("right shoulder down", "right_shoulder_down.mp3") servos.setServoPosition(ARM_UPDOWN_R, 70) servos.beginMotion() speak("left shoulder up", "left_shoulder_up.mp3") servos.setServoPosition(ARM_UPDOWN_L, 90) servos.beginMotion() speak("left shoulder down", "left_shoulder_down.mp3") servos.setServoPosition(ARM_UPDOWN_L, 50) servos.beginMotion() speak("right arm out", "right_arm_out.mp3") servos.setServoPosition(ARM_ROTATE_R, 80) servos.beginMotion() speak("right elbow down", "right_elbow_down.mp3") servos.setServoPosition(ELBOW_R, 90) servos.beginMotion() speak("right elbow up", "right_elbow_up.mp3") servos.setServoPosition(ELBOW_R, 30) servos.beginMotion() speak("right arm in", "right_arm_in.mp3") servos.setServoPosition(ARM_ROTATE_R, 30) servos.beginMotion() #recenter the arm servos.setServoPosition(ARM_ROTATE_R, 55) speak("left arm out", "left_arm_out.mp3") servos.setServoPosition(ARM_ROTATE_L, 50) servos.beginMotion() speak("left elbow down", "left_elbow_down.mp3") servos.setServoPosition(ELBOW_L, 100) servos.beginMotion() speak("left elbow up", "left_elbow_up.mp3") servos.setServoPosition(ELBOW_L, 120) servos.beginMotion() speak("left arm in", "left_arm_in.mp3") servos.setServoPosition(ARM_ROTATE_L, 65) servos.beginMotion() #recenter the arm servos.setServoPosition(ARM_ROTATE_L, 65) servos.beginMotion() speak("Bang right drum", "bang_right_drum.mp3") arms.bangDrumRight() speak("Bang left drum", "bang_left_drum.mp3") arms.bangDrumLeft() speak("Play music!", "music.mp3") playMusic()