示例#1
0
文件: core.py 项目: lubosz/rosstacks
    def _load_for_package(self, package, ros_package_proxy):
        """ Load into local structures the information for this
        specific package 

        Called in constructor. """

        try:
            rosdep_dependent_packages = ros_package_proxy.depends([package])[package]
        except KeyError as ex:
            print("Depends Failed on package", ex)
            print(" The errors was in ", ros_package_proxy.depends([package]))
            rosdep_dependent_packages = []
        rosdep_dependent_packages.append(package)

        paths = set()
        rospack = rospkg.RosPack()
        rosstack = rospkg.RosStack()
        for p in rosdep_dependent_packages:
            stack = None
            try:
                stack = rospack.stack_of(p)
            except rospkg.ResourceNotFound as ex:
                print("Failed to find stack for package [%s]" % p, file=sys.stderr)
            if stack:
                try:
                    paths.add(os.path.join(rosstack.get_path(stack), "rosdep.yaml"))
                    if "ROSDEP_DEBUG" in os.environ:
                        print("loading rosdeps from", os.path.join(rosstack.get_path(stack), "rosdep.yaml"))
                except AttributeError as ex:
                    print("Stack [%s] could not be found" % (stack))
                for s in self.yaml_cache.get_rosstack_depends(stack):
                    try:
                        paths.add(os.path.join(rosstack.get_path(s), "rosdep.yaml"))
                    except AttributeError as ex:
                        print("Stack [%s] dependency of [%s] could not be found" % (s, stack))

            else:
                try:
                    paths.add(os.path.join(rospack.get_path(p), "rosdep.yaml"))
                    if "ROSDEP_DEBUG" in os.environ:
                        print(
                            "Package fallback, no parent stack found for package %s: loading rosdeps from" % p,
                            os.path.join(rospack.get_path(p), "rosdep.yaml"),
                        )
                except rospkg.ResourceNotFound as ex:
                    print("Failed to load rosdep.yaml for package [%s]:%s" % (p, ex), file=sys.stderr)
        for path in paths:
            yaml_in = self.parse_yaml(path)
            self._insert_map(yaml_in, path)
            if "ROSDEP_DEBUG" in os.environ:
                print("rosdep loading from file: %s got" % path, yaml_in)

        # Override with ros_home/rosdep.yaml if present
        ros_home = rospkg.get_ros_home()
        path = os.path.join(ros_home, "rosdep.yaml")
        self._insert_map(self.parse_yaml(path), path, override=True)
示例#2
0
文件: core.py 项目: lubosz/rosstacks
    def where_defined(self, rosdeps):
        output = ""
        locations = {}

        for r in rosdeps:
            locations[r] = set()

        rospack = rospkg.RosPack()

        path = os.path.join(rospkg.get_ros_home(), "rosdep.yaml")
        rosdep_dict = self.yc.get_specific_rosdeps(path)
        for r in rosdeps:
            if r in rosdep_dict:
                locations[r].add("Override:" + path)

        for p in rospack.list():
            path = os.path.join(rospack.get_path(p), "rosdep.yaml")
            rosdep_dict = self.yc.get_specific_rosdeps(path)
            for r in rosdeps:
                if r in rosdep_dict:
                    addendum = ""
                    if rospack.stack_of(p):
                        addendum = "<<Unused due to package '%s' being in a stack.]]" % p
                    locations[r].add(">>" + path + addendum)

        rosstack = rospkg.RosStack()
        for s in rosstack.list():
            path = os.path.join(rosstack.get_path(s), "rosdep.yaml")
            rosdep_dict = self.yc.get_specific_rosdeps(path)
            for r in rosdeps:
                if r in rosdep_dict:
                    locations[r].add(path)

        for rd in locations:
            output += "%s defined in %s" % (rd, locations[rd])
        return output
示例#3
0
    def __init__(self,app):
        super(Instructor,self).__init__()
        rospy.logwarn('INSTRUCTOR: STARTING UP...')
        self.app_ = app
        # self.setMinimumWidth(700)
        # self.setMinimumHeight(500)
        self.types__ = ['LOGIC', 'ACTION', 'SERVICE', 'CONDITION', 'QUERY', 'PROCESS', 'VARIABLE']
        # Load the ui attributes into the main widget
        rospack = rospkg.RosPack()
        ui_path = rospack.get_path('instructor_core') + '/ui/main_alt.ui'
        uic.loadUi(ui_path, self)
        # Create the Graph Visualization Pane
        self.dot_widget = DotWidget()
        self.instructor_layout.addWidget(self.dot_widget)    
        # Finish Up
        self.show()

        # Running the tree
        self.running__ = False
        self.run_timer_ = QTimer(self)
        self.connect(self.run_timer_, QtCore.SIGNAL("timeout()"), self.run)

        # Set up ros_ok watchdog timer to handle termination and ctrl-c
        self.ok_timer_ = QTimer(self)
        self.connect(self.ok_timer_, QtCore.SIGNAL("timeout()"), self.check_ok)
        self.ok_timer_.start(100)

        # Load Settings
        self.settings = QSettings('settings.ini', QSettings.IniFormat)
        self.settings.setFallbacksEnabled(False) 
        self.resize( self.settings.value('size', QSize(800, 800), type=QSize) )
        self.move(self.settings.value('pos', QPoint(50, 50), type=QPoint))
        # self.showMaximized()

        # Set up Behavior Tree structure
        self.current_tree = {}
        self.current_generators = {}
        self.all_generators = {}
        
        self.current_node_info ={}
        self.current_node_generator = None

        self.current_plugin_names = {}
        self.current_node_types = {}
        self.root_node = None
        self.gui_selected_node = None
        self.selected_node_field.setText('NONE')
        # Get known Beetree Builder Node Plugins
        self.parse_plugin_info()
        # Set up the gui with plugin information
        self.set_up_gui()
        # Set up communication between node view and the rest of the app
        self.connect(self.dot_widget,SIGNAL("clicked"), self.node_gui_selected_cb)
        self.connect(self.dot_widget,SIGNAL("right_clicked"), self.node_gui_alt_selected_cb)

        # Set up librarian
        self.set_type_service = rospy.ServiceProxy('/librarian/add_type', librarian_msgs.srv.AddType)
        self.save_service = rospy.ServiceProxy('/librarian/save', librarian_msgs.srv.Save)
        self.load_service = rospy.ServiceProxy('/librarian/load', librarian_msgs.srv.Load)
        self.list_service = rospy.ServiceProxy('/librarian/list', librarian_msgs.srv.List)
        self.set_type_service('instructor_node')
        self.set_type_service('instructor_subtree')