예제 #1
0
    def __init__(self):
        """
        This class manage the robot task planning. A list of goals can be set by
        external agent (e.g. users) with the action server 'task_plan' The task
        manager plans a sequence of skills to reach the goals and returns it.

        Initialize task manager as a ros node. Establish access to the global
        and local world model, skill manager and the task planner.
        """
        rospy.init_node("task_manager", anonymous=False)
        self._author_name = rospy.get_name()

        self._goals = []
        self._skills = {}
        self._abstract_objects = []

        self._wmi = wmi.WorldModelInterface(self._author_name)
        self._sli = sli.SkillLayerInterface(self._author_name)
        self._pddl_interface = pddl.PddlInterface()

        self._verbose = rospy.get_param('~verbose', True)
        log.setLevel(log.INFO)
        self._assign_task_action = actionlib.SimpleActionServer(
            '~task_plan',
            msgs.AssignTaskAction,
            execute_cb=self._assign_task_cb,
            auto_start=False)
        self._assign_task_action.start()

        self._is_ready = False
예제 #2
0
    def __init__(self):
        """Initialization of the task manager.

        Initialize task manager as a ros node.
        Establish access to the global and local world model, skill manager and the task planner.
        """
        rospy.init_node("task_manager", anonymous=False)
        self._author_name = rospy.get_name()

        self._goals = []
        self._skills = {}
        self._abstract_objects = []

        self._wmi = wmi.WorldModelInterface(self._author_name)
        self._sli = sli.SkillLayerInterface(self._author_name)
        self._pddl_interface = pddl.PddlInterface(
            workspace=rospkg.RosPack().get_path("skiros2_task"))

        self._verbose = rospy.get_param('~verbose', True)
        self._assign_task_action = actionlib.SimpleActionServer(
            '~task_plan',
            msgs.AssignTaskAction,
            execute_cb=self._assign_task_cb,
            auto_start=False)
        self._assign_task_action.start()

        self._is_ready = False
예제 #3
0
    def reset(self):
        # The plugin should not call init_node as this is performed by rqt_gui_py.
        # Due to restrictions in Qt, you cannot manipulate Qt widgets directly within ROS callbacks,
        # because they are running in a different thread.
        self.initInteractiveServer(SkirosWidget.widget_id)
        self._wmi = wmi.WorldModelInterface(SkirosWidget.widget_id)
        self._sli = sli.SkillLayerInterface(SkirosWidget.widget_id)

        # Setup a timer to keep interface updated
        self.refresh_timer = QTimer()
        self.refresh_timer.timeout.connect(self.refresh_timer_cb)
        self.refresh_timer.start(500)
        self.robot_sub = rospy.Subscriber('/robot_output', String, self.robot_output_cb)
        self.robot_text = ""


        # World model tab
        self._wmi.set_monitor_cb(lambda d: self.wm_update_signal.emit(d))
        self._sli.set_monitor_cb(lambda d: self.task_progress_signal.emit(d))
        self._snapshot_id = ""
        self._snapshot_stamp = rospy.Time.now()
        self._wm_mutex = Lock()
        self._task_mutex = Lock()

        # Skill tab
        self.last_executed_skill = ""
        self.skill_stop_button.setEnabled(False)
        self.space_shortcut = QShortcut(QtGui.QKeySequence(Qt.Key_Space), self)
        self.space_shortcut.activated.connect(self.skill_start_stop)
        # self.space_shortcut.setContext(QtCore.Qt.WidgetWithChildrenShortcut)
        # Log tab
        self.log_file = None
        self.icons = dict()
예제 #4
0
 def __init__(self, qtbot, tmp_dir, init_scene):
     self.qtbot = qtbot
     self.tmp_dir = tmp_dir
     self.init_scene = init_scene
     self.widget = SkirosWidget()
     self.qtbot.addWidget(self.widget)
     self.wmi = wmi.WorldModelInterface()
     self._file_paths = []
예제 #5
0
def wm_tmp_dir():
    tmp_dir = 'tmp_dir'
    init_scene = 'init_scene.turtle'
    tmp_name = os.path.join(tmp_dir, init_scene)
    wm_inst = wmi.WorldModelInterface()
    wm_inst.save(tmp_name)
    yield [tmp_dir, init_scene]
    #tear down
    tmp_path = wm_file_path(tmp_dir)
    shutil.rmtree(tmp_path)
예제 #6
0
 def __init__(self, prefix, agent_name, verbose=True):
     self._agent_name = agent_name
     self._wmi = wmi.WorldModelInterface(agent_name, make_cache=True)
     self._wmi.set_default_prefix(prefix)
     self._local_wm = self._wmi
     self._instanciator = SkillInstanciator(self._local_wm)
     self._ticker = BtTicker()
     self._verbose = verbose
     self._ticker._verbose = verbose
     self._register_agent(agent_name)
     self._skills = []