Beispiel #1
0
def MainTaskFood(name, task):
    if (Settings.PositionRon == []):
        Settings.ModifyName(name[0])
        list_rooms = [
            'Personalroom', 'Kitchen', 'Bedroom', 'Bathroom', 'Livingroom',
            'Floor', 'Door'
        ]
        event, position_start = Window(robot_gui_title,
                                       'Hi %s , in which room i am ?' % (name),
                                       'LB', list_rooms, True)
        if event == 'Ok' or event == 'Read From Sensor':
            if (event != 'Read From Sensor'):
                Settings.SetPositionRon(position_start['LB'][0])
            else:
                Settings.SetPositionRon(random.choice(list_rooms))
            if (Settings.HasKeys == [] and Settings.PositionPerson == []):
                solution, goal_position, where_food, has_food = RonTaskFood(
                    Settings.PositionRon[0], Settings.PositionFood[0])
                actions = define_actions_robot(solution)
                Settings.SetActualSolution(solution)
                if (Settings.ActualSolution != [[]]):
                    start_pos_mess = start_position_message_food(
                        robot_position=Settings.PositionRon[0],
                        position_object=where_food,
                        person_position=Settings.PositionPerson[0])
                    plan_mess = planning_message_food(has_food=has_food,
                                                      planning=actions)
                    Popup('Start Position : ', start_pos_mess)
                    Popup('Solution : ', plan_mess)
                    robot_environment(actions,
                                      Settings.PositionRon[0],
                                      where_food,
                                      goal_position,
                                      has_food,
                                      targ=task)
                else:
                    event, sol = Window(
                        robot_gui_title,
                        'the problem is not feasible.\nIt is necessary to add in Database Of Actions of Ron:\n-PickupFood\n-DropFood. \nYou can choose one of these actions :\nP.s You can Add also an action\nthat will be useful after for other task.',
                        list=Settings.AllActions,
                        key="ADD_DEL_ACT")

                    if event == 'Ok':
                        Settings.AddAction(sol['ADD_DEL_ACT'][0])
                        Settings.DropAction((sol['ADD_DEL_ACT'][0]).name)
                        ModifyDatabaseActions(Settings.ActualActions)
                        ModifyDatabaseAllActionsAvailable(Settings.AllActions)
                        MainTaskFood(name, task)
                    else:
                        PopupCancel(robot_gui_aborted)

        else:
            PopupCancel(robot_gui_aborted)
    else:
        solution, goal_position, where_food, has_keys = RonTaskFood(
            Settings.PositionRon[0], Settings.PositionFood[0])
        Settings.SetActualSolution(solution)
        if (Settings.ActualSolution != [[]]):
            if (Settings.HasFood[0] == 'no'):
                Has_food = False
            else:
                Has_food = True
            actions = define_actions_robot(Settings.ActualSolution[0])

            start_pos_mess = start_position_message_food(
                robot_position=Settings.PositionRon[0],
                position_object=where_food,
                person_position=Settings.PositionPerson[0])
            plan_mess = planning_message_food(has_food=Has_food,
                                              planning=actions)

            Popup('Start Position : ', start_pos_mess)
            Popup('Solution : ', plan_mess)
            robot_environment(actions, Settings.PositionRon[0], where_food,
                              goal_position, Has_food, task)
        else:
            event, sol = Window(
                robot_gui_title,
                'the problem is not feasible.\nIt is necessary to add in Database Of Actions of Ron:\n-PickupFood\n-DropFood. \nYou can choose one of these actions :\nP.s You can Add also an action\nthat will be useful after for other task.',
                list=Settings.AllActions,
                key="ADD_DEL_ACT")

            if event == 'Ok':
                Settings.AddAction(sol['ADD_DEL_ACT'][0])
                Settings.DropAction((sol['ADD_DEL_ACT'][0]).name)
                ModifyDatabaseActions(Settings.ActualActions)
                ModifyDatabaseAllActionsAvailable(Settings.AllActions)
                MainTaskFood(name, task)
            else:
                PopupCancel(robot_gui_aborted)
Beispiel #2
0
def MainTaskOnOffTV(name, task):
    if (Settings.PositionRon == [] and Settings.PositionController == []):
        Settings.ModifyName(name[0])
        event, onTv = Window(robot_gui_title,
                             '%s , I have to on or off the TV?' % (name),
                             'OTV', ['OnTv', 'OffTv'])
        if event == 'Ok':
            Settings.OnTv = onTv['OTV'][0]
            OnOrOffTv = Settings.OnTv
            list_rooms = [
                'Personalroom', 'Kitchen', 'Bedroom', 'Bathroom', 'Livingroom',
                'Floor'
            ]
            event, position_start = Window(
                robot_gui_title, 'Hi %s , in which room i am ?' % (name), 'LB',
                list_rooms, True)
            if event == 'Ok' or event == 'Read From Sensor':
                if (event != 'Read From Sensor'):
                    Settings.SetPositionRon(position_start['LB'][0])
                else:
                    Settings.SetPositionRon(random.choice(list_rooms))
                if (Settings.HasController == []):
                    solution, goal_position, where_controller, has_controller = RonTaskOnOffTv(
                        Settings.PositionRon[0], OnOrOffTv)
                    actions = define_actions_robot(solution)
                    Settings.SetActualSolution(solution)
                    if (Settings.ActualSolution != [[]]):
                        start_pos_mess = start_position_message_tv(
                            robot_position=Settings.PositionRon[0],
                            position_object=where_controller,
                            position_tv=Settings.PositionTv[0])
                        plan_mess = planning_message_tv(
                            has_controller=has_controller, planning=actions)
                        Popup('Start Position : ', start_pos_mess)
                        Popup('Solution : ', plan_mess)
                        robot_environment(actions,
                                          Settings.PositionRon[0],
                                          where_controller,
                                          goal_position,
                                          has_controller,
                                          targ=task)
                    else:
                        event, sol = Window(
                            robot_gui_title,
                            'the problem is not feasible.\nIt is necessary to add in Database Of Actions of Ron:\n-OnTv / OffTv\n-PickupController. \nYou can choose one of these actions :\nP.s You can Add also an action\nthat will be useful after for other task.',
                            list=Settings.AllActions,
                            key="ADD_DEL_ACT")

                        if event == 'Ok':
                            Settings.AddAction(sol['ADD_DEL_ACT'][0])
                            Settings.DropAction((sol['ADD_DEL_ACT'][0]).name)
                            ModifyDatabaseActions(Settings.ActualActions)
                            ModifyDatabaseAllActionsAvailable(
                                Settings.AllActions)
                            MainTaskOnOffTV(name, task)
                        else:
                            PopupCancel(robot_gui_aborted)

            else:
                PopupCancel(robot_gui_aborted)

        else:
            PopupCancel(robot_gui_aborted)
    else:
        OnOrOffTv = Settings.OnTv
        solution, goal_position, where_controller, has_controller = RonTaskOnOffTv(
            Settings.PositionRon[0], OnOrOffTv)
        Settings.SetActualSolution(solution)
        if (Settings.ActualSolution != [[]]):
            if (Settings.HasController[0] == 'no'):
                Has_controller = False
            else:
                Has_controller = True
            actions = define_actions_robot(Settings.ActualSolution[0])

            start_pos_mess = start_position_message_tv(
                robot_position=Settings.PositionRon[0],
                position_object=where_controller,
                position_tv=Settings.PositionTv[0])
            plan_mess = planning_message_tv(has_controller=Has_controller,
                                            planning=actions)

            Popup('Start Position : ', start_pos_mess)
            Popup('Solution : ', plan_mess)
            robot_environment(actions,
                              Settings.PositionRon[0],
                              where_controller,
                              goal_position,
                              Has_controller,
                              targ=task)
        else:
            event, sol = Window(
                robot_gui_title,
                'the problem is not feasible.\nIt is necessary to add in Database Of Actions of Ron:\n-OnTv / OffTv\n-PickupController\nYou can choose one of these actions :\nP.s You can Add also an action\nthat will be useful after for other task.',
                list=Settings.AllActions,
                key="ADD_DEL_ACT")

            if event == 'Ok':
                Settings.AddAction(sol['ADD_DEL_ACT'][0])
                Settings.DropAction((sol['ADD_DEL_ACT'][0]).name)
                ModifyDatabaseActions(Settings.ActualActions)
                ModifyDatabaseAllActionsAvailable(Settings.AllActions)
                MainTaskOnOffTV(name, task)
            else:
                PopupCancel(robot_gui_aborted)
Beispiel #3
0
def MainTaskOpenCloseGarage(name, task):
    if (Settings.PositionRon == []):
        Settings.ModifyName(name[0])
        event, taskOpenClose = Window(
            robot_gui_title,
            '%s , I have to open or close the Garage?' % (name), 'OCG',
            ['OpenGarage', 'CloseGarage'])
        Settings.SetOpenGarage(taskOpenClose['OCG'][0])
        if event == 'Ok':
            taskOpenClose = taskOpenClose['OCG'][0]
            list_rooms = [
                'Personalroom', 'Kitchen', 'Bedroom', 'Bathroom', 'Livingroom',
                'Floor', 'Door'
            ]
            event, position_start = Window(
                robot_gui_title, 'Hi %s , in which room i am ?' % (name), 'LB',
                list_rooms, True)
            if event == 'Ok' or event == 'Read From Sensor':
                if (event != 'Read From Sensor'):
                    Settings.SetPositionRon(position_start['LB'][0])
                else:
                    Settings.SetPositionRon(random.choice(list_rooms))
                if (Settings.HasKeys == [] and Settings.PositionKeys == []):
                    solution, goal_position, where_key, has_keys = RonTaskOpenCloseGarage(
                        Settings.PositionRon[0],
                        taskOpenCloseOff=taskOpenClose)
                    actions = define_actions_robot(solution)
                    Settings.SetActualSolution(solution)
                    if (Settings.ActualSolution != [[]]):
                        start_pos_mess = start_position_message_open_close_garage(
                            robot_position=Settings.PositionRon[0],
                            position_object=Settings.PositionKeys[0],
                            person_position=Settings.PositionGarage[0])
                        plan_mess = planning_message_open_close_garage(
                            has_keys=has_keys, planning=actions)
                        Popup('Start Position : ', start_pos_mess)
                        Popup('Solution : ', plan_mess)
                        robot_environment(actions,
                                          Settings.PositionRon[0],
                                          where_key,
                                          goal_position,
                                          has_keys,
                                          targ=task)
                    else:
                        event, sol = Window(
                            robot_gui_title,
                            'the problem is not feasible.\nIt is necessary to add in Database Of Actions of Ron:\n-PickupKeys\n-OpenGarage / CloseGarage\n.\nYou can choose one of these actions\nP.s You can Add also an action\nthat will be useful after for other task.',
                            list=Settings.AllActions,
                            key="ADD_DEL_ACT")

                        if event == 'Ok':
                            Settings.AddAction(sol['ADD_DEL_ACT'][0])
                            Settings.DropAction((sol['ADD_DEL_ACT'][0]).name)
                            ModifyDatabaseActions(Settings.ActualActions)
                            ModifyDatabaseAllActionsAvailable(
                                Settings.AllActions)
                            MainTaskOpenCloseGarage(name, task)
                        else:
                            PopupCancel(robot_gui_aborted)

            else:
                PopupCancel(robot_gui_aborted)
                Settings.ClearActualSolution()
        else:
            PopupCancel(robot_gui_aborted)
            Settings.ClearActualSolution()
    else:
        taskOpenClose = Settings.OpenGarage[0]
        solution, goal_position, where_key, has_keys = RonTaskOpenCloseGarage(
            Settings.PositionRon[0], taskOpenCloseOff=taskOpenClose)
        Settings.SetActualSolution(solution)
        if (Settings.ActualSolution != [[]]):
            if (Settings.HasKeys[0] == 'no'):
                Has_key = False
            else:
                Has_key = True
            actions = define_actions_robot(Settings.ActualSolution[0])

            start_pos_mess = start_position_message_open_close_garage(
                robot_position=Settings.PositionRon[0],
                position_object=Settings.PositionKeys[0],
                person_position=Settings.PositionGarage[0])
            plan_mess = planning_message_open_close_garage(has_keys=Has_key,
                                                           planning=actions)

            Popup('Start Position : ', start_pos_mess)
            Popup('Solution : ', plan_mess)
            robot_environment(actions,
                              Settings.PositionRon[0],
                              Settings.PositionKeys[0],
                              Settings.PositionGarage[0],
                              Has_key,
                              targ=task)
        else:
            event, sol = Window(
                robot_gui_title,
                'the problem is not feasible.\nIt is necessary to add in Database Of Actions of Ron:\n-PickupKeys\n-OpenGarage / CloseGarage.\nYou can choose one of these actions\nP.s You can Add also an action\nthat will be useful after for other task.',
                list=Settings.AllActions,
                key="ADD_DEL_ACT")

            if event == 'Ok':
                Settings.AddAction(sol['ADD_DEL_ACT'][0])
                Settings.DropAction(sol['ADD_DEL_ACT'][0].name)
                ModifyDatabaseActions(Settings.ActualActions)
                ModifyDatabaseAllActionsAvailable(Settings.AllActions)
                MainTaskOpenCloseGarage(name, task)
            else:
                PopupCancel(robot_gui_aborted)
                Settings.ClearActualSolution()