How to use the rospkg.distro 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 / catkin / test / checks / fuerte / distro-to-install.py View on Github external
def go(argv):
  if len(argv) != 2:
    print('wrong number args')
    sys.exit(1)

  d=rospkg.distro.load_distro(argv[1])
  ri=rospkg.distro.distro_to_rosinstall(d, 'release')
  print(ri)
github ros-infrastructure / rosdep / test / test_rosdep_sources_list.py View on Github external
def test_DataSourceMatcher_create_default():
    distro_name = rospkg.distro.current_distro_codename()
    os_detect = rospkg.os_detect.OsDetect()
    os_name, os_version, os_codename = os_detect.detect_os()

    matcher = rosdep2.sources_list.DataSourceMatcher.create_default()

    # matches full
    os_data_source = rosdep2.sources_list.DataSource('yaml', 'http://fake/url', [distro_name, os_name, os_codename])
    assert matcher.matches(os_data_source)

    # matches against current os
    os_data_source = rosdep2.sources_list.DataSource('yaml', 'http://fake/url', [os_name, os_codename])
    assert matcher.matches(os_data_source)

    # matches against current distro
    distro_data_source = rosdep2.sources_list.DataSource('yaml', 'http://fake/url', [distro_name])
    assert matcher.matches(distro_data_source)
github robotcaresystems / RoboticsLanguage / RoboticsLanguage / Transformers / ROS / Transform.py View on Github external
def transform(code, parameters):

    # save ros distribution value
    parameters['Transformers']['ROS']['distribution'] = distro.current_distro_codename()

    # make sure RosCpp is part of the output
    if any(x in parameters['globals']['output'] for x in ['RosCpp', 'HTMLGUI', 'Ros2Cpp', 'RosPy']):

      # Types
      code, parameters = Types.process(code, parameters)

      # Topics
      code, parameters = Topics.process(code, parameters)

      # Ros messages
      code, parameters = RosMessage.process(code, parameters)

      # Ros classes
      code, parameters = RosClass.process(code, parameters)
github ros / ros_comm / tools / roslaunch / src / roslaunch / config.py View on Github external
def calculate_env_loader(env=None):
    """
    @raise RLException
    """
    if env is None:
        env = os.environ
    # guess the env loader based on distro name
    distro_name = rospkg.distro.current_distro_codename()
    # sanity check
    if distro_name in ['electric', 'diamondback', 'cturtle']:
        raise RLException("This version of roslaunch is not compatible with pre-Fuerte ROS distributions")
    return '/opt/ros/%s/env.sh'%(distro_name)
github ros-infrastructure / rosdep / src / rosdep2 / sources_list.py View on Github external
def create_default(os_override=None):
        """
        Create a :class:`DataSourceMatcher` to match the current
        configuration.

        :param os_override: (os_name, os_codename) tuple to override
            OS detection
        :returns: :class:`DataSourceMatcher`
        """
        distro_name = rospkg.distro.current_distro_codename()
        if os_override is None:
            os_detect = rospkg.os_detect.OsDetect()
            os_name, os_version, os_codename = os_detect.detect_os()
        else:
            os_name, os_codename = os_override
        tags = [t for t in (distro_name, os_name, os_codename) if t]
        return DataSourceMatcher(tags)
github fkie / multimaster_fkie / fkie_master_discovery / src / fkie_master_discovery / common.py View on Github external
def masteruri_from_ros():
    '''
    Returns the master URI depending on ROS distribution API.

    :return: ROS master URI
    :rtype: str
    :see: rosgraph.rosenv.get_master_uri() (fuerte)
    :see: roslib.rosenv.get_master_uri() (prior)
    '''
    try:
        import rospkg.distro
        distro = rospkg.distro.current_distro_codename()
        if distro in ['electric', 'diamondback', 'cturtle']:
            return roslib.rosenv.get_master_uri()
        else:
            import rosgraph
            return rosgraph.rosenv.get_master_uri()
    except Exception:
        return os.environ['ROS_MASTER_URI']
github fkie / multimaster_fkie / default_cfg_fkie / src / default_cfg_fkie / default_cfg.py View on Github external
def _masteruri_from_ros(self):
        '''
        Returns the master URI depending on ROS distribution API.
        @return: ROS master URI
        @rtype: C{str}
        '''
        try:
            import rospkg.distro
            distro = rospkg.distro.current_distro_codename()
            if distro in ['electric', 'diamondback', 'cturtle']:
                return roslib.rosenv.get_master_uri()
            else:
                return rosgraph.rosenv.get_master_uri()
        except:
            return roslib.rosenv.get_master_uri()
github fkie / multimaster_fkie / fkie_node_manager / src / fkie_node_manager / common.py View on Github external
def get_ros_home():
    '''
    Returns the ROS HOME depending on ROS distribution API.

    :return: ROS HOME path
    :rtype: str
    '''
    try:
        import rospkg.distro
        distro = rospkg.distro.current_distro_codename()
        if distro in ['electric', 'diamondback', 'cturtle']:
            import roslib.rosenv
            return roslib.rosenv.get_ros_home()
        else:
            from rospkg import get_ros_home
            return get_ros_home()
    except Exception:
        from roslib import rosenv
        return rosenv.get_ros_home()
github fkie / multimaster_fkie / fkie_node_manager / scripts / reduced_nm.py View on Github external
def get_ros_home():
    '''
    Returns the ROS HOME depending on ROS distribution API.

    :return: ROS HOME path
    :rtype: str
    '''
    try:
        import rospkg.distro
        distro = rospkg.distro.current_distro_codename()
        if distro in ['electric', 'diamondback', 'cturtle']:
            import roslib.rosenv
            return roslib.rosenv.get_ros_home()
        else:
            from rospkg import get_ros_home
            return get_ros_home()
    except Exception:
        from roslib import rosenv
        return rosenv.get_ros_home()
github ros-infrastructure / rosdep / src / rosdep2 / main.py View on Github external
try:
            uninstalled, errors = lookup.resolve_all(packages, installer_context, implicit=options.recursive)
        except InvalidData as e:
            print('ERROR: unable to process all dependencies:\n\t%s' % (e), file=sys.stderr)
            return 1
    else:
        uninstalled, errors = installer.get_uninstalled(packages, implicit=options.recursive, verbose=options.verbose)

    if options.verbose:
        uninstalled_dependencies = normalize_uninstalled_to_list(uninstalled)
        print('uninstalled dependencies are: [%s]' % ', '.join(uninstalled_dependencies))

    if errors:
        err_msg = ('ERROR: the following packages/stacks could not have their '
                   'rosdep keys resolved\nto system dependencies')
        if rospkg.distro.current_distro_codename() is None:
            err_msg += (
                ' (ROS distro is not set. '
                'Make sure `ROS_DISTRO` environment variable is set, or use '
                '`--rosdistro` option to specify the distro, '
                'e.g. `--rosdistro indigo`)'
            )
        print(err_msg + ':', file=sys.stderr)
        for rosdep_key, error in errors.items():
            print('%s: %s' % (rosdep_key, error_to_human_readable(error)), file=sys.stderr)
        if options.robust:
            print('Continuing to install resolvable dependencies...')
        else:
            return 1
    try:
        installer.install(uninstalled, **install_options)
        if not options.simulate: