示例#1
0
class DeepSearchHandler(pyinotify.ProcessEvent):
    """ Deep file search handler to handle the events gengerated by file changes """
    def __init__(self):
        self.datahandler = DatabaseHandler()
        print "instance created"

    def process_IN_CREATE(self, event):
        """Called when a file or directory is created."""
        print "file create event" + str(event)
        self.datahandler.create(event.pathname)

    def process_IN_MODIFY(self, event):
        """"Called when a file or directory is modified."""
        print "file modify event" + str(event)
        self.datahandler.update(event.pathname)

    def process_IN_DELETE(self, event):
        """" Called when a file or directory is deleted. """
        print "file delete event" + str(event)
        self.datahandler.delete(event.pathname)

    def process_IN_ACCESS(self, event):
        """" Called when a file or directory is accessed. """
        print "file access event" + str(event.pathname)
        self.datahandler.access(event.pathname)

    def close_db_connection(self):
        """ call close_connection function of datanadler """
        self.datahandler.close_connection()
示例#2
0
class DeepSearchHandler(PatternMatchingEventHandler):
	""" Deep file search handler to handle the events gengerated by file changes """
	def __init__(self):	
		self.datahandler = DatabaseHandler()
		self._ignore_directories = False
		self._ignore_patterns = False
		self._ignore_patterns = ["*.log","*.logger"]
		self._case_sensitive = False
		self._patterns = ["*.rb","*.py","*.java","*.mp4","*.mp3","*.txt"]
		print "instance created"


	def on_created(self,event):
		"""Called when a file or directory is created."""
		print "file create event"+str(event)
		self.datahandler.create(event.src_path)		

	def on_modified(self,event):
		""""Called when a file or directory is modified."""
		print "file modify event"+str(event)
		self.datahandler.update(event.src_path)

	def on_deleted(self,event):
		"""" Called when a file or directory is deleted. """
		print "file delete event"+str(event)
		self.datahandler.delete(event.src_path)

	def on_moved(self,event):
		""""Called when a file or a directory is moved or renamed."""
		print "file moved event"+str(event)
		self.datahandler.moved(event.src_path)

	def close_db_connection(self):
		""" call close_connection function of datanadler """
		self.datahandler.close_connection()
示例#3
0
def main():

    homedir = os.path.expanduser("~")
    path = homedir + "/navigation.db"

    if (os.path.exists(path) == False):
        database_handler = DatabaseHandler(filename=path)
        database_handler.create()
        database_handler.add_location(location_name="entrance", robot_map_name="ntnu2.map", x=-18.440, y=6.500, z=0, p=0, j=0, r=2, threshold=3, crowded=False,enviorment=-0.10)
        database_handler.add_location(location_name="home", robot_map_name="ntnu2.map", x=-29.500, y=8.700, z=0, p=0, j=0, r=2, threshold=3, crowded=False, enviorment=0.20)
        database_handler.add_location(location_name="waiting area", robot_map_name="ntnu2.map", x=-33.600, y=10.600, z=0, p=0, j=0, r=2, threshold=3, crowded=False, enviorment=-0.10)
        database_handler.add_location(location_name="cafeteria", robot_map_name="ntnu2.map", x=-33.090, y=-55.700, z=0, p=0, j=0, r=2, threshold=3, crowded=True, enviorment=0.20)
        database_handler.add_location(location_name="elevator", robot_map_name="ntnu2.map", x=-29.500, y=-50.200, z=0, p=0, j=0, r=2, threshold=3, crowded=True, enviorment=-0.02)
        database_handler.add_location(location_name="entrance 2", robot_map_name="ntnu2.map", x=-18.300, y=-66.000, z=0, p=0, j=0, r=33, threshold=3, crowded=True, enviorment=0.05)
        database_handler.add_location(location_name="information", robot_map_name="ntnu2.map", x=-33.490, y=1.160, z=0, p=0, j=0, r=2, threshold=3, crowded=True, enviorment=0.05)
        database_handler.add_location(location_name="el5", robot_map_name="ntnu2.map", x=-33.720, y=-32.500, z=0, p=0, j=0, r=-2, threshold=3, crowded=True, enviorment=0.00)
        database_handler.add_location(location_name="el6", robot_map_name="ntnu2.map", x=-30.300, y=-12.840, z=0, p=0, j=0, r=2, threshold=3, crowded=True, enviorment=0.00)
        database_handler.add_location(location_name="bridge", robot_map_name="ntnu2.map", x=-28.090, y=-63.500, z=0, p=0, j=0, r=2, threshold=3, crowded=True, enviorment=0.00)
        
        database_handler.add_event(event_name="welcome_time", location_name="entrance", start_date=datetime.datetime(2017, 1, 18, 11, 0, 0, 1), end_date=datetime.datetime(2017, 1, 18, 11, 4, 0, 1), ignore=False)
        database_handler.add_event(event_name="dinner_time", location_name="cafeteria", start_date=datetime.datetime(2017, 1, 18, 15, 0, 7, 1) , end_date=datetime.datetime(2017, 1, 18, 15, 59, 0, 1), ignore=False)
        database_handler.add_event(event_name="wait_time", location_name="waiting area", start_date=datetime.datetime(2017, 1, 18, 8, 0, 1, 1) , end_date=datetime.datetime(2017, 1, 18, 8, 46, 0, 1), ignore=False)
        database_handler.add_event(event_name="lunch_time", location_name="cafeteria", start_date=datetime.datetime(2017, 1, 18, 7, 0, 1, 1) , end_date=datetime.datetime(2017, 1, 18, 7, 0, 0, 1), ignore=False)
        database_handler.add_event(event_name="goodbye_time", location_name="entrance 2", start_date=datetime.datetime(2017, 1, 18, 9, 0, 1, 1), end_date=datetime.datetime(2017, 1, 18, 9, 0, 0, 1), ignore=False)
        
        database_handler.add_response( message="I love LOCATION", response_type="navigation_response", emotion="love")
        database_handler.add_response( message="I am happy about LOCATION", response_type="navigation_response", emotion="elated")
        database_handler.add_response( message="I like LOCATION", response_type="navigation_response", emotion="elated")
        database_handler.add_response( message="I like LOCATION", response_type="navigation_response", emotion="dignified")
        database_handler.add_response( message="I am happy about at LOCATION", response_type="navigation_response", emotion="neutral")
        database_handler.add_response( message="I like LOCATION", response_type="navigation_response", emotion="neutral")
        database_handler.add_response( message="What is this place? A LOCATION you say?", response_type="navigation_response", emotion="curious")
        database_handler.add_response( message="What is this place? A LOCATION you say?", response_type="navigation_response", emotion="puzzled")
        database_handler.add_response( message="I hate the LOCATION", response_type="navigation_response", emotion="angry")
        database_handler.add_response( message="I dont like the LOCATION", response_type="navigation_response", emotion="angry")
        database_handler.add_response( message="A the LOCATION, whatever. Been there, done that...", response_type="navigation_response", emotion="unconcerned")
        database_handler.add_response( message="A the LOCATION, whatever. Been there, done that...", response_type="navigation_response", emotion="angry")
        database_handler.add_response( message="A the LOCATION, whatever. Been there, done that...", response_type="navigation_response", emotion="inhibited")
        
    rospy.init_node("cyborg_navigation")
    navigation_server = NavigationServer(database_file=path)
    rospy.spin()
示例#4
0
def main():
    rospy.init_node("cyborg_controller")

    # Create emotions
    emotion_system = EmotionSystem()
    emotion_system.add_emotion(name="angry",
                               pleasure=-0.51,
                               arousal=0.59,
                               dominance=0.25)
    emotion_system.add_emotion(name="bored",
                               pleasure=-0.65,
                               arousal=-0.62,
                               dominance=-0.33)
    emotion_system.add_emotion(name="curious",
                               pleasure=0.22,
                               arousal=0.62,
                               dominance=-0.10)
    emotion_system.add_emotion(name="dignified",
                               pleasure=0.55,
                               arousal=0.22,
                               dominance=0.61)
    emotion_system.add_emotion(name="elated",
                               pleasure=0.50,
                               arousal=0.42,
                               dominance=0.23)  # Happy
    emotion_system.add_emotion(name="inhibited",
                               pleasure=-0.54,
                               arousal=-0.04,
                               dominance=-0.41)  # Sadness
    emotion_system.add_emotion(name="puzzled",
                               pleasure=-0.41,
                               arousal=0.48,
                               dominance=-0.33)  # Surprized
    emotion_system.add_emotion(name="loved",
                               pleasure=0.89,
                               arousal=0.54,
                               dominance=-0.18)
    emotion_system.add_emotion(name="unconcerned",
                               pleasure=-0.13,
                               arousal=-0.41,
                               dominance=0.08)

    homedir = os.path.expanduser("~")
    path = homedir + "/controller.db"

    # Fill database with default values
    if (os.path.exists(path) == False):
        event_cost = 0.6  #
        database_handler = DatabaseHandler(filename=path)
        database_handler.create()
        database_handler.add_event(state="idle",
                                   event="music_play",
                                   reward_pleasure=0.08,
                                   reward_arousal=0.02,
                                   reward_dominance=-0.03,
                                   event_cost=event_cost * 2)
        database_handler.add_event(state="idle",
                                   event="astrolanguage",
                                   reward_pleasure=0.04,
                                   reward_arousal=0.05,
                                   reward_dominance=0.04,
                                   event_cost=event_cost * 1.5)
        database_handler.add_event(state="idle",
                                   event="navigation_emotional",
                                   reward_pleasure=0.02,
                                   reward_arousal=0.04,
                                   reward_dominance=-0.02,
                                   event_cost=event_cost)
        database_handler.add_event(state="idle",
                                   event="show_off_mea",
                                   reward_pleasure=0.02,
                                   reward_arousal=0.01,
                                   reward_dominance=0.01,
                                   event_cost=event_cost / 2)
        database_handler.add_event(state="idle",
                                   event="convey_emotion",
                                   reward_pleasure=0.01,
                                   reward_arousal=-0.01,
                                   reward_dominance=0.02,
                                   event_cost=event_cost / 3)

    # Create motivator
    motivator = Motivator(database_file=path)
    motivator.start()

    # Create a SMACH state machine
    sm = smach.StateMachine(outcomes=["error"])

    sm.userdata.state_machine_events = []
    sm.userdata.last_state = "initializing"
    sm.userdata.last_event = "start_up"

    with sm:
        sm_remapping = {
            "input_events": "state_machine_events",
            "output_events": "state_machine_events",
            "previous_state": "last_state",
            "current_state": "last_state",
            "previous_event": "last_event",
            "current_event": "last_event"
        }

        idle_transitions = {
            "navigation_schedular": "navigation",
            "navigation_emotional": "navigation",
            "convey_emotion": "conveying_emotional_state",
            "show_off_mea": "show_off_mea",
            "music_play": "music_horror",
            "astrolanguage": "astrolanguage",
            "aborted": "idle",
            "power_low": "exhausted",
            "bedtime": "sleepy"
        }
        idle_resources = {}  # Idle does not require any resources

        smach.StateMachine.add(
            "idle",
            Module("idle", "cyborg_primary_states", idle_transitions,
                   idle_resources), idle_transitions, sm_remapping)

        sleepy_transitions = {"aborted": "idle", "succeeded": "sleeping"}
        sleepy_resources = {}
        show_off_mea_transitions = {"aborted": "idle", "succeeded": "idle"}
        smach.StateMachine.add(
            "show_off_mea",
            Module("show_off_mea", "cyborg_behavior", show_off_mea_transitions,
                   sleepy_resources), show_off_mea_transitions, sm_remapping)

        smach.StateMachine.add(
            "sleepy",
            Module("sleepy", "cyborg_behavior", sleepy_transitions,
                   sleepy_resources), sleepy_transitions, sm_remapping)

        exhausted_transitions = {"aborted": "idle", "succeeded": "sleeping"}
        exhausted_resources = {}
        smach.StateMachine.add(
            "exhausted",
            Module("exhausted", "cyborg_behavior", exhausted_transitions,
                   exhausted_resources), exhausted_transitions, sm_remapping)

        sleeping_transitions = {
            "preempted": "idle",
            "cyborg_wake_up": "waking_up"
        }

        sleeping_resources = {}
        smach.StateMachine.add(
            "sleeping",
            Module("sleeping", "cyborg_primary_states", sleeping_transitions,
                   sleeping_resources), sleeping_transitions, sm_remapping)

        waking_up_transitions = {"aborted": "idle", "succeeded": "idle"}
        waking_up_resources = {}

        smach.StateMachine.add(
            "waking_up",
            Module("waking_up", "cyborg_behavior", waking_up_transitions,
                   waking_up_resources), waking_up_transitions, sm_remapping)

        conveying_emotion_transitions = {
            "aborted": "idle",
            "succeeded": "idle"
        }
        conveying_emotion_resources = {}

        smach.StateMachine.add(
            "conveying_emotional_state",
            Module("conveying_emotional_state", "cyborg_behavior",
                   conveying_emotion_transitions, conveying_emotion_resources),
            conveying_emotion_transitions, sm_remapping)

        sm_nav = smach.StateMachine(
            outcomes=["succeeded", "aborted", "power_low"])

        with sm_nav:

            navigation_planning_transitions = {
                "navigation_start_moving_schedular":
                "navigation_go_to_schedular",
                "navigation_start_moving_emotional":
                "navigation_go_to_emotional",
                "navigation_start_wandering": "wandering_emotional",
                "aborted": "aborted"
            }
            navigation_planning_resources = {}

            smach.StateMachine.add(
                "navigation_planning",
                Module("navigation_planning", "cyborg_primary_states",
                       navigation_planning_transitions,
                       navigation_planning_resources),
                navigation_planning_transitions, sm_remapping)

            navigation_go_to_transitions = {
                "succeeded": "succeeded",
                "aborted": "aborted",
                "preempted": "aborted"
            }

            smach.StateMachine.add(
                "navigation_go_to_emotional",
                statemachines.sequence_navigation_go_to_emotional,
                transitions=navigation_go_to_transitions,
                remapping=sm_remapping)

            navigation_go_to_schedular_resources = {}
            smach.StateMachine.add(
                "navigation_go_to_schedular",
                Module("navigation_go_to_schedular", "cyborg_behavior",
                       navigation_go_to_transitions,
                       navigation_go_to_schedular_resources),
                navigation_go_to_transitions, sm_remapping)

            navigation_wandering_emotional_transitions = {
                "navigation_wandering_complete": "succeeded",
                "aborted": "aborted",
                "power_low": "power_low"
            }
            navigation_wandering_emotional_resources = {}

            smach.StateMachine.add(
                "wandering_emotional",
                Module("wandering_emotional", "cyborg_primary_states",
                       navigation_wandering_emotional_transitions,
                       navigation_wandering_emotional_resources),
                navigation_wandering_emotional_transitions, sm_remapping)

        sm_nav_transitions = {
            "aborted": "idle",
            "succeeded": "idle",
            "power_low": "exhausted"
        }
        smach.StateMachine.add("navigation", sm_nav, sm_nav_transitions,
                               sm_remapping)

        music_transitions = {"aborted": "idle", "succeeded": "idle"}
        music_resources = {}
        smach.StateMachine.add(
            "music_horror",
            Module("music_horror", "cyborg_behavior", music_transitions,
                   music_resources), music_transitions, sm_remapping)

        astrolanguage_transitions = {"aborted": "idle", "succeeded": "idle"}
        astrolanguage_resources = {}
        smach.StateMachine.add(
            "astrolanguage",
            Module("astrolanguage", "cyborg_behavior",
                   astrolanguage_transitions, astrolanguage_resources),
            astrolanguage_transitions, sm_remapping)

        sm.register_io_keys(
            {"state_machine_events", "last_state", "last_event"})
        sm_nav.register_io_keys(
            {"state_machine_events", "last_state", "last_event"})

    rospy.sleep(3)
    sis = smach_ros.IntrospectionServer('controller_viewer', sm,
                                        '/controller_viewer')
    sis.start()

    smach_thread = threading.Thread(target=sm.execute)
    smach_thread.daemon = True
    smach_thread.start()
    # Start ROS main looping
    rospy.loginfo("Controller: Activated...")
    rospy.spin()
    sis.stop()
    rospy.loginfo("Controller: Terminated...")
def main():
    rospy.init_node("cyborg_controller")

    # Create emotions
    emotion_system = EmotionSystem()
    emotion_system.add_emotion(name="angry",
                               pleasure=-0.51,
                               arousal=0.59,
                               dominance=0.25)
    emotion_system.add_emotion(name="bored",
                               pleasure=-0.65,
                               arousal=-0.62,
                               dominance=-0.33)
    emotion_system.add_emotion(name="curious",
                               pleasure=0.22,
                               arousal=0.62,
                               dominance=-0.10)
    emotion_system.add_emotion(name="dignified",
                               pleasure=0.55,
                               arousal=0.22,
                               dominance=0.61)
    emotion_system.add_emotion(name="elated",
                               pleasure=0.50,
                               arousal=0.42,
                               dominance=0.23)  # Happy
    emotion_system.add_emotion(name="inhibited",
                               pleasure=-0.54,
                               arousal=-0.04,
                               dominance=-0.41)  # Sadness
    emotion_system.add_emotion(name="puzzled",
                               pleasure=-0.41,
                               arousal=0.48,
                               dominance=-0.33)  # Suprized
    emotion_system.add_emotion(name="loved",
                               pleasure=0.89,
                               arousal=0.54,
                               dominance=-0.18)
    emotion_system.add_emotion(name="unconcerned",
                               pleasure=-0.13,
                               arousal=-0.41,
                               dominance=0.08)

    homedir = os.path.expanduser("~")
    path = homedir + "/controller.db"

    # Fill database with default values
    if (os.path.exists(path) == False):
        event_cost = 0.45
        database_handler = DatabaseHandler(filename=path)
        database_handler.create()
        database_handler.add_event(state="idle",
                                   event="music_play",
                                   reward_pleasure=0.08,
                                   reward_arousal=0.01,
                                   reward_dominance=-0.02,
                                   event_cost=event_cost)
        database_handler.add_event(state="idle",
                                   event="navigation_emotional",
                                   reward_pleasure=0.00,
                                   reward_arousal=0.05,
                                   reward_dominance=-0.01,
                                   event_cost=event_cost)

        database_handler.add_event(state="conversation",
                                   event="weather_tell",
                                   reward_pleasure=0.05,
                                   reward_arousal=0.00,
                                   reward_dominance=0.00,
                                   event_cost=event_cost)
        database_handler.add_event(state="conversation",
                                   event="joke_tell",
                                   reward_pleasure=0.05,
                                   reward_arousal=0.02,
                                   reward_dominance=0.00,
                                   event_cost=event_cost)
        database_handler.add_event(state="conversation",
                                   event="selfie_take",
                                   reward_pleasure=0.05,
                                   reward_arousal=-0.02,
                                   reward_dominance=0.01,
                                   event_cost=event_cost * 1.5)
        database_handler.add_event(state="conversation",
                                   event="simon_says_play",
                                   reward_pleasure=0.00,
                                   reward_arousal=0.00,
                                   reward_dominance=0.10,
                                   event_cost=event_cost)
        database_handler.add_event(state="conversation",
                                   event="follower_follow",
                                   reward_pleasure=0.00,
                                   reward_arousal=0.05,
                                   reward_dominance=-0.05,
                                   event_cost=event_cost)

    # Create motivator
    motivator = Motivator(database_file=path)
    motivator.start()

    # Create a SMACH state machine
    state_machine = smach.StateMachine(outcomes=["error"])
    state_machine.userdata.state_machine_events = []
    state_machine.userdata.last_state = "initializing"
    state_machine.userdata.last_event = "start_up"

    # Open the container
    with state_machine:
        # Remapp outputs, so userdata can be moved between states
        state_machine_remapping = {
            "input_events": "state_machine_events",
            "output_events": "state_machine_events",
            "previous_state": "last_state",
            "current_state": "last_state",
            "previous_event": "last_event",
            "current_event": "last_event"
        }

        # Add states to the container
        idle_transitions = {
            "conversation_interest": "conversation",
            "navigation_schedualer": "navigation_planing",
            "navigation_emotional": "navigation_planing",
            "aborted": "idle",
            "navigation_command": "navigation_planing",
            "music_play": "music"
        }
        idle_resources = {}  # Idle does not require any resources
        smach.StateMachine.add(label="idle",
                               state=Module(state_name="idle",
                                            actionlib_name="cyborg_idle/idle",
                                            transitions=idle_transitions,
                                            resources=idle_resources),
                               transitions=idle_transitions,
                               remapping=state_machine_remapping)

        conversation_transitions = {
            "aborted": "idle",
            "succeded": "idle",
            "navigation_feedback": "navigation_talking",
            "navigation_command": "navigation_talking",
            "navigation_information": "navigation_talking",
            "simon_says_play": "simon_says",
            "selfie_take": "selfie",
            "follower_follow": "follower",
            "weather_tell": "weather",
            "joke_tell": "joke"
        }
        conversation_resources = {"trollface": "cyborg_conversation"}
        smach.StateMachine.add(
            label="conversation",
            state=Module(state_name="conversation",
                         actionlib_name="cyborg_conversation/conversation",
                         transitions=conversation_transitions,
                         resources=conversation_resources),
            transitions=conversation_transitions,
            remapping=state_machine_remapping)

        navigation_transitions = {
            "aborted": "navigation_talking",
            "navigation_start_wandering": "navigation_moving",
            "navigation_start_moving": "navigation_moving",
            "succeded": "navigation_talking"
        }
        navigation_resources = {"base": "cyborg_navigation"}
        smach.StateMachine.add(label="navigation_planing",
                               state=Module(
                                   state_name="navigation_planing",
                                   actionlib_name="cyborg_navigation/planing",
                                   transitions=navigation_transitions,
                                   resources=navigation_resources),
                               transitions=navigation_transitions,
                               remapping=state_machine_remapping)

        navigation_transitions = {
            "aborted": "navigation_talking",
            "succeded": "navigation_talking",
            "navigation_wandering_completed": "idle"
        }
        navigation_resources = {"base": "cyborg_navigation"}
        smach.StateMachine.add(label="navigation_moving",
                               state=Module(
                                   state_name="navigation_moving",
                                   actionlib_name="cyborg_navigation/moving",
                                   transitions=navigation_transitions,
                                   resources=navigation_resources),
                               transitions=navigation_transitions,
                               remapping=state_machine_remapping)

        navigation_transitions = {
            "aborted": "idle",
            "succeded": "idle",
            "navigation_feedback_completed": "conversation",
            "navigation_command": "navigation_planing"
        }
        navigation_resources = {
            "base": "cyborg_navigation",
            "trollface": "cyborg_navigation"
        }
        smach.StateMachine.add(label="navigation_talking",
                               state=Module(
                                   state_name="navigation_talking",
                                   actionlib_name="cyborg_navigation/talking",
                                   transitions=navigation_transitions,
                                   resources=navigation_resources),
                               transitions=navigation_transitions,
                               remapping=state_machine_remapping)

        music_transitions = {
            "aborted": "idle",
            "succeded": "idle",
            "conversation_interest": "conversation"
        }
        music_resources = {}
        smach.StateMachine.add(label="music",
                               state=Module(
                                   state_name="music",
                                   actionlib_name="cyborg_music/music",
                                   transitions=music_transitions,
                                   resources=music_resources),
                               transitions=music_transitions,
                               remapping=state_machine_remapping)

        smach.StateMachine.add(
            label="simon_says",
            state=Module(state_name="simon_says",
                         actionlib_name="cyborg_conversation/simon_says",
                         transitions={
                             "aborted": "conversation",
                             "succeded": "conversation"
                         },
                         resources={"trollface": "cyborg_simon_says"}),
            transitions={
                "aborted": "conversation",
                "succeded": "conversation"
            },
            remapping=state_machine_remapping)

        smach.StateMachine.add(label="selfie",
                               state=Module(
                                   state_name="selfie",
                                   actionlib_name="cyborg_conversation/selfie",
                                   transitions={
                                       "aborted": "conversation",
                                       "succeded": "conversation"
                                   },
                                   resources={"trollface": "cyborg_selfie"}),
                               transitions={
                                   "aborted": "conversation",
                                   "succeded": "conversation"
                               },
                               remapping=state_machine_remapping)

        smach.StateMachine.add(
            label="follower",
            state=Module(state_name="follower",
                         actionlib_name="cyborg_conversation/follower",
                         transitions={
                             "aborted": "conversation",
                             "succeded": "conversation"
                         },
                         resources={"trollface": "cyborg_follower"}),
            transitions={
                "aborted": "conversation",
                "succeded": "conversation"
            },
            remapping=state_machine_remapping)

        smach.StateMachine.add(
            label="weather",
            state=Module(state_name="weather",
                         actionlib_name="cyborg_conversation/weather",
                         transitions={
                             "aborted": "conversation",
                             "succeded": "conversation"
                         },
                         resources={"trollface": "cyborg_weather"}),
            transitions={
                "aborted": "conversation",
                "succeded": "conversation"
            },
            remapping=state_machine_remapping)

        smach.StateMachine.add(
            label="joke",  # name on state
            state=Module(
                state_name="joke",  # name on state
                actionlib_name="cyborg_conversation/joke",  # actionlib name
                transitions={
                    "aborted": "conversation",
                    "succeded": "conversation"
                },  #event name:state - events that leads away from state
                resources={"trollface": "cyborg_joke"
                           }),  # for gatekeepers: resource_name:node_name
            transitions={
                "aborted": "conversation",
                "succeded": "conversation"
            },
            remapping=state_machine_remapping)

        ################################################### ADD MORE STATES BELOW ###################################################

        ################################################### STOP ADDING YOUR STATES ###################################################

    # Create a state machine monitorer
    smm = StateMachineMonitor(state_machine, display_all=True)
    rospy.loginfo("Controller: State Machine Monitor Activated...")

    import smach_ros
    sis = smach_ros.IntrospectionServer('controler_viewer', state_machine,
                                        '/controler_viewer')
    sis.start()

    # Create a thread to execute the smach
    smach_thread = threading.Thread(target=state_machine.execute)
    smach_thread.daemon = True
    smach_thread.start()
    rospy.loginfo("Controller: SMACH activated...")

    # Start ROS main looping
    rospy.loginfo("Controller: Activated...")
    rospy.spin()
    sis.stop()
    rospy.loginfo("Controller: Terminated...")