def send_fidget_message(self, fidget):
     """ Publish TegaAction message setting the fidget set in use. """
     if self.tega_pub is not None:
         print('\nsending fidget message: %s' % fidget)
         msg = TegaAction()
         # add header
         msg.header = Header()
         msg.header.stamp = rospy.Time.now()
         msg.fidgets = fidget
         self.tega_pub.publish(msg)
         rospy.loginfo(msg)
 def send_motion_message(self, motion):
     """ Publish TegaAction do motion message """
     if self.tega_pub is not None:
         print('sending motion message: %s' % motion)
         msg = TegaAction()
         # add header
         msg.header = Header()
         msg.header.stamp = rospy.Time.now()
         msg.motion = motion
         self.tega_pub.publish(msg)
         rospy.loginfo(msg)
 def send_speech_message(self, speech):
     """ Publish TegaAction playback audio message """
     if self.tega_pub is not None:
         print('\nsending speech message: %s' % speech)
         msg = TegaAction()
         # add header
         msg.header = Header()
         msg.header.stamp = rospy.Time.now()
         msg.wav_filename = speech
         self.tega_pub.publish(msg)
         rospy.loginfo(msg)
 def send_volume_message(self, volume):
     """ Publish TegaAction message setting the percent volume to use. """
     if self.tega_pub is not None:
         print('\nsending volume message: %s' % volume)
         msg = TegaAction()
         # add header
         msg.header = Header()
         msg.header.stamp = rospy.Time.now()
         msg.set_volume = True
         msg.percent_volume = volume
         self.tega_pub.publish(msg)
         rospy.loginfo(msg)
 def send_lookat_message(self, lookat):
     """ Publish TegaAction lookat message """
     if self.tega_pub is not None:
         print('sending lookat message: %s' % lookat)
         msg = TegaAction()
         # add header
         msg.header = Header()
         msg.header.stamp = rospy.Time.now()
         msg.do_look_at = True
         msg.look_at = lookat
         self.tega_pub.publish(msg)
         rospy.loginfo(msg)
Exemple #6
0
def send_tega_action_message(audio_file, visemes, energies, times):
    """ Publish TegaAction message to playback audio. """
    LOGGER.info("\nsending speech message: {}".format(audio_file))
    msg = TegaAction()
    # Add header.
    msg.header = Header()
    msg.header.stamp = rospy.Time.now()
    msg.wav_filename = audio_file
    msg.visemes = visemes
    msg.energy_values = energies
    msg.energy_times = times
    msg.enqueue = True
    PUB_TEGA_ACTION.publish(msg)
 def send_tega_animation(self, motion):
     """ Publish a Tega command message. """
     if self._tega_pub is None:
         self._logger.warning("TegaAction ROS publisher is none!")
         return
     self._logger.info("Sending Tega command: {}".format(motion))
     # Build message.
     msg = TegaAction()
     msg.header = Header()
     msg.header.stamp = rospy.Time.now()
     msg.motion = motion
     # Send message.
     self._tega_pub.publish(msg)
     self._logger.debug(msg)
Exemple #8
0
 def send_tega_command(self,
                       motion="",
                       lookat=None,
                       audio="",
                       fidgets="",
                       enqueue=False,
                       cancel=False,
                       volume=None):
     """ Publish a Tega command message and optionally wait for a response.
     """
     # We may need to send a TegaAction message with any or all of these
     # parameters.
     # pylint: disable=too-many-arguments
     if self._tega_pub is None:
         self._logger.warning("TegaAction ROS publisher is none!")
         return
     self._logger.info("Sending Tega command...")
     # Build message.
     msg = TegaAction()
     # Add header.
     msg.header = Header()
     msg.header.stamp = rospy.Time.now()
     # If parameters are set, add them to the message...
     msg.motion = motion
     if lookat is not None:
         msg.do_look_at = True
         msg.look_at = lookat
     msg.wav_filename = audio
     msg.fidgets = fidgets
     msg.enqueue = enqueue
     msg.cancel_actions = cancel
     if volume is not None:
         msg.percent_volume = volume
         msg.set_volume = True
     # Send message.
     self._tega_pub.publish(msg)
     self._logger.debug(msg)
Exemple #9
0
def send_tega_command(lookat=None, motion=None):
    """ Publish a Tega command message containing a lookat command or a motion
    command.
    """
    if not TEGA_PUB:
        LOGGER.warning("No TegaAction ROS publisher is setup!")
        return
    LOGGER.info("Sending Tega lookat command...")
    # Build message.
    msg = TegaAction()
    # Add header.
    msg.header = Header()
    msg.header.stamp = rospy.Time.now()
    # Add the lookat command and/or motion command.
    if lookat is not None:
        msg.do_look_at = True
        msg.look_at = lookat
    if motion is not None:
        msg.motion = motion
    # Queue the action so it doesn't play over or interrupt anything.
    msg.enqueue = True
    # Send message.
    TEGA_PUB.publish(msg)
    LOGGER.info(msg)
    def get_msg_from_behavior(command, *args): #pylint: disable=too-many-branches, too-many-statements

        msg = TegaAction()
        msg.header = Header()
        msg.header.stamp = rospy.Time.now()

        if command == RobotBehaviors.LOOK_AT_TABLET:
            lookat_pos = Vec3()
            lookat_pos.x = 0
            lookat_pos.y = 2
            lookat_pos.z = 20
            msg.do_look_at = True
            msg.look_at = lookat_pos

        elif command == RobotBehaviors.LOOK_CENTER:
            lookat_pos = Vec3()
            lookat_pos.x = 0
            lookat_pos.y = 10
            lookat_pos.z = 40
            msg.do_look_at = True
            msg.look_at = lookat_pos

        elif command == RobotBehaviors.SAY_HI:
            msg.wav_filename = "vocab_games/effects/say_hi.wav"

        ## Basic Ring Ins

        elif command == RobotBehaviors.RING_ANSWER_CORRECT:
            msg.motion = "PERKUP"
            
        elif command == RobotBehaviors.LATE_RING:
            msg.motion = "PERKUP"            

        elif command == RobotBehaviors.PRONOUNCE_CORRECT:
            msg.enqueue = True
            msg.wav_filename = "vocab_games/words/" + args[0][0].lower() + ".wav"

        elif command == RobotBehaviors.PRONOUNCE_WRONG_SOUND:
            msg.enqueue = True
            num = randint(0, 3)
            if num == 0:
                msg.wav_filename = "vocab_games/effects/thinking1.wav"
            elif num == 1:
                msg.wav_filename = "vocab_games/effects/puzzled1.wav"
            elif num == 2:
                msg.wav_filename = "vocab_games/effects/confused1.wav"                        
            elif num == 3:
                msg.motion = "THINKING"                        


        #### Reactions                 

        elif command == RobotBehaviors.REACT_TO_BEAT_CORRECT:
            num = randint(0, 2)
            if num == 0:
                msg.motion = "FRUSTRATED"
            elif num == 1:
                msg.wav_filename = "vocab_games/effects/angry2.wav"
            elif num == 2:
                msg.wav_filename = "vocab_games/effects/angry4.wav"


        elif command == RobotBehaviors.REACT_TO_BEAT_WRONG:
            num = randint(0, 1)
            if num == 0:
                msg.wav_filename = "vocab_games/effects/laugh1.wav"
            elif num == 1:
                msg.wav_filename = "vocab_games/effects/laugh2.wav"

        elif command == RobotBehaviors.REACT_ROBOT_CORRECT:
            num = randint(0, 1)
            if num == 0:
                msg.motion = "SMILE"
            elif num == 1:
                msg.wav_filename = "vocab_games/effects/woohoo1.wav"                
            

        elif command == RobotBehaviors.REACT_ROBOT_WRONG:
            num = randint(0, 1)
            if num == 0:
                msg.wav_filename = "vocab_games/effects/aww1.wav"
            elif num == 1:
                msg.wav_filename = "vocab_games/effects/sigh2.wav"

        elif command == RobotBehaviors.REACT_PLAYER_CORRECT:
            num = randint(0, 3)
            if num == 0:
                msg.motion = "SMILE"
            elif num == 1:
                msg.wav_filename = "vocab_games/effects/yes1.wav"
            elif num == 2:
                msg.wav_filename = "vocab_games/effects/good_job.wav"                    
            elif num == 3:
                msg.motion = "YES"                                    
            

        elif command == RobotBehaviors.REACT_PLAYER_WRONG:
            num = randint(0, 2)
            if num == 0:
                msg.wav_filename = "vocab_games/effects/aww1.wav"
            elif num == 1:
                msg.wav_filename = "vocab_games/effects/serene.wav"                
            elif num == 2:
                msg.motion = "NO"

        elif command == RobotBehaviors.WIN_MOTION:
            msg.motion = TegaAction.MOTION_EXCITED

        elif command == RobotBehaviors.WIN_SPEECH:
            pass
            # msg.wav_filename = "vocab_games/effects/woohoo1.wav"

        elif command == RobotBehaviors.LOSE_MOTION:
            msg.motion = TegaAction.MOTION_SAD

        elif command == RobotBehaviors.LOSE_SPEECH:
            pass
            # msg.wav_filename = "vocab_games/effects/sigh1.wav"
        elif command == RobotBehaviors.PLAYER_RING_PROMPT:
            num = randint(0, 1)
            if num == 0:
                msg.wav_filename = "vocab_games/effects/interested.wav"
            elif num == 1:
                msg.wav_filename = "vocab_games/effects/deep_think.wav"            

        return msg
    def get_msg_from_behavior(command, *args): #pylint: disable=too-many-branches, too-many-statements

        msg = TegaAction()
        msg.header = Header()
        msg.header.stamp = rospy.Time.now()


        ## Look at Commands
        if command == RobotBehaviors.LOOK_AT_TABLET:
            lookat_pos = Vec3()
            lookat_pos.x = 0
            lookat_pos.y = -10
            lookat_pos.z = 20
            msg.do_look_at = True
            msg.look_at = lookat_pos

        if command == RobotBehaviors.LOOK_CENTER:
            lookat_pos = Vec3()
            lookat_pos.x = 0
            lookat_pos.y = 10
            lookat_pos.z = 40
            msg.do_look_at = True
            msg.look_at = lookat_pos

        ## Positive Commands
        if command == RobotBehaviors.ROBOT_EXCITED:
            msg.motion = TegaAction.MOTION_EXCITED

        if command == RobotBehaviors.ROBOT_INTERESTED:
            msg.motion = TegaAction.MOTION_INTERESTED

        if command == RobotBehaviors.ROBOT_YES:
            msg.motion = TegaAction.MOTION_YES

        if command == RobotBehaviors.ROBOT_HAPPY_DANCE:
            msg.motion = TegaAction.MOTION_HAPPY_DANCE

        if command == RobotBehaviors.ROBOT_CURIOUS:
            msg.motion = TegaAction.MOTION_POSE_FORWARD

        if command == RobotBehaviors.ROBOT_ATTENTION:
            msg.motion = TegaAction.MOTION_SHIMMY

        if command == RobotBehaviors.ROBOT_CELEBRATION:
            msg.motion = TegaAction.MOTION_CIRCLING

        if command == RobotBehaviors.ROBOT_ENCOURAGING:
            msg.motion = TegaAction.MOTION_PERKUP

        if command == RobotBehaviors.ROBOT_WINK:
            msg.motion = TegaAction.MOTION_NOD

        if command == RobotBehaviors.ROBOT_THINKING:
            msg.motion = TegaAction.MOTION_THINKING


        ## Negative Commands
        if command == RobotBehaviors.ROBOT_SAD:
            msg.motion = TegaAction.MOTION_SAD

        if command == RobotBehaviors.ROBOT_UNSURE:
            msg.motion = TegaAction.MOTION_PUZZLED

        if command == RobotBehaviors.ROBOT_COMFORT:
            msg.motion = TegaAction.MOTION_FLAT_AGREEMENT 

        if command == RobotBehaviors.ROBOT_ASK_HELP:
            msg.motion = TegaAction.MOTION_POSE_FORWARD

        if command == RobotBehaviors.ROBOT_DISAPPOINTED:
            msg.motion = TegaAction.MOTION_FRUSTRATED 


        ## Silent Emotion Commands
        if command == RobotBehaviors.ROBOT_SILENT_SAD:
            msg.motion = TegaAction.MOTION_SILENT_SAD

        if command == RobotBehaviors.ROBOT_SILENT_NOD:
            msg.motion = TegaAction.MOTION_SILENT_NOD

        if command == RobotBehaviors.ROBOT_SILENT_HAPPY_DANCE:
            msg.motion = TegaAction.MOTION_SILENT_HAPPY_DANCE

        if command == RobotBehaviors.ROBOT_SILENT_YES:
            msg.motion = TegaAction.MOTION_SILENT_YES

        if command == RobotBehaviors.ROBOT_SILENT_PUZZLED:
            msg.motion = TegaAction.MOTION_SILENT_PUZZLED

        if command == RobotBehaviors.ROBOT_SILENT_FRUSTRATED:
            msg.motion = TegaAction.MOTION_SILENT_FRUSTRATED

        if command == RobotBehaviors.ROBOT_SILENT_INTERESTED:
            msg.motion = TegaAction.MOTION_SILENT_INTERESTED

        if command == RobotBehaviors.ROBOT_SILENT_EXCITED:
            msg.motion = TegaAction.MOTION_SILENT_HAPPY_WIGGLE

        # Tega speech commands
        if command == RobotBehaviors.ROBOT_HINT_BUTTON_REMINDER:
            msg.wav_filename = ROOT_TEGA_SPEECH_FOLDER + "general/others/mission_reminder.wav"
            msg.motion = TegaAction.MOTION_SILENT_PUZZLED
            msg.enqueue = True

        if command == RobotBehaviors.ROBOT_CUSTOM_SPEECH:
            msg.wav_filename = args[0][0].lower()
            msg.enqueue = True

        if command == RobotBehaviors.NOVICE_ROLE_KEYWORD:
            PATH = ROOT_TEGA_SPEECH_FOLDER + "general/novice_keyword/"
            vocab_word = args[0][0].lower()
            msg.wav_filename = PATH + "novice_"+ vocab_word + ".wav"
            msg.motion = TegaAction.MOTION_SILENT_PUZZLED
            msg.enqueue = True


        ### ============== Tega Speech for Role Switching Project ================== ###
        if command == RobotBehaviors.BEFORE_GAME_SPEECH:
            PATH = ROOT_TEGA_SPEECH_FOLDER + "general/before_game/"
            file = "before_game_"+random.choice(["1", "3"])+".wav"
            msg.wav_filename = PATH + file
            msg.motion = TegaAction.MOTION_SILENT_HAPPY_WIGGLE
            print("before game speech wav: "+msg.wav_filename)

        if command == RobotBehaviors.VOCAB_EXPLANATION_SPEECH:
            PATH = ROOT_TEGA_SPEECH_FOLDER + "general/vocab_explanation/"
           
            vocab_word = args[0][0][0].lower()
            itype = args[0][0][1].lower()
            file = vocab_word+"_"+itype+"_explanation.wav"
            msg.wav_filename = PATH + file
            msg.motion = TegaAction.MOTION_SILENT_HAPPY_DANCE

        if command == RobotBehaviors.HINT_SPEECH:
            PATH = ROOT_TEGA_SPEECH_FOLDER + "general/hint/"
            vocab_word = args[0][0].lower()
            msg.wav_filename = PATH + vocab_word + "_hint.wav"
            msg.motion = TegaAction.MOTION_SILENT_HAPPY_WIGGLE
            print("hint speech wav: "+msg.wav_filename)

        if command == RobotBehaviors.KEYWORD_DEFINITION_SPEECH:
            PATH = ROOT_TEGA_SPEECH_FOLDER + "general/keyword_definition/"
            file = args[0][0].lower()+"_definition.wav"
            msg.wav_filename = PATH + file
            msg.motion = TegaAction.MOTION_SILENT_NOD
            print("key word definition speech wav: "+msg.wav_filename)

        if command == RobotBehaviors.REMINDER_SPEECH: 
            PATH = ROOT_TEGA_SPEECH_FOLDER + "general/reminder/"
            file = args[0][0].lower() + "_reminder_" + random.choice(["1", "2", "3"]) + ".wav"
            msg.wav_filename = PATH + file
            msg.motion = "" 
            print ("reminder speech wav: "+msg.wav_filename)

        ### ====== Tega End of Task Celebration =========== ####

        if command == RobotBehaviors.ROBOT_TASK_END_BEHAVIOR:
            PATH = ROOT_TEGA_SPEECH_FOLDER + "general/between_missions/"
            file = "between_missions_"
            speech_file = PATH + file + str(int(args[0][0])) + ".wav"
            msg.wav_filename = speech_file
            print("between missions celebration: "+msg.wav_filename)

        if command == RobotBehaviors.ROBOT_PLAY_MUSIC:
            PATH = ROOT_TEGA_SPEECH_FOLDER + "general/music/"
            file = "music_"
            speech_file = PATH + file + random.choice(["1", "2", "3", "4", "5"]) + ".wav"
            msg.wav_filename = speech_file
            print ("music: "+msg.wav_filename)

        if command == RobotBehaviors.ROBOT_DANCE:
            msg.motion = TegaAction.MOTION_DANCE

        ### ====== Tega End of Task Vocab Reminder ======== ####

        if command == RobotBehaviors.Q_ROBOT_TASK_END_REMINDER:
            PATH = ROOT_TEGA_SPEECH_FOLDER + "general/word_learning/"
            file = "word_reminder_"
            speech_file = PATH + file + random.choice(["1", "2", "3"]) + ".wav"
            msg.wav_filename = speech_file
            print ("vocab reminder question: "+msg.wav_filename)

        if command == RobotBehaviors.ROBOT_TASK_END_RESPONSE:
            PATH = ROOT_TEGA_SPEECH_FOLDER + "general/word_learning/"
            vocab_word = args[0][0].lower()
            speech_file = PATH + vocab_word + "_answer_" + random.choice(["1", "2"]) + ".wav"
            msg.wav_filename = speech_file
            print ("vocab reminder answer: "+msg.wav_filename)

        if command == RobotBehaviors.Q_ROBOT_TASK_END_ASSESSMENT:
            PATH = ROOT_TEGA_SPEECH_FOLDER + "general/word_learning/"
            vocab_word = args[0][0].lower()
            speech_file = PATH + vocab_word + "_question_" + random.choice(["1", "2"]) + ".wav"
            msg.wav_filename = speech_file
            print ("vocab assessment: "+msg.wav_filename)

        ### =========== Tega Speech Induction ============= ####

        if command == RobotBehaviors.Q_ROBOT_INDUCE_SPEECH:
            PATH = ROOT_TEGA_SPEECH_FOLDER + "general/induce_keyword/"
            file = "induce_keyword_"
            speech_file = PATH + file + random.choice(["1", "3", "6"]) + ".wav"
            msg.wav_filename = speech_file
            print ("induced speech: "+msg.wav_filename)

        if command == RobotBehaviors.ROBOT_INDUCE_SPEECH_RESPONSE:
            PATH = ROOT_TEGA_SPEECH_FOLDER + "general/word_learning/"
            vocab_word = args[0][0].lower()
            speech_file = PATH + vocab_word + "_answer_" + random.choice(["2"]) + ".wav"
            msg.wav_filename = speech_file
            print ("induced speech answer: "+msg.wav_filename)

        ### ====== Tega Question Asking =================== ####
        if command == RobotBehaviors.Q_ROBOT_OFFER_HELP:
            PATH = ROOT_TEGA_SPEECH_FOLDER + "questions/"
            msg.wav_filename = PATH + args[0][0].lower()+".wav"

            print("robot offer help wav: "+msg.wav_filename)

        if command == RobotBehaviors.Q_ROBOT_ASK_WHY_CHOOSE_IT:
            PATH = ROOT_TEGA_SPEECH_FOLDER + "questions/"
            msg.wav_filename = PATH + args[0][0].lower()+".wav"
            msg.motion = TegaAction.MOTION_SILENT_PUZZLED
            print("robot ask why choose it wav: "+msg.wav_filename)

        if command == RobotBehaviors.Q_ROBOT_WANT_LEARN:
            PATH = ROOT_TEGA_SPEECH_FOLDER + "questions/"
            msg.wav_filename = PATH + args[0][0].lower()+".wav"
            msg.motion = TegaAction.MOTION_SILENT_INTERESTED
            print("robot want learn wav: "+msg.wav_filename)

        if command == RobotBehaviors.Q_ROBOT_ASK_HELP:
            PATH = ROOT_TEGA_SPEECH_FOLDER + "questions/"
            msg.wav_filename = PATH + args[0][0].lower()+".wav"
            print("robot ask help wav: "+msg.wav_filename)

        if command == RobotBehaviors.Q_ROBOT_ASK_WHY_WRONG:
            PATH = ROOT_TEGA_SPEECH_FOLDER + "questions/"
            msg.wav_filename = PATH + args[0][0].lower()+".wav"
            msg.motion = TegaAction.MOTION_SILENT_FRUSTRATED
            print("robot ask why wrong wav: "+msg.wav_filename)

        if command == RobotBehaviors.Q_END_OF_TURN:
            vocab_word = args[0][0].lower()
            file = ROOT_TEGA_SPEECH_FOLDER + "questions/end_of_turn_question_"+vocab_word+".wav"
            msg.wav_filename = file
            print("end of turn wav: "+msg.wav_filename)

        if command == RobotBehaviors.ROBOT_SAY_WORD:
            PATH = ROOT_TEGA_SPEECH_FOLDER + "object_words/"
            object_word =args[0][0].lower()
            speech_file_name = PATH + object_word + ".wav"
            msg.wav_filename = speech_file_name
            msg.enqueue = True



        ### ================ NO iSpy Action Alert #### ====================

        if command == RobotBehaviors.NO_ISPY_ACTION_ALERT:
            path= ROOT_TEGA_SPEECH_FOLDER + 'general/others/'
            files = ["no_ispy_action_alert1_response_1", "no_ispy_action_alert1_response_2"]
            speech_file = path + random.choice(files)+".wav"
            msg.wav_filename = speech_file
            print("no ispy action alert wav: "+msg.wav_filename)
            #msg.motion = 

        ### ============= Tega Speech for Curiosity Assessment =====================

        # General Curiosity Speech
        if command == RobotBehaviors.GENERAL_CURIOSITY_SPEECH:
            # the default path in Tega is "contentroot/robots/tega/01/speech", 
            # so no need to add this prefix in the path here. make sure all audios are under this prefix path
            PATH = "TegaAudio/generalcuriosity/"
            speech_file_name = PATH + random.choice(GENERAL_CURIOSITY_SPEECH)
            msg.wav_filename = speech_file_name
            msg.enqueue = True
            print(speech_file_name)

        # Based on prompts speech
        if command == RobotBehaviors.BASED_ON_PROMPTS_SPEECH:
            PATH = "TegaAudio/basedonprompts/"
            vocab_word =args[0][0].lower()
            print("vocab word is "+vocab_word)
            speech_file_name = PATH + vocab_word + ".mp3"
            msg.wav_filename = speech_file_name
            msg.enqueue = True

	   # Before pronunciation
        if command == RobotBehaviors.TRY_PRONOUNCE:
            PATH = "TegaAudio/generalcuriosity/"
            speech_file_name = PATH + "c.mp3"
            msg.wav_filename = speech_file_name
            msg.enqueue = True

	   # Based on objects
        if command == RobotBehaviors.BASED_ON_OBJECTS:
            PATH = "TegaAudio/basedonobjects/"
            speech_file_name = PATH + random.choice(BASED_ON_OBJECTS_TEMPLATES)
            msg.wav_filename = speech_file_name
            msg.enqueue = True

	   # Random objects
        if command == RobotBehaviors.OBJECTS:
            PATH = "TegaAudio/objects/"
            speech_file_name = PATH + random.choice(OBJECTS)
            msg.wav_filename = speech_file_name
            msg.enqueue = True


       
        return msg