Beispiel #1
0
 def parse(cls, entity: Entity, parser: Parser):
     """Parse node."""
     # See parse method of `ExecuteProcess`
     _, kwargs = super().parse(entity, parser, 'args')
     kwargs['arguments'] = kwargs['args']
     del kwargs['args']
     kwargs['node_name'] = kwargs['name']
     del kwargs['name']
     kwargs['package'] = parser.parse_substitution(entity.get_attr('pkg'))
     kwargs['node_executable'] = parser.parse_substitution(
         entity.get_attr('exec'))
     ns = entity.get_attr('namespace', optional=True)
     if ns is not None:
         kwargs['node_namespace'] = parser.parse_substitution(ns)
     remappings = entity.get_attr('remap', optional=True)
     if remappings is not None:
         kwargs['remappings'] = [
             (parser.parse_substitution(remap.get_attr('from')),
              parser.parse_substitution(remap.get_attr('to')))
             for remap in remappings
         ]
     parameters = entity.get_attr('param',
                                  data_type=List[Entity],
                                  optional=True)
     if parameters is not None:
         kwargs['parameters'] = cls.parse_nested_parameters(
             parameters, parser)
     return cls, kwargs
Beispiel #2
0
    def parse(cls, entity: Entity, parser: Parser):
        """Parse load_composable_node."""
        _, kwargs = super().parse(entity, parser)

        kwargs['target_container'] = parser.parse_substitution(
            entity.get_attr('target', data_type=str))

        composable_nodes = entity.get_attr('composable_node', data_type=List[Entity])
        kwargs['composable_node_descriptions'] = []
        for entity in composable_nodes:
            composable_node_cls, composable_node_kwargs = ComposableNode.parse(parser, entity)
            kwargs['composable_node_descriptions'].append(
                composable_node_cls(**composable_node_kwargs))

        return cls, kwargs
    def parse(cls, entity: Entity, parser: Parser):
        """Parse."""
        _, kwargs = super().parse(entity, parser)

        kwargs['session_name'] = entity.get_attr('session-name')
        append_timestamp = entity.get_attr('append-timestamp',
                                           data_type=bool,
                                           optional=True,
                                           can_be_str=False)
        if append_timestamp is not None:
            kwargs['append_timestamp'] = append_timestamp
        base_path = entity.get_attr('base-path', optional=True)
        if base_path:
            kwargs['base_path'] = parser.parse_substitution(base_path)
        # Make sure to handle empty strings and replace with empty lists,
        # otherwise an empty string enables all events
        events_ust = entity.get_attr('events-ust', optional=True)
        if events_ust is not None:
            kwargs['events_ust'] = cls._parse_cmdline(events_ust, parser) \
                if events_ust else []
        events_kernel = entity.get_attr('events-kernel', optional=True)
        if events_kernel is not None:
            kwargs['events_kernel'] = cls._parse_cmdline(events_kernel, parser) \
                if events_kernel else []
        context_fields = entity.get_attr('context-fields', optional=True)
        if context_fields is not None:
            kwargs['context_fields'] = cls._parse_cmdline(context_fields, parser) \
                if context_fields else []
        context_names = entity.get_attr('context-names', optional=True)
        if context_names is not None:
            kwargs['context_names'] = cls._parse_cmdline(context_names, parser) \
                if context_names else []

        return cls, kwargs
Beispiel #4
0
    def parse(cls, entity: Entity, parser: Parser):
        """Parse node."""
        # See parse method of `ExecuteProcess`
        _, kwargs = super().parse(entity, parser, ignore=['cmd'])
        args = entity.get_attr('args', optional=True)
        if args is not None:
            kwargs['arguments'] = super()._parse_cmdline(args, parser)
        ros_args = entity.get_attr('ros_args', optional=True)
        if ros_args is not None:
            kwargs['ros_arguments'] = super()._parse_cmdline(ros_args, parser)
        node_name = entity.get_attr('node-name', optional=True)
        if node_name is not None:
            kwargs['node_name'] = parser.parse_substitution(node_name)
        node_name = entity.get_attr('name', optional=True)
        if node_name is not None:
            kwargs['name'] = parser.parse_substitution(node_name)
        exec_name = entity.get_attr('exec_name', optional=True)
        if exec_name is not None:
            kwargs['exec_name'] = parser.parse_substitution(exec_name)
        package = entity.get_attr('pkg', optional=True)
        if package is not None:
            kwargs['package'] = parser.parse_substitution(package)
        kwargs['executable'] = parser.parse_substitution(entity.get_attr('exec'))
        ns = entity.get_attr('namespace', optional=True)
        if ns is not None:
            kwargs['namespace'] = parser.parse_substitution(ns)
        remappings = entity.get_attr('remap', data_type=List[Entity], optional=True)
        if remappings is not None:
            kwargs['remappings'] = [
                (
                    parser.parse_substitution(remap.get_attr('from')),
                    parser.parse_substitution(remap.get_attr('to'))
                ) for remap in remappings
            ]
            for remap in remappings:
                remap.assert_entity_completely_parsed()
        parameters = entity.get_attr('param', data_type=List[Entity], optional=True)
        if parameters is not None:
            kwargs['parameters'] = cls.parse_nested_parameters(parameters, parser)

        return cls, kwargs
Beispiel #5
0
 def parse(
     cls,
     entity: Entity,
     parser: Parser,
 ):
     """Return the `RosTimer` action and kwargs for constructing it."""
     _, kwargs = super().parse(entity, parser)
     kwargs['period'] = parser.parse_if_substitutions(
         entity.get_attr('period', data_type=float, can_be_str=True))
     kwargs['actions'] = [
         parser.parse_action(child) for child in entity.children
     ]
     return cls, kwargs
Beispiel #6
0
    def parse(cls, parser: Parser, entity: Entity):
        """Parse composable_node."""
        from launch_ros.actions import Node
        kwargs = {}

        kwargs['package'] = parser.parse_substitution(entity.get_attr('pkg'))
        kwargs['plugin'] = parser.parse_substitution(entity.get_attr('plugin'))
        kwargs['name'] = parser.parse_substitution(entity.get_attr('name'))

        namespace = entity.get_attr('namespace', optional=True)
        if namespace is not None:
            kwargs['namespace'] = parser.parse_substitution(namespace)

        parameters = entity.get_attr('param', data_type=List[Entity], optional=True)
        if parameters is not None:
            kwargs['parameters'] = Node.parse_nested_parameters(parameters, parser)

        remappings = entity.get_attr('remap', data_type=List[Entity], optional=True)
        if remappings is not None:
            kwargs['remappings'] = [
                (
                    parser.parse_substitution(remap.get_attr('from')),
                    parser.parse_substitution(remap.get_attr('to'))
                ) for remap in remappings
            ]

            for remap in remappings:
                remap.assert_entity_completely_parsed()

        extra_arguments = entity.get_attr('extra_arg', data_type=List[Entity], optional=True)
        if extra_arguments is not None:
            kwargs['extra_arguments'] = [
                {
                    tuple(parser.parse_substitution(extra_arg.get_attr('name'))):
                    parser.parse_substitution(extra_arg.get_attr('value'))
                } for extra_arg in extra_arguments
            ]

            for extra_arg in extra_arguments:
                extra_arg.assert_entity_completely_parsed()

        entity.assert_entity_completely_parsed()

        return cls, kwargs
Beispiel #7
0
    def parse(cls, entity: Entity, parser: Parser):
        """Parse node_container."""
        _, kwargs = super().parse(entity, parser)

        composable_nodes = entity.get_attr('composable_node',
                                           data_type=List[Entity],
                                           optional=True)
        if composable_nodes is not None:
            kwargs['composable_node_descriptions'] = []
            for entity in composable_nodes:
                composable_node_cls, composable_node_kwargs = ComposableNode.parse(
                    parser, entity)
                kwargs['composable_node_descriptions'].append(
                    composable_node_cls(**composable_node_kwargs))

        return cls, kwargs
 def parse(cls, entity: Entity, parser: Parser):
     """Return `SetLaunchConfiguration` action and kwargs for constructing it."""
     _, kwargs = super().parse(entity, parser)
     kwargs['namespace'] = parser.parse_substitution(entity.get_attr('namespace'))
     return cls, kwargs
 def parse(cls, entity: Entity, parser: Parser):
     """Return `SetParameterFromFile` action and kwargs for constructing it."""
     _, kwargs = super().parse(entity, parser)
     kwargs['filename'] = parser.parse_substitution(
         entity.get_attr('filename'))
     return cls, kwargs
Beispiel #10
0
 def parse(cls, entity: Entity, parser: Parser):
     """Return `SetUseSimTime` action and kwargs for constructing it."""
     _, kwargs = super().parse(entity, parser)
     kwargs['value'] = parser.parse_substitution(entity.get_attr('value'))
     return cls, kwargs
Beispiel #11
0
 def parse(cls, entity: Entity, parser: Parser):
     """Return `SetVehicleInfo` action and kwargs for constructing it."""
     _, kwargs = super().parse(entity, parser)
     kwargs['param_file'] = parser.parse_substitution(
         entity.get_attr('param_file'))
     return cls, kwargs
Beispiel #12
0
 def parse(cls, entity: Entity, parser: Parser):
     """Return `SetRemap` action and kwargs for constructing it."""
     _, kwargs = super().parse(entity, parser)
     kwargs['src'] = parser.parse_substitution(entity.get_attr('from'))
     kwargs['dst'] = parser.parse_substitution(entity.get_attr('to'))
     return cls, kwargs