Пример #1
0
def main():
    rospy.init_node('what_say_test')

    sm = smach.StateMachine(outcomes=['succeeded', 'preempted', 'aborted'])

    with sm:
	
	sm.userdata.grammar_name="robocup/what_did_you_say"
	# Activate the server
        smach.StateMachine.add('ActivateASR',
                    ActivateASR(),
                    transitions={'succeeded': 'what_say_sm', 'aborted': 'aborted', 'preempted': 'preempted'})
            

        smach.StateMachine.add(
            'what_say_sm',
            WhatSaySM(),
            transitions={'succeeded': 'succeeded', 'aborted': 'aborted'})

    # This is for the smach_viewer so we can see what is happening, rosrun smach_viewer smach_viewer.py it's cool!
    sis = smach_ros.IntrospectionServer(
        'what_say_test', sm, '/WSI_ROOT')
    sis.start()

    sm.execute()

    rospy.spin()
    sis.stop()
Пример #2
0
def main():
    rospy.init_node('yes_no_test')

    sm = smach.StateMachine(outcomes=['succeeded', 'preempted', 'aborted'])

    with sm:
        sm.userdata.grammar_name = None
        sm.userdata.tts_text = None
        sm.userdata.tts_wait_before_speaking = None
        sm.userdata.tts_lang = None

        # Load grammar yes/no
        smach.StateMachine.add('ActivateASR_yesno',
                               ActivateASR("robocup/yes_no"),
                               transitions={
                                   'succeeded': 'DID_YOU_SAY',
                                   'aborted': 'aborted',
                                   'preempted': 'preempted'
                               })

        smach.StateMachine.add('DID_YOU_SAY',
                               text_to_say("ready"),
                               transitions={
                                   'succeeded': 'YesNoTest',
                                   'aborted': 'aborted'
                               })

        smach.StateMachine.add('YesNoTest',
                               SayYesOrNoSM(),
                               transitions={
                                   'succeeded': 'SAY_SUCC',
                                   'aborted': 'SAY_ABORTED'
                               })

        smach.StateMachine.add('SAY_SUCC',
                               text_to_say("SUCCEEDED"),
                               transitions={
                                   'succeeded': 'succeeded',
                                   'aborted': 'aborted'
                               })

        smach.StateMachine.add('SAY_ABORTED',
                               text_to_say("ABORTED"),
                               transitions={
                                   'succeeded': 'succeeded',
                                   'aborted': 'aborted'
                               })

    # This is for the smach_viewer so we can see what is happening, rosrun smach_viewer smach_viewer.py it's cool!
    sis = smach_ros.IntrospectionServer('yes_no_introspection', sm,
                                        '/YES_NO_TEST')
    sis.start()

    sm.execute()

    rospy.spin()
    sis.stop()
Пример #3
0
    def __init__(self, grammar=None):
        smach.StateMachine.__init__(
            self,
            outcomes=['succeeded', 'preempted', 'aborted'],
            input_keys=[],
            output_keys=[])

        with self:
            self.userdata.asr_userSaid = ''
            self.userdata.grammar_name = GRAMMAR_NAME
            self.userdata.tts_text = None
            self.userdata.tts_wait_before_speaking = None
            self.userdata.tts_lang = None

            # Activate the server
            smach.StateMachine.add('ActivateASR',
                                   ActivateASR(GRAMMAR_NAME),
                                   transitions={
                                       'succeeded': 'listen_info',
                                       'aborted': 'aborted',
                                       'preempted': 'preempted'
                                   })

            # Listen
            smach.StateMachine.add('listen_info',
                                   ReadASR(),
                                   transitions={
                                       'succeeded': 'process_command',
                                       'aborted': 'aborted',
                                       'preempted': 'preempted'
                                   })

            # Prepare the information
            smach.StateMachine.add("process_command",
                                   ProcessCommand(),
                                   transitions={
                                       'yes': 'succeeded',
                                       'no': 'aborted',
                                       'aborted': 'aborted'
                                   })

            # Ask for repeat
            smach.StateMachine.add(
                'repeat',
                text_to_say(
                    "Excuse me, I don't understand you. Can you repeat?"),
                transitions={
                    'succeeded': 'aborted',
                    'aborted': 'aborted',
                    'preempted': 'preempted'
                })
Пример #4
0
    def __init__(self,
                 GRAMMAR_NAME,
                 command_key='finn',
                 command_value='xxx',
                 ask_for_confirmation=False):
        smach.StateMachine.__init__(self,
                                    ['succeeded', 'preempted', 'aborted'])
        with self:

            smach.StateMachine.add('ENABLE_GRAMMAR',
                                   ActivateASR(GRAMMAR_NAME),
                                   transitions={'succeeded': 'HEAR_COMMAND'})

            smach.StateMachine.add('HEAR_COMMAND',
                                   ReadASR(),
                                   transitions={
                                       'aborted': 'HEAR_COMMAND',
                                       'succeeded': 'PROCESS_COMMAND',
                                       'preempted': 'preempted'
                                   },
                                   remapping={
                                       'asr_userSaid': 'userSaidData',
                                       'asr_userSaid_tags': 'userSaidTags'
                                   })

            smach.StateMachine.add(
                'PROCESS_COMMAND',
                ProcessCommandState(),
                transitions={
                    'succeeded':
                    'ASK_COMMAND_CONFIRMATION'
                    if ask_for_confirmation else 'PRINT_MESSAGE',
                    'preempted':
                    'preempted',
                    'aborted':
                    'aborted'
                },
                remapping={
                    'in_heard': 'userSaidData',
                    'value_heard_out': 'word_heard'
                })

            if ask_for_confirmation:
                smach.StateMachine.add(
                    'ASK_COMMAND_CONFIRMATION',
                    text_to_say('Did you say ' + userdata.word_heard + '?'),
                    transitions={
                        'succeeded': 'LISTEN_COMMAND_CONFIRMATION',
                        'aborted': 'SLEEP_STATE',
                        'preempted': 'preempted'
                    })

                smach.StateMachine.add(
                    'LISTEN_COMMAND_CONFIRMATION',
                    SayYesOrNoSM(),
                    transitions={
                        'succeeded': 'DISABLE_GRAMMAR',
                        'aborted': 'SLEEP_STATE',
                        'preempted': 'preempted'
                    },
                    remapping={'in_message_heard': 'word_heard'})

                smach.StateMachine.add('SLEEP_STATE',
                                       SleepState(0.5),
                                       transitions={
                                           'succeeded': 'HEAR_COMMAND',
                                           'preempted': 'preempted'
                                       })

            smach.StateMachine.add('PRINT_MESSAGE',
                                   PrintUserData(),
                                   transitions={
                                       'succeeded': 'DISABLE_GRAMMAR',
                                       'preempted': 'preempted'
                                   })

            smach.StateMachine.add('DISABLE_GRAMMAR',
                                   DeactivateASR(GRAMMAR_NAME),
                                   transitions={'succeeded': 'succeeded'})
Пример #5
0
    def __init__(self,
                 GRAMMAR_NAME='categories',
                 command_key='finn',
                 command_value='xxx'):
        smach.StateMachine.__init__(self,
                                    ['succeeded', 'preempted', 'aborted'])

        GRAMMAR_NAME = 'gpsr/' + GRAMMAR_NAME

        self.userdata.cat = GRAMMAR_NAME
        self.userdata.objectList = []
        self.userdata.locList = []
        self.userdata.location_name = ''
        self.userdata.grammar_name = GRAMMAR_NAME
        self.userdata.tts_wait_before_speaking = 0
        self.userdata.tts_text = ''
        self.userdata.tts_lang = ''

        with self:

            smach.StateMachine.add('CONFG_QUESTION',
                                   config_loc_question(),
                                   transitions={'succeeded': 'ENABLE_GRAMMAR'},
                                   remapping={
                                       'DataType': 'DataType',
                                       'locList': 'locList'
                                   })

            smach.StateMachine.add(
                'ENABLE_GRAMMAR',
                ActivateASR(GRAMMAR_NAME),
                transitions={'succeeded': 'PREPARATION_ASK_INFO'})

            smach.StateMachine.add('PREPARATION_ASK_INFO',
                                   prepare_ask_info_loc(),
                                   transitions={'succeeded': 'ASK_INFO'},
                                   remapping={'tosay': 'tts_text'})

            smach.StateMachine.add('ASK_INFO',
                                   text_to_say(),
                                   transitions={
                                       'succeeded': 'HEAR_COMMAND',
                                       'aborted': 'aborted'
                                   })

            smach.StateMachine.add('HEAR_COMMAND',
                                   ReadASR(),
                                   transitions={
                                       'aborted': 'HEAR_COMMAND',
                                       'succeeded': 'BRING_ORDER',
                                       'preempted': 'preempted'
                                   },
                                   remapping={
                                       'asr_userSaid': 'userSaidData',
                                       'asr_userSaid_tags': 'userSaidTags'
                                   })

            smach.StateMachine.add('BRING_ORDER',
                                   BringOrderLoc(),
                                   transitions={
                                       'aborted': 'HEAR_COMMAND',
                                       'succeeded':
                                       'PREPARATION_CONFIRM_OBJECT',
                                       'preempted': 'preempted'
                                   })

            smach.StateMachine.add('PREPARATION_CONFIRM_OBJECT',
                                   prepare_confirm_info(),
                                   transitions={'succeeded': 'CONFIRM_OBJECT'},
                                   remapping={'tosay': 'tts_text'})

            smach.StateMachine.add('CONFIRM_OBJECT',
                                   text_to_say(),
                                   transitions={
                                       'succeeded': 'DISABLE_GRAMMAR',
                                       'aborted': 'DISABLE_GRAMMAR'
                                   })

            smach.StateMachine.add('RECOGNIZE_COMMAND',
                                   RecognizeCommand(command_key,
                                                    command_value),
                                   transitions={
                                       'notvalid_command': 'NOT_VALID_COMMAND',
                                       'valid_command': 'VALID_COMMAND',
                                       'preempted': 'preempted',
                                       'aborted': 'aborted'
                                   },
                                   remapping={'speechData': 'userSaidData'})

            smach.StateMachine.add(
                'VALID_COMMAND',
                text_to_say("Ok, understood."),
                transitions={'succeeded': 'DISABLE_GRAMMAR'})

            smach.StateMachine.add(
                'NOT_VALID_COMMAND',
                text_to_say(
                    "Sorry, I couldn't understand what you said. Can you repeat?"
                ),
                transitions={'succeeded': 'HEAR_COMMAND'})

            smach.StateMachine.add('DISABLE_GRAMMAR',
                                   DeactivateASR(GRAMMAR_NAME),
                                   transitions={'succeeded': 'succeeded'})
Пример #6
0
    def __init__(self,
                 Type,
                 objectName,
                 GRAMMAR_NAME='robocup/locations',
                 command_key='finn',
                 command_value='xxx'):
        smach.StateMachine.__init__(self,
                                    ['succeeded', 'preempted', 'aborted'])

        self.userdata.dataType = Type
        self.userdata.object_name = objectName
        self.userdata.location_name = ''
        self.userdata.grammar_name = GRAMMAR_NAME
        self.userdata.tts_wait_before_speaking = 0
        self.userdata.tts_text = ''
        self.userdata.tts_lang = ''

        with self:

            smach.StateMachine.add('ENABLE_GRAMMAR',
                                   ActivateASR(GRAMMAR_NAME),
                                   transitions={'succeeded': 'ASK_LOCATION'})

            smach.StateMachine.add(
                'ASK_LOCATION',
                text_to_say("I don't know where the " +
                            self.userdata.object_name +
                            ' is. Do you know where could I find it?'),
                transitions={
                    'succeeded': 'HEAR_COMMAND',
                    'aborted': 'aborted'
                })

            smach.StateMachine.add('HEAR_COMMAND',
                                   ReadASR(),
                                   transitions={
                                       'aborted': 'HEAR_COMMAND',
                                       'succeeded': 'BRING_LOCATION',
                                       'preempted': 'preempted'
                                   },
                                   remapping={
                                       'asr_userSaid': 'userSaidData',
                                       'asr_userSaid_tags': 'userSaidTags'
                                   })

            smach.StateMachine.add(
                'BRING_LOCATION',
                BringOrderLoc(),
                transitions={
                    'aborted': 'HEAR_COMMAND',
                    'succeeded': 'PREPARATION_CONFIRM_OBJECT',
                    'preempted': 'preempted'
                },
                remapping={'location_name': 'location_name'})

            smach.StateMachine.add('PREPARATION_CONFIRM_OBJECT',
                                   prepare_confirm_info(),
                                   transitions={'succeeded': 'CONFIRM_OBJECT'},
                                   remapping={'tosay': 'tts_text'})

            smach.StateMachine.add('CONFIRM_OBJECT',
                                   text_to_say(),
                                   transitions={
                                       'succeeded': 'DISABLE_GRAMMAR',
                                       'aborted': 'DISABLE_GRAMMAR'
                                   })

            smach.StateMachine.add('RECOGNIZE_COMMAND',
                                   RecognizeCommand(command_key,
                                                    command_value),
                                   transitions={
                                       'notvalid_command': 'NOT_VALID_COMMAND',
                                       'valid_command': 'VALID_COMMAND',
                                       'preempted': 'preempted',
                                       'aborted': 'aborted'
                                   },
                                   remapping={'speechData': 'userSaidData'})

            smach.StateMachine.add(
                'VALID_COMMAND',
                text_to_say("Ok, understood."),
                transitions={'succeeded': 'DISABLE_GRAMMAR'})

            smach.StateMachine.add(
                'NOT_VALID_COMMAND',
                text_to_say(
                    "I couldn't understand what you said. Can you repeat?"),
                transitions={'succeeded': 'HEAR_COMMAND'})

            smach.StateMachine.add('DISABLE_GRAMMAR',
                                   DeactivateASR(),
                                   transitions={'succeeded': 'succeeded'})
Пример #7
0
    def __init__(self):
        smach.StateMachine.__init__(
            self,
            outcomes=['succeeded', 'preempted', 'aborted'],
            output_keys=['object_array'])

        with self:
            # We must initialize the userdata keys if they are going to be accessed or they won't exist and crash!
            self.userdata.nav_to_poi_name = None
            self.userdata.grammar_name = None
            self.userdata.type_movment = None
            self.userdata.tts_wait_before_speaking = 0
            self.userdata.tts_lang = None
            self.userdata.standard_error = 'OK'
            self.userdata.object_name = ''
            self.userdata.object_index = 0

            # Activate the server
            smach.StateMachine.add('ActivateASR',
                                   ActivateASR(GRAMMAR_NAME),
                                   transitions={
                                       'succeeded': 'ask_restaurant_order',
                                       'aborted': 'aborted',
                                       'preempted': 'preempted'
                                   })

            # Ask Order
            smach.StateMachine.add(
                'ask_restaurant_order',
                text_to_say("What would you like to order?"),
                transitions={
                    'succeeded': 'ReadASR',
                    'aborted': 'aborted',
                    'preempted': 'preempted'
                })

            # Read from server
            smach.StateMachine.add('ReadASR',
                                   ReadASR(),
                                   transitions={
                                       'succeeded': 'process_restaurant_order',
                                       'aborted': 'aborted',
                                       'preempted': 'preempted'
                                   })

            # Listen Order
            #             smach.StateMachine.add(
            #                 'listen_restaurant_order',
            #                 ListenToSM(GRAMMAR_NAME),
            #                 transitions={'succeeded': 'process_restaurant_order', 'aborted': 'aborted',
            #                 'preempted': 'preempted'})
            #
            # Process order
            smach.StateMachine.add('process_restaurant_order',
                                   process_restaurant_order(),
                                   transitions={
                                       'succeeded': 'ActivateASR_yesno',
                                       'aborted': 'aborted'
                                   })

            # Load grammar yes/no
            smach.StateMachine.add('ActivateASR_yesno',
                                   ActivateASR("robocup/yes_no"),
                                   transitions={
                                       'succeeded': 'confirm_restaurant_order',
                                       'aborted': 'aborted',
                                       'preempted': 'preempted'
                                   })

            # Confirm Order
            smach.StateMachine.add('confirm_restaurant_order',
                                   acknowledgment(type_movement="yes"),
                                   transitions={
                                       'succeeded': 'yesno_restaurant_order',
                                       'aborted': 'aborted',
                                       'preempted': 'preempted'
                                   })

            # Wait for yes or no
            smach.StateMachine.add('yesno_restaurant_order',
                                   SayYesOrNoSM(),
                                   transitions={
                                       'succeeded': 'ok_im_going',
                                       'aborted': 'aborted',
                                       'preempted': 'preempted'
                                   })

            # Ask for repeat the order
            smach.StateMachine.add(
                'repeat_restaurant_order',
                acknowledgment(
                    type_movement="no",
                    tts_text=
                    "Excuse me, I don't understand you. Can you repeat your order?"
                ),
                transitions={
                    'succeeded': 'ReadASR',
                    'aborted': 'aborted',
                    'preempted': 'preempted'
                })

            # Confirm Order
            smach.StateMachine.add('ok_im_going',
                                   text_to_say("OK i'm going to service"),
                                   transitions={
                                       'succeeded': 'succeeded',
                                       'aborted': 'aborted',
                                       'preempted': 'preempted'
                                   })

            # Search for object information - It says where the object is, go to it and start object recognition -> RESTAURANT
            # TODO: Add some messages in search object


#             smach.StateMachine.add(
#                 'search_food_order',
#                 SearchObjectSM(),
#                 transitions={'succeeded': 'go_to_storage', 'aborted': 'go_to_storage',
#                 'preempted': 'preempted'})
Пример #8
0
    def __init__(self):
        smach.StateMachine.__init__(self, ['succeeded', 'preempted', 'aborted'])

        with self:
            # We must initialize the userdata keys if they are going to be accessed or they won't exist and crash!
            self.userdata.loop_iterations = 0
            self.userdata.nav_to_poi_name = ""
            self.userdata.faces = ""
            self.userdata.name=''
            self.userdata.tts_text = None
            self.userdata.tts_wait_before_speaking = 0
            self.userdata.tts_lang = ''
            
            # Listen the first question
            self.userdata.grammar_name = GRAMMAR_NAME
            
            # Home position
            smach.StateMachine.add(
                'home_position_init',
                play_motion_sm('home'),
                transitions={'succeeded': 'ActivateASR', 'aborted': 'home_position_init', #TODO: Change aborted to try again
                'preempted': 'preempted'}) 
                     
            # Enter room
            smach.StateMachine.add(
                 'say_what_did_you_say',
                 text_to_say("I'm beginning the what did you say test, I'm going to looking for the referee"),
                 #transitions={'succeeded': 'go_location', 'aborted': 'aborted'})
                 transitions={'succeeded': 'search_face', 'aborted': 'search_face'})
            
#             # Go to the location
#             smach.StateMachine.add(
#                  'go_location',
#                  nav_to_poi("init_what_say"),
#                  transitions={'succeeded': 'search_face', 'aborted': 'aborted', 
#                  'preempted': 'preempted'})    
             
#             smach.StateMachine.add(
#                  'say_faces',
#                  text_to_say("Searching for faces"),
#                  transitions={'succeeded': 'search_face', 'aborted': 'aborted'})
            
            # Look for a face
            smach.StateMachine.add(
                 'search_face',
                 go_find_person(),
                 transitions={'succeeded': 'Say_Found_Face', 'aborted': 'ask_for_tc', 
                 'preempted': 'preempted'},
                  remapping={'face_frame':'face_frame'})
             
            # Go to the person - We assume that find person will return the position for the person
            smach.StateMachine.add(
                                   'Say_Found_Face',
                                   text_to_say('Referee! I have found you at last. Now I am going to you, wait for me.'),
                                   transitions={'succeeded': 'get_current_pose_yaw', 'aborted': 'Say_Found_Face', 
                                                'preempted': 'preempted'})
            smach.StateMachine.add(
               'get_current_pose_yaw',
               get_current_robot_pose(),
               transitions={'succeeded': 'prepare_coord_person', 'aborted': 'ask_for_tc',
                                'preempted': 'preempted'})
            
            smach.StateMachine.add(
                 'prepare_coord_person',
                 prepare_coord_person(),
                 transitions={'succeeded': 'go_to_person', 'aborted': 'aborted',
                 'preempted': 'preempted'})
            
            
            smach.StateMachine.add(
                 'go_to_person',
                 nav_to_coord_ud(),
                 transitions={'succeeded': 'say_found', 'aborted': 'Say_person_not_reached',
                 'preempted': 'preempted'})
            
            smach.StateMachine.add(
               'Say_person_not_reached',
               text_to_say('I Found you, but cannot reach you, can you come to me please?'),
               transitions={'succeeded': 'wait_for_tc', 'aborted': 'aborted'})
             
            # Say "I found you!" + Small Talk
            smach.StateMachine.add(
                 'say_found',
                 text_to_say("I found you! I have arrived to where you are."),
                 transitions={'succeeded': 'ActivateASR', 'aborted': 'aborted'})
             
            # Ask for TC if we don't find him
            smach.StateMachine.add(
                 'ask_for_tc',
                 text_to_say("I can't find you. Can you come to me?"),
                 transitions={'succeeded': 'wait_for_tc', 'aborted': 'aborted'})
              
            # Wait for TC
            smach.StateMachine.add(
                 'wait_for_tc',
                 detect_face(),
                 transitions={'succeeded': 'say_found', 'aborted': 'aborted'})
            
            # Question Part ---------------------------------------------------------------------------------------------
            
            # Init the asr service

            # Activate the server
            smach.StateMachine.add('ActivateASR',
                    ActivateASR(),
                    transitions={'succeeded': 'check_loop', 'aborted': 'aborted', 'preempted': 'preempted'})
            
            # loop test - It checks the number of iterations
            smach.StateMachine.add(
                'check_loop',
                checkLoop(),
                transitions={'succeeded': 'ask_next_question', 'aborted': 'aborted', 
                'preempted': 'preempted', 'end':'DeactivateASR'})
            
            # Ask for next question
            smach.StateMachine.add(
                'ask_next_question',
                text_to_say("I'm ready, ask me a question"),
                transitions={'succeeded': 'listen_question', 'aborted': 'aborted', 
                'preempted': 'preempted'}) 
            
            smach.StateMachine.add(
                'listen_question',
                ReadASR(),
                transitions={'succeeded': 'prepear_repeat', 'aborted': 'aborted', 
                'preempted': 'preempted'})  
            
            smach.StateMachine.add(
                'prepear_repeat',
                prepear_repeat(),
                transitions={'succeeded': 'repeat_question', 'aborted': 'aborted', 
                'preempted': 'preempted'})  
             
            # Repeat question
            smach.StateMachine.add(
                'repeat_question',
                text_to_say(),
                transitions={'succeeded': 'search_answer', 'aborted': 'aborted', 
                'preempted': 'preempted'})  
            
            # Search the answer
            smach.StateMachine.add(
                'search_answer',
                SelectAnswer(),
                transitions={'succeeded': 'say_answer', 'aborted': 'say_answer', 
                'preempted': 'preempted', 'None': 'aborted'})    

            # Say the answer
            smach.StateMachine.add(
                'say_answer',
                text_to_say(),
                transitions={'succeeded': 'check_loop', 'aborted': 'aborted', 
                'preempted': 'preempted'})  
            
            # Deactivate ASR
            smach.StateMachine.add('DeactivateASR',
                DeactivateASR(),
                transitions={'succeeded': 'say_end', 'aborted': 'aborted', 'preempted': 'preempted'})
            
            smach.StateMachine.add(
                 'say_end',
                 text_to_say("What did you say test finished"),
                 transitions={'succeeded': 'succeeded', 'aborted': 'aborted'})
Пример #9
0
    def __init__(self):
        smach.StateMachine.__init__(self,
                                    ['succeeded', 'preempted', 'aborted'])

        with self:
            # We must initialize the userdata keys if they are going to be accessed or they won't exist and crash!
            self.userdata.loop_iterations = 0
            self.userdata.nav_to_poi_name = ""
            self.userdata.faces = ""
            self.userdata.name = ''
            self.userdata.tts_text = None
            self.userdata.tts_wait_before_speaking = 0
            self.userdata.tts_lang = ''

            # Listen the first question
            self.userdata.grammar_name = GRAMMAR_NAME

            # Find me Part

            # Enter room
            smach.StateMachine.add(
                'say_what_did_you_say',
                text_to_say(
                    "I'm beginning the what did you say test,. I'm going to the place where ther referee should be"
                ),
                #transitions={'succeeded': 'go_location', 'aborted': 'aborted'})
                transitions={
                    'succeeded': 'go_location',
                    'aborted': 'aborted'
                })

            # Go to the location
            smach.StateMachine.add('go_location',
                                   nav_to_poi("find_me"),
                                   transitions={
                                       'succeeded': 'say_faces',
                                       'aborted': 'aborted',
                                       'preempted': 'preempted'
                                   })

            smach.StateMachine.add('say_faces',
                                   text_to_say("Searching for faces"),
                                   transitions={
                                       'succeeded': 'search_face',
                                       'aborted': 'aborted'
                                   })

            # Look for a face
            smach.StateMachine.add('search_face',
                                   SearchFacesSM(),
                                   transitions={
                                       'succeeded': 'prepare_coord_person',
                                       'aborted': 'ask_for_tc',
                                       'preempted': 'preempted'
                                   })

            # Go to the person - We assume that find person will return the position for the person
            smach.StateMachine.add('prepare_coord_person',
                                   prepare_coord_person(),
                                   transitions={
                                       'succeeded': 'go_to_person',
                                       'aborted': 'aborted',
                                       'preempted': 'preempted'
                                   })

            smach.StateMachine.add('go_to_person',
                                   nav_to_coord('/base_link'),
                                   transitions={
                                       'succeeded': 'say_found',
                                       'aborted': 'aborted',
                                       'preempted': 'preempted'
                                   })

            # Say "I found you!" + Small Talk
            smach.StateMachine.add('say_found',
                                   text_to_say("I found you!"),
                                   transitions={
                                       'succeeded': 'ActivateASR',
                                       'aborted': 'aborted'
                                   })

            # Ask for TC if we dont find him
            smach.StateMachine.add(
                'ask_for_tc',
                text_to_say("I can't find you. Can you come to me?"),
                transitions={
                    'succeeded': 'wait_for_tc',
                    'aborted': 'aborted'
                })

            # Wait for TC
            smach.StateMachine.add('wait_for_tc',
                                   detect_face(),
                                   transitions={
                                       'succeeded': 'say_found',
                                       'aborted': 'aborted'
                                   })

            # Question Part ---------------------------------------------------------------------------------------------

            # Init the asr service

            # Activate the server
            smach.StateMachine.add('ActivateASR',
                                   ActivateASR(),
                                   transitions={
                                       'succeeded': 'check_loop',
                                       'aborted': 'aborted',
                                       'preempted': 'preempted'
                                   })

            # loop test - It checks the number of iterations
            smach.StateMachine.add('check_loop',
                                   checkLoop(),
                                   transitions={
                                       'succeeded': 'ask_next_question',
                                       'aborted': 'aborted',
                                       'preempted': 'preempted',
                                       'end': 'DeactivateASR'
                                   })

            # Ask for next question
            smach.StateMachine.add('ask_next_question',
                                   text_to_say("I'm ready, ask me a question"),
                                   transitions={
                                       'succeeded': 'listen_question',
                                       'aborted': 'aborted',
                                       'preempted': 'preempted'
                                   })

            smach.StateMachine.add('listen_question',
                                   ReadASR(),
                                   transitions={
                                       'succeeded': 'prepear_repeat',
                                       'aborted': 'aborted',
                                       'preempted': 'preempted'
                                   })

            smach.StateMachine.add('prepear_repeat',
                                   prepear_repeat(),
                                   transitions={
                                       'succeeded': 'repeat_question',
                                       'aborted': 'aborted',
                                       'preempted': 'preempted'
                                   })

            # Repeat question
            smach.StateMachine.add('repeat_question',
                                   text_to_say(),
                                   transitions={
                                       'succeeded': 'search_answer',
                                       'aborted': 'aborted',
                                       'preempted': 'preempted'
                                   })

            # Search the answer
            smach.StateMachine.add('search_answer',
                                   SelectAnswer(),
                                   transitions={
                                       'succeeded': 'say_answer',
                                       'aborted': 'say_answer',
                                       'preempted': 'preempted',
                                       'None': 'aborted'
                                   })

            # Say the answer
            smach.StateMachine.add('say_answer',
                                   text_to_say(),
                                   transitions={
                                       'succeeded': 'check_loop',
                                       'aborted': 'aborted',
                                       'preempted': 'preempted'
                                   })

            # Deactivate ASR
            smach.StateMachine.add('DeactivateASR',
                                   DeactivateASR(),
                                   transitions={
                                       'succeeded': 'say_end',
                                       'aborted': 'aborted',
                                       'preempted': 'preempted'
                                   })

            smach.StateMachine.add(
                'say_end',
                text_to_say("What did you say test finished"),
                transitions={
                    'succeeded': 'succeeded',
                    'aborted': 'aborted'
                })