How to use the rospkg.RosStack function in rospkg

To help you get started, we’ve selected a few rospkg examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ros-infrastructure / rosdep / test / test_rosdep_rospkg_loader.py View on Github external
def get_rospkg():
    # configure inside of the test tree
    test_dir = get_test_dir()
    ros_root = os.path.join(test_dir, 'ros')
    ros_package_path = os.path.join(test_dir, 'stacks')
    ros_paths = [ros_root, ros_package_path]
    rospack = RosPack(ros_paths=ros_paths)
    rosstack = RosStack(ros_paths=ros_paths)
    return rospack, rosstack
github git-afsantos / haros / haros / extractor.py View on Github external
for pkginfo in pkglist:
                    pkginfo_parts = pkginfo.split('\t')
                    if len(pkginfo_parts) < 2:
                        continue
                    if pkginfo_parts[0] in pkgs:
                        continue
                    pkgs[pkginfo_parts[0]] = pkginfo_parts[1]
                return pkgs
            except:
                pass
        # ^ if colcon != None
    # ^ if ros_version != "1"
    # else: try the ROS1 way
    ros = None
    if as_stack:
        ros = RosStack.get_instance(paths)
    else:
        ros = RosPack.get_instance(paths)
    pkg_names = ros.list()
    pkgs = {}
    for pkg_name in pkg_names:
        if pkg_name in pkgs:
            continue
        pkgs[pkg_name] = ros.get_path(pkg_name)
    return pkgs
# ^ findRosPackages(paths)
github ros-infrastructure / rosdep / src / rosdep2 / main.py View on Github external
path = os.path.abspath(path)
            if 'ROS_PACKAGE_PATH' not in os.environ:
                os.environ['ROS_PACKAGE_PATH'] = '{0}'.format(path)
            else:
                os.environ['ROS_PACKAGE_PATH'] = '{0}{1}{2}'.format(
                    path,
                    os.pathsep,
                    os.environ['ROS_PACKAGE_PATH']
                )
            pkgs = find_catkin_packages_in(path, options.verbose)
            packages.extend(pkgs)
        # Make packages list unique
        packages = list(set(packages))
    else:
        rospack = rospkg.RosPack()
        rosstack = rospkg.RosStack()
        val = rospkg.expand_to_packages(args, rospack, rosstack)
        packages = val[0]
        not_found = val[1]
    if not_found:
        raise rospkg.ResourceNotFound(not_found[0], rospack.get_ros_paths())

    # Handle the --ignore-src option
    if command in ['install', 'check', 'keys'] and options.ignore_src:
        if options.verbose:
            print('Searching ROS_PACKAGE_PATH for '
                  'sources: ' + str(os.environ['ROS_PACKAGE_PATH'].split(':')))
        ws_pkgs = get_workspace_packages()
        for path in os.environ['ROS_PACKAGE_PATH'].split(':'):
            path = os.path.abspath(path.strip())
            if os.path.exists(path):
                pkgs = find_catkin_packages_in(path, options.verbose)
github ros / ros_comm / utilities / roswtf / src / roswtf / stacks.py View on Github external
def manifest_depends(ctx):
    # This rule should probably be cache optimized
    errors = []
    rospack = rospkg.RosPack()
    rosstack = rospkg.RosStack()

    stack_list = rosstack.list()
    #print stack_list
    for s in ctx.stacks:
        try:
            s_deps = []
            s_pkgs = _packages_of(rosstack, s)
            for p in s_pkgs:
                s_deps.extend(rospack.get_depends(p, implicit=False))
            m = rosstack.get_manifest(s)
            m_file = os.path.join(rosstack.get_path(s), 'stack.xml')
            for d in m.depends:
                if not d.name in stack_list:
                    errors.append("%s (%s does not exist)"%(m_file, d))
                elif d.name in ['ros', 'ros_comm']:
                    # ros dependency always exists. ros_comm
github ros / ros / core / roslib / src / roslib / stacks.py View on Github external
def _init_rosstack(env=None):
    global _rosstack, _ros_paths
    if env is None:
        env = os.environ
    ros_paths = rospkg.get_ros_paths(env)
    if ros_paths != _ros_paths:
        _ros_paths = ros_paths
        _rosstack = rospkg.RosStack(ros_paths)
github ros-infrastructure / rosdep / src / rosdep2 / lookup.py View on Github external
"""
        Create :class:`RosdepLookup` based on current ROS package
        environment.

        :param rospack: (optional) Override :class:`rospkg.RosPack`
          instance used to crawl ROS packages.
        :param rosstack: (optional) Override :class:`rospkg.RosStack`
          instance used to crawl ROS stacks.
        :param sources_loader: (optional) Override SourcesLoader used
            for managing sources.list data sources.
        """
        # initialize the loader
        if rospack is None:
            rospack = RosPack()
        if rosstack is None:
            rosstack = RosStack()
        if sources_loader is None:
            sources_loader = SourcesListLoader.create_default(verbose=verbose)

        rosdep_db = RosdepDatabase()

        # Use sources list to initialize rosdep_db.  Underlay has no
        # notion of specific resources, and its view keys are just the
        # individual sources it can load from.  SourcesListLoader
        # cannot do delayed evaluation of OS setting due to matcher.
        underlay_key = SourcesListLoader.ALL_VIEW_KEY

        # Create the rospkg loader on top of the underlay
        loader = RosPkgLoader(rospack=rospack, rosstack=rosstack,
                              underlay_key=underlay_key)

        # create our actual instance