コード例 #1
0
ファイル: list.py プロジェクト: utiasASRL/rosbag2
    def main(self, *, args):  # noqa: D102
        # the following is the resource index which is created when installing a pluginlib xml file
        if args.plugin_type == 'storage':
            pluginlib_resource_index = 'rosbag2_storage__pluginlib__plugin'
        else:
            pluginlib_resource_index = 'rosbag2_cpp__pluginlib__plugin'

        resources = get_resources(pluginlib_resource_index)
        if args.verbose:
            print('available %s plugins are:' % args.plugin_type)
        for resource in resources:
            plugin_xml_file_paths, base_folder = get_resource(
                pluginlib_resource_index, resource)
            for file_path in list(
                    filter(None, plugin_xml_file_paths.split('\n'))):
                abs_path = os.path.join(base_folder, file_path)
                if not os.path.exists(abs_path):
                    return 'path does not exist: %s' % abs_path

                xmldoc = minidom.parse(abs_path)
                class_item = xmldoc.getElementsByTagName('class')[0]
                class_name = class_item.attributes['name']
                type_name = class_item.attributes['type']
                base_class_name = class_item.attributes['base_class_type']
                description = xmldoc.getElementsByTagName('description')[0]

                print('%s%s' %
                      (('name: ' if args.verbose else ''), class_name.value))
                if args.verbose:
                    print('\t%s' % description.childNodes[0].data)
                    print('\ttype: %s' % type_name.value)
                    print('\tbase_class: %s' % base_class_name.value)
コード例 #2
0
ファイル: __init__.py プロジェクト: haueck/ros1_bridge
def get_ros2_services():
    pkgs = []
    srvs = []
    rules = []
    resource_type = 'rosidl_interfaces'
    resources = ament_index_python.get_resources(resource_type)
    for package_name, prefix_path in resources.items():
        pkgs.append(package_name)
        resource, _ = ament_index_python.get_resource(resource_type,
                                                      package_name)
        interfaces = resource.splitlines()
        service_names = [i[:-4] for i in interfaces if i.endswith('.srv')]
        for service_name in service_names:
            srvs.append(Message(package_name, service_name, prefix_path))
        # check package manifest for mapping rules
        package_path = os.path.join(prefix_path, 'share', package_name)
        pkg = parse_package(package_path)
        for export in pkg.exports:
            if export.tagname != 'ros1_bridge':
                continue
            if 'mapping_rules' not in export.attributes:
                continue
            rule_file = os.path.join(package_path,
                                     export.attributes['mapping_rules'])
            with open(rule_file, 'r') as h:
                for data in yaml.load(h):
                    if all(n not in data for n in ('ros1_message_name',
                                                   'ros2_message_name')):
                        try:
                            rules.append(ServiceMappingRule(
                                data, package_name))
                        except Exception as e:
                            print('%s' % str(e), file=sys.stderr)
    return pkgs, srvs, rules
コード例 #3
0
 def __init__(self, name, *, typesupport_implementations=None):
     super().__init__(name)
     if typesupport_implementations is None:
         typesupport_implementations = ['rosidl_typesupport_c']
         typesupport_implementations.extend(
             get_resources('rosidl_typesupport_c'))
     self.__typesupport_implementations = typesupport_implementations
コード例 #4
0
ファイル: __init__.py プロジェクト: yechun1/ros2cli
def get_all_service_types():
    all_service_types = {}
    for package_name in get_resources('rosidl_interfaces'):
        service_types = get_service_types(package_name)
        if service_types:
            all_service_types[package_name] = service_types
    return all_service_types
コード例 #5
0
def get_all_action_types():
    all_action_types = {}
    for package_name in get_resources('rosidl_interfaces'):
        action_types = get_action_types(package_name)
        if action_types:
            all_action_types[package_name] = action_types
    return all_action_types
コード例 #6
0
ファイル: __init__.py プロジェクト: yechun1/ros2cli
def get_all_message_types():
    all_message_types = {}
    for package_name in get_resources('rosidl_interfaces'):
        message_types = get_message_types(package_name)
        if message_types:
            all_message_types[package_name] = message_types
    return all_message_types
コード例 #7
0
ファイル: __init__.py プロジェクト: haueck/ros1_bridge
def get_ros2_services():
    pkgs = []
    srvs = []
    rules = []
    resource_type = 'rosidl_interfaces'
    resources = ament_index_python.get_resources(resource_type)
    for package_name, prefix_path in resources.items():
        pkgs.append(package_name)
        resource, _ = ament_index_python.get_resource(resource_type, package_name)
        interfaces = resource.splitlines()
        service_names = [i[:-4] for i in interfaces if i.endswith('.srv')]
        for service_name in service_names:
            srvs.append(Message(package_name, service_name, prefix_path))
        # check package manifest for mapping rules
        package_path = os.path.join(prefix_path, 'share', package_name)
        pkg = parse_package(package_path)
        for export in pkg.exports:
            if export.tagname != 'ros1_bridge':
                continue
            if 'mapping_rules' not in export.attributes:
                continue
            rule_file = os.path.join(package_path, export.attributes['mapping_rules'])
            with open(rule_file, 'r') as h:
                for data in yaml.load(h):
                    if all(n not in data for n in ('ros1_message_name', 'ros2_message_name')):
                        try:
                            rules.append(ServiceMappingRule(data, package_name))
                        except Exception as e:
                            print('%s' % str(e), file=sys.stderr)
    return pkgs, srvs, rules
コード例 #8
0
def test_cli_extension_for_smoke(tmp_path, capsys):
    # NOTE(hidmic): pytest and empy do not play along,
    # the latter expects some proxy will stay in sys.stdout
    # and the former insists in overwriting it
    interface_files = [TEST_DIR + ':msg/Test.msg']

    with capsys.disabled():  # so do everything in one run
        # Passing target typesupport implementations explictly
        ts = 'cpp[typesupport_implementations:{}]'.format(
            list(get_resources('rosidl_typesupport_cpp'))
        )
        generate(
            package_name='rosidl_typesupport_cpp',
            interface_files=interface_files,
            typesupports=[ts],
            output_path=tmp_path / 'explicit_args'
        )

        # Using default typesupport implementations
        generate(
            package_name='rosidl_typesupport_cpp',
            interface_files=interface_files,
            typesupports=['cpp'],
            output_path=tmp_path / 'defaults'
        )
コード例 #9
0
    def generate(self, package_name, interface_files, include_paths,
                 output_path):
        generated_files = []

        package_share_path = \
            get_package_share_directory('rosidl_typesupport_c')

        templates_path = os.path.join(package_share_path, 'resource')

        # Normalize interface definition format to .idl
        idl_interface_files = []
        non_idl_interface_files = []
        for path in interface_files:
            if not path.endswith('.idl'):
                non_idl_interface_files.append(path)
            else:
                idl_interface_files.append(path)
        if non_idl_interface_files:
            idl_interface_files.extend(
                translate(
                    package_name=package_name,
                    interface_files=non_idl_interface_files,
                    include_paths=include_paths,
                    output_format='idl',
                    output_path=output_path / 'tmp',
                ))

        # Generate visibility control file
        visibility_control_file_template_path = \
            'rosidl_typesupport_c__visibility_control.h.in'
        visibility_control_file_template_path = \
            templates_path / visibility_control_file_template_path
        visibility_control_file_path = \
            'rosidl_typesupport_c__visibility_control.h'
        visibility_control_file_path = \
            output_path / 'msg' / visibility_control_file_path

        generate_visibility_control_file(
            package_name=package_name,
            template_path=visibility_control_file_template_path,
            output_path=visibility_control_file_path)
        generated_files.append(visibility_control_file_path)

        # Generate typesupport code
        typesupport_implementations = list(
            get_resources('rosidl_typesupport_c'))

        with legacy_generator_arguments_file(
                package_name=package_name,
                interface_files=idl_interface_files,
                include_paths=include_paths,
                templates_path=templates_path,
                output_path=output_path) as path_to_arguments_file:
            generated_files.extend(
                generate_c(path_to_arguments_file,
                           typesupport_implementations))

        return generated_files
コード例 #10
0
def get_all_rosidl_types():
    """
    Retrieve a dictionary mapping packages to their provided rosidl interfaces.

    :returns: a dictionary mapping packages to their types
    """
    all_rosidl_types = {}
    for package_name in get_resources('rosidl_interfaces').keys():
        all_rosidl_types[package_name] = get_rosidl_types(package_name)
    return all_rosidl_types
コード例 #11
0
def reload_rmw_implementations():
    """(Re)Load the available rmw implementations by inspecting the ament index."""
    global __rmw_implementations
    __rmw_implementations = sorted(ament_index_python.get_resources('rmw_implementation').keys())

    # Remove implementations that are being filtered for in the rclpy CMakeLists so
    # that they cannot be selected
    __rmw_implementations = [
        rmw_impl for rmw_impl in __rmw_implementations
        if rmw_impl not in ['rmw_connext_dynamic_cpp', 'rmw_fastrtps_cpp']]
    return __rmw_implementations
コード例 #12
0
ファイル: get_interfaces.py プロジェクト: Team488/WindowFrame
def _get_interfaces(package_names: Iterable[str] = []) -> Dict[str, List[str]]:
    interfaces = {}
    if len(package_names) == 0:
        package_names = get_resources('rosidl_interfaces')

    for package_name in package_names:
        if not has_resource('packages', package_name):
            raise LookupError(f"Unknown package '{package_name}'")
        try:
            content, _ = get_resource('rosidl_interfaces', package_name)
        except LookupError:
            continue
        interfaces[package_name] = content.splitlines()
    return interfaces
コード例 #13
0
    def main(self, *, args):  # noqa: D102
        # the following is the resource index which is created when installing a pluginlib xml file
        if args.plugin_type == 'storage':
            pluginlib_resource_index = 'rosbag2_storage__pluginlib__plugin'
        elif args.plugin_type == 'compressor' or args.plugin_type == 'decompressor':
            pluginlib_resource_index = 'rosbag2_compression__pluginlib__plugin'
        else:
            pluginlib_resource_index = 'rosbag2_cpp__pluginlib__plugin'

        resources = get_resources(pluginlib_resource_index)
        if args.verbose:
            print('available %s plugins are:' % args.plugin_type)
        for resource in resources:
            plugin_xml_file_paths, base_folder = get_resource(
                pluginlib_resource_index, resource)
            for file_path in list(
                    filter(None, plugin_xml_file_paths.split('\n'))):
                abs_path = os.path.join(base_folder, file_path)
                if not os.path.exists(abs_path):
                    return 'path does not exist: %s' % abs_path

                xmldoc = minidom.parse(abs_path)
                for class_item in xmldoc.getElementsByTagName('class'):
                    class_name = class_item.attributes['name']
                    type_name = class_item.attributes['type']
                    base_class_name = class_item.attributes['base_class_type']
                    description = class_item.getElementsByTagName(
                        'description')[0]

                    # Compression and decompression plugins share the same resource index
                    # so they must be filtered using their base class
                    if args.plugin_type == 'compressor' and \
                            base_class_name.value != \
                            'rosbag2_compression::BaseCompressorInterface':
                        continue
                    elif args.plugin_type == 'decompressor' and \
                            base_class_name.value != \
                            'rosbag2_compression::BaseDecompressorInterface':
                        continue

                    print(
                        '%s%s' %
                        (('name: ' if args.verbose else ''), class_name.value))
                    if args.verbose:
                        print('\t%s' % description.childNodes[0].data)
                        print('\ttype: %s' % type_name.value)
                        print('\tbase_class: %s' % base_class_name.value)
コード例 #14
0
def get_ros2_messages():
    pkgs = []
    msgs = []
    rules = []
    # get messages from packages
    resource_type = 'rosidl_interfaces'
    resources = ament_index_python.get_resources(resource_type)
    for package_name, prefix_path in resources.items():
        pkgs.append(package_name)
        resource, _ = ament_index_python.get_resource(resource_type,
                                                      package_name)
        interfaces = resource.splitlines()
        message_names = {
            i[4:-4]
            for i in interfaces
            if i.startswith('msg/') and i[-4:] in ('.idl', '.msg')
        }

        for message_name in sorted(message_names):
            msgs.append(Message(package_name, message_name, prefix_path))
        # check package manifest for mapping rules
        package_path = os.path.join(prefix_path, 'share', package_name)
        pkg = parse_package(package_path)
        for export in pkg.exports:
            if export.tagname != 'ros1_bridge':
                continue
            if 'mapping_rules' not in export.attributes:
                continue
            rule_file = os.path.join(package_path,
                                     export.attributes['mapping_rules'])
            with open(rule_file, 'r') as h:
                content = yaml.safe_load(h)
            if not isinstance(content, list):
                print(
                    "The content of the mapping rules in '%s' is not a list" %
                    rule_file,
                    file=sys.stderr)
                continue
            for data in content:
                if all(n not in data
                       for n in ('ros1_service_name', 'ros2_service_name')):
                    try:
                        rules.append(MessageMappingRule(data, package_name))
                    except Exception as e:  # noqa: B902
                        print('%s' % str(e), file=sys.stderr)
    return pkgs, msgs, rules
コード例 #15
0
ファイル: cli.py プロジェクト: ksuszka/rosidl_python
    def generate(
        self,
        package_name,
        interface_files,
        include_paths,
        output_path
    ):
        package_share_path = \
            pathlib.Path(get_package_share_directory('rosidl_generator_py'))
        templates_path = package_share_path / 'resource'

        # Normalize interface definition format to .idl
        idl_interface_files = []
        non_idl_interface_files = []
        for path in interface_files:
            if not path.endswith('.idl'):
                non_idl_interface_files.append(path)
            else:
                idl_interface_files.append(path)
        if non_idl_interface_files:
            idl_interface_files.extend(translate(
                package_name=package_name,
                interface_files=non_idl_interface_files,
                include_paths=include_paths,
                output_format='idl',
                output_path=output_path / 'tmp',
            ))

        # Generate code
        typesupport_implementations = ['rosidl_typesupport_c']
        typesupport_implementations.extend(
            get_resources('rosidl_typesupport_c')
        )
        with legacy_generator_arguments_file(
            package_name=package_name,
            interface_files=idl_interface_files,
            include_paths=include_paths,
            templates_path=templates_path,
            output_path=output_path
        ) as path_to_arguments_file:
            return generate_py(
                path_to_arguments_file,
                typesupport_implementations)
コード例 #16
0
ファイル: __main__.py プロジェクト: lijian8/rmf-web
def main():
    parser = argparse.ArgumentParser(
        "ros_tortoise",
        description=
        "Generates tortoise-orm mixins boilerplate from ros messages",
    )
    parser.add_argument(
        "-o",
        "--output",
        required=True,
        metavar="DIRECTORY",
        help="output directory",
    )
    parser.add_argument(
        "packages",
        nargs="+",
        help="packages to generate",
    )

    args = parser.parse_args()
    packages = [
        k for k in ament_index_python.get_resources("rosidl_interfaces")
        if k in args.packages
    ]
    os.makedirs(args.output, exist_ok=True)
    sha1 = hashlib.sha1()
    for pkg in packages:
        pkg_spec = PackageSpec(pkg, parse_package(pkg))
        mixins = gen_mixin(pkg_spec)
        sha1.update(mixins.encode())
        outfile = f"{args.output}/{pkg}_mixins.py"
        with open(outfile, "w") as f:
            f.write(mixins)
        print(outfile)

    rev = base64.b32encode(sha1.digest())
    with open(f"{args.output}/rev", "bw") as f:
        f.write(rev)

    init_file = f"{args.output}/__init__.py"
    with open(f"{args.output}/__init__.py", "w") as f:
        f.write("")
    print(init_file)
コード例 #17
0
def get_ros2_messages():
    msgs = []
    pkgs = []
    # get messages from packages
    resource_type = 'rosidl_interfaces'
    resources = ament_index_python.get_resources(resource_type)
    for package_name, prefix_path in resources.items():
        pkgs.append(package_name)
        resource, _ = ament_index_python.get_resource(resource_type,
                                                      package_name)
        interfaces = resource.splitlines()
        message_names = {
            i[4:-4]
            for i in interfaces
            if i.startswith('msg/') and i[-4:] in ('.idl', '.msg')
        }
        for message_name in sorted(message_names):
            msgs.append(Message(package_name, message_name, prefix_path))
    return pkgs, msgs
コード例 #18
0
ファイル: __init__.py プロジェクト: ros2/ros1_bridge
def get_ros2_messages():
    pkgs = []
    msgs = []
    rules = []
    # get messages from packages
    resource_type = 'rosidl_interfaces'
    resources = ament_index_python.get_resources(resource_type)
    for package_name, prefix_path in resources.items():
        pkgs.append(package_name)
        resource, _ = ament_index_python.get_resource(resource_type, package_name)
        interfaces = resource.splitlines()
        message_names = {
            i[4:-4]
            for i in interfaces
            if i.startswith('msg/') and i[-4:] in ('.idl', '.msg')}

        for message_name in sorted(message_names):
            msgs.append(Message(package_name, message_name, prefix_path))
        # check package manifest for mapping rules
        package_path = os.path.join(prefix_path, 'share', package_name)
        pkg = parse_package(package_path)
        for export in pkg.exports:
            if export.tagname != 'ros1_bridge':
                continue
            if 'mapping_rules' not in export.attributes:
                continue
            rule_file = os.path.join(package_path, export.attributes['mapping_rules'])
            with open(rule_file, 'r') as h:
                content = yaml.safe_load(h)
            if not isinstance(content, list):
                print(
                    "The content of the mapping rules in '%s' is not a list" % rule_file,
                    file=sys.stderr)
                continue
            for data in content:
                if all(n not in data for n in ('ros1_service_name', 'ros2_service_name')):
                    try:
                        rules.append(MessageMappingRule(data, package_name))
                    except Exception as e:
                        print('%s' % str(e), file=sys.stderr)
    return pkgs, msgs, rules
コード例 #19
0
    def iterate_packages(subdir):
        """
        Iterator for packages that contain the given subdir.

        This method is generalizing rosmsg.iterate_packages.

        @param subdir: eg. 'launch', 'msg', 'srv', 'action'
        @type subdir: str
        @raise ValueError:
        """
        if subdir is None or subdir == '':
            raise ValueError('Invalid package subdir = {}'.format(subdir))

        packages_map = get_resources('packages')
        for package_name, package_path in packages_map.items():
            package_path = os.path.join(package_path, 'share', package_name,
                                        subdir)
            RqtRoscommUtil._logger.debug('package:\t{} dir:\t{}'.format(
                package_name, package_path))
            if os.path.isdir(package_path):
                yield package_name, package_path
コード例 #20
0
ファイル: __init__.py プロジェクト: takiaine/ros1_bridge
def get_ros2_messages():
    msgs = []
    rules = []
    # get messages from packages
    resource_type = 'rosidl_interfaces'
    resources = ament_index_python.get_resources(resource_type)
    for package_name, prefix_path in resources.items():
        resource = ament_index_python.get_resource(resource_type, package_name)
        interfaces = resource.splitlines()
        message_names = [i[:-4] for i in interfaces if i.endswith('.msg')]
        for message_name in message_names:
            msgs.append(Message(package_name, message_name, prefix_path))
        # check package manifest for mapping rules
        package_path = os.path.join(prefix_path, 'share', package_name)
        pkg = parse_package(package_path)
        for export in pkg.exports:
            if export.tagname != 'ros1_bridge':
                continue
            if 'mapping_rules' not in export.attributes:
                continue
            rule_file = os.path.join(package_path, export.attributes['mapping_rules'])
            rules += read_mapping_rules(rule_file, package_name)
    return msgs, rules
コード例 #21
0
ファイル: __init__.py プロジェクト: takiaine/ros1_bridge
def get_ros2_messages():
    msgs = []
    rules = []
    # get messages from packages
    resource_type = 'rosidl_interfaces'
    resources = ament_index_python.get_resources(resource_type)
    for package_name, prefix_path in resources.items():
        resource = ament_index_python.get_resource(resource_type, package_name)
        interfaces = resource.splitlines()
        message_names = [i[:-4] for i in interfaces if i.endswith('.msg')]
        for message_name in message_names:
            msgs.append(Message(package_name, message_name, prefix_path))
        # check package manifest for mapping rules
        package_path = os.path.join(prefix_path, 'share', package_name)
        pkg = parse_package(package_path)
        for export in pkg.exports:
            if export.tagname != 'ros1_bridge':
                continue
            if 'mapping_rules' not in export.attributes:
                continue
            rule_file = os.path.join(package_path,
                                     export.attributes['mapping_rules'])
            rules += read_mapping_rules(rule_file, package_name)
    return msgs, rules
コード例 #22
0
def get_available_rmw_implementations():
    """
    Return the set of all available RMW implementations as registered in the ament index.

    The result can be overridden by setting an environment variable named
    ``RMW_IMPLEMENTATIONS``.
    The variable can contain RMW implementation names separated by the platform
    specific path separator.
    Including an unavailable RMW implementation results in a RuntimeError.
    """
    available_rmw_implementations = ament_index_python.get_resources(
        'rmw_typesupport')
    available_rmw_implementations = {
        name
        for name in available_rmw_implementations
        if name != 'rmw_implementation'
    }

    # filter by implementations in environment variable if provided
    rmw_implementations = os.environ.get('RMW_IMPLEMENTATIONS')
    if rmw_implementations:
        rmw_implementations = rmw_implementations.split(os.pathsep)
        missing_rmw_implementations = set(rmw_implementations) - \
            available_rmw_implementations
        if missing_rmw_implementations:
            raise RuntimeError(
                f'The RMW implementations {missing_rmw_implementations} '
                "specified in 'RMW_IMPLEMENTATIONS' are not available (" +
                ', '.join(sorted(available_rmw_implementations)) + ')')
        available_rmw_implementations = {
            name
            for name in available_rmw_implementations
            if name in rmw_implementations
        }

    return available_rmw_implementations
コード例 #23
0
def test_resources_overlay():
    set_ament_prefix_path(['prefix1', 'prefix2'])
    resources = get_resources('resource_type2')
    assert len(resources) == 2, 'Expected two resource'
    assert set(resources.keys()) == {'foo',
                                     'bar'}, 'Expected different resources'
コード例 #24
0
ファイル: __init__.py プロジェクト: InigoMonreal/rcc
def get_package_names_with_component_types():
    """Get the names of all packages that register component types in the ament index."""
    return list(get_resources(COMPONENTS_RESOURCE_TYPE).keys())
コード例 #25
0
def test_resources_overlay():
    set_ament_prefix_path(['prefix1', 'prefix2'])
    resources = get_resources('resource_type2')
    assert len(resources) == 2, 'Expected two resource'
    assert set(resources.keys()) == set(['foo', 'bar']), 'Expected different resources'
コード例 #26
0
def reload_rmw_implementations():
    """(Re)Load the available rmw implementations by inspecting the ament index."""
    global __rmw_implementations
    __rmw_implementations = sorted(ament_index_python.get_resources(AMENT_INDEX_NAME).keys())
    return __rmw_implementations
コード例 #27
0
def test_resources_underlay():
    set_ament_prefix_path(['prefix1', 'prefix2'])
    resources = get_resources('resource_type3')
    assert len(resources) == 1, 'Expected one resource'
    assert set(resources.keys()) == set(['bar']), 'Expected different resources'
コード例 #28
0
 def get_package_names_with_component_types(self):
     """Get the names of all packages that register component types in the ament index."""
     return list(get_resources(self.component_resource_type).keys())
コード例 #29
0
ファイル: __init__.py プロジェクト: jpace121/ros2cli
def get_all_interface_packages():
    return get_resources('rosidl_interfaces')
コード例 #30
0
def generate_cpp(generator_arguments_file):
    args = read_generator_arguments(generator_arguments_file)

    template_dir = args['template_dir']
    mapping_msgs = {
        os.path.join(template_dir, 'msg__type_support.cpp.em'):
        '%s__type_support.cpp',
    }
    mapping_srvs = {
        os.path.join(template_dir, 'srv__type_support.cpp.em'):
        '%s__type_support.cpp',
    }

    for template_file in mapping_msgs.keys():
        assert os.path.exists(
            template_file), 'Could not find template: ' + template_file

    for template_file in mapping_srvs.keys():
        assert os.path.exists(
            template_file), 'Could not find template: ' + template_file

    pkg_name = args['package_name']
    known_msg_types = extract_message_types(
        pkg_name, args['ros_interface_files'],
        args.get('ros_interface_dependencies', []))

    functions = {
        'get_header_filename_from_msg_name':
        convert_camel_case_to_lower_case_underscore,
    }
    latest_target_timestamp = get_newest_modification_time(
        args['target_dependencies'])
    type_supports = list(get_resources('rosidl_typesupport_cpp').keys())

    for ros_interface_file in args['ros_interface_files']:
        extension = os.path.splitext(ros_interface_file)[1]
        subfolder = os.path.basename(os.path.dirname(ros_interface_file))
        if extension == '.msg':
            spec = parse_message_file(pkg_name, ros_interface_file)
            validate_field_types(spec, known_msg_types)
            for template_file, generated_filename in mapping_msgs.items():
                generated_file = os.path.join(
                    args['output_dir'], subfolder, generated_filename %
                    convert_camel_case_to_lower_case_underscore(
                        spec.base_type.type))

                data = {
                    'spec': spec,
                    'subfolder': subfolder,
                    'type_supports': type_supports
                }
                data.update(functions)
                expand_template(template_file,
                                data,
                                generated_file,
                                minimum_timestamp=latest_target_timestamp)

        elif extension == '.srv':
            spec = parse_service_file(pkg_name, ros_interface_file)
            validate_field_types(spec, known_msg_types)
            for template_file, generated_filename in mapping_srvs.items():
                generated_file = os.path.join(
                    args['output_dir'], subfolder, generated_filename %
                    convert_camel_case_to_lower_case_underscore(spec.srv_name))

                data = {'spec': spec, 'type_supports': type_supports}
                data.update(functions)
                expand_template(template_file,
                                data,
                                generated_file,
                                minimum_timestamp=latest_target_timestamp)

    return 0
コード例 #31
0
def test_resources():
    set_ament_prefix_path(['prefix1'])
    resources = get_resources('resource_type1')
    assert len(resources) == 2, 'Expected two resources'
    assert set(resources.keys()) == set(['foo', 'bar']), 'Expected different resources'
コード例 #32
0
def get_available_rmw_implementations():
    """Return the set of all available RMW implementations as registered in the ament index."""
    rmw_implementations = ament_index_python.get_resources('rmw_typesupport')
    return {name for name in rmw_implementations if name != 'rmw_implementation'}
コード例 #33
0
def test_unknown_resources():
    set_ament_prefix_path(['prefix1'])
    resources = get_resources('unknown_resource_type')
    assert len(resources) == 0, 'Expected no resources'
コード例 #34
0
ファイル: get_interfaces.py プロジェクト: Team488/WindowFrame
def get_interface_packages() -> List[str]:
    """Get all packages that generate interfaces."""
    return get_resources('rosidl_interfaces')
コード例 #35
0
def test_resources_underlay():
    set_ament_prefix_path(['prefix1', 'prefix2'])
    resources = get_resources('resource_type3')
    assert len(resources) == 1, 'Expected one resource'
    assert set(resources.keys()) == {'bar'}, 'Expected different resources'
コード例 #36
0
def test_unknown_resources():
    set_ament_prefix_path(['prefix1'])
    resources = get_resources('unknown_resource_type')
    assert len(resources) == 0, 'Expected no resources'