Exemplo n.º 1
0
    def execute(self, context: LaunchContext) -> Optional[List[Action]]:
        """
        Execute the action.

        Delegated to :meth:`launch.actions.ExecuteProcess.execute`.
        """
        self._perform_substitutions(context)
        # Prepare the ros_specific_arguments list and add it to the context so that the
        # LocalSubstitution placeholders added to the the cmd can be expanded using the contents.
        ros_specific_arguments: Dict[str, Union[str, List[str]]] = {}
        if self.__node_name is not None:
            ros_specific_arguments['name'] = '__node:={}'.format(self.__expanded_node_name)
        if self.__expanded_node_namespace != '':
            ros_specific_arguments['ns'] = '__ns:={}'.format(self.__expanded_node_namespace)
        context.extend_locals({'ros_specific_arguments': ros_specific_arguments})
        ret = super().execute(context)

        if self.is_node_name_fully_specified():
            add_node_name(context, self.node_name)
            node_name_count = get_node_name_count(context, self.node_name)
            if node_name_count > 1:
                execute_process_logger = launch.logging.get_logger(self.name)
                execute_process_logger.warning(
                    'there are now at least {} nodes with the name {} created within this '
                    'launch context'.format(node_name_count, self.node_name)
                )

        return ret
Exemplo n.º 2
0
    def execute(self, context: LaunchContext) -> Optional[List[Action]]:
        """
        Execute the action.

        Delegated to :meth:`launch.actions.ExecuteProcess.execute`.
        """
        self._perform_substitutions(context)
        # Prepare the ros_specific_arguments list and add it to the context so that the
        # LocalSubstitution placeholders added to the the cmd can be expanded using the contents.
        ros_specific_arguments: Dict[str, Union[str, List[str]]] = {}
        if self.__node_name is not None:
            ros_specific_arguments['name'] = '__node:={}'.format(
                self.__expanded_node_name)
        if self.__expanded_node_namespace != '':
            ros_specific_arguments['ns'] = '__ns:={}'.format(
                self.__expanded_node_namespace)
        if self.__expanded_parameter_files is not None:
            ros_specific_arguments['params'] = []
            param_arguments = cast(List[str], ros_specific_arguments['params'])
            for param_file_path in self.__expanded_parameter_files:
                param_arguments.append('__params:={}'.format(param_file_path))
        if self.__expanded_remappings is not None:
            ros_specific_arguments['remaps'] = []
            for remapping_from, remapping_to in self.__expanded_remappings:
                remap_arguments = cast(List[str],
                                       ros_specific_arguments['remaps'])
                remap_arguments.append('{}:={}'.format(remapping_from,
                                                       remapping_to))
        context.extend_locals(
            {'ros_specific_arguments': ros_specific_arguments})
        return super().execute(context)
Exemplo n.º 3
0
Arquivo: node.py Projeto: hfz-Nick/ROS
    def execute(self, context: LaunchContext) -> Optional[List[Action]]:
        """
        Execute the action.

        Delegated to :meth:`launch.actions.ExecuteProcess.execute`.
        """
        self._perform_substitutions(context)
        # Prepare the ros_specific_arguments list and add it to the context so that the
        # LocalSubstitution placeholders added to the the cmd can be expanded using the contents.
        ros_specific_arguments = []  # type: List[Text]
        if self.__node_name is not None:
            ros_specific_arguments.append('__node:={}'.format(
                self.__expanded_node_name))
        if self.__node_namespace is not None:
            ros_specific_arguments.append('__ns:={}'.format(
                self.__expanded_node_namespace))
        if self.__expanded_remappings is not None:
            for remapping_from, remapping_to in self.__remappings:
                ros_specific_arguments.append('{}:={}'.format(
                    remapping_from, remapping_to))
        context.extend_locals(
            {'ros_specific_arguments': ros_specific_arguments})
        return super().execute(context)