diff --git a/nav2_bringup/bringup/launch/nav2_bringup_launch.py b/nav2_bringup/bringup/launch/nav2_bringup_launch.py index 8f68d521abfc11f726ec5af1ec3cd20b2daa713d..7b79d334a7f5826c61c00f4a3436e51795a8e11e 100644 --- a/nav2_bringup/bringup/launch/nav2_bringup_launch.py +++ b/nav2_bringup/bringup/launch/nav2_bringup_launch.py @@ -22,9 +22,9 @@ from launch.actions import (DeclareLaunchArgument, GroupAction, from launch.conditions import IfCondition from launch.launch_description_sources import PythonLaunchDescriptionSource from launch.substitutions import LaunchConfiguration +from launch_ros.actions import Node from launch_ros.actions import PushRosNamespace -from nav2_common.launch import Node def generate_launch_description(): @@ -40,7 +40,6 @@ def generate_launch_description(): params_file = LaunchConfiguration('params_file') bt_xml_file = LaunchConfiguration('bt_xml_file') autostart = LaunchConfiguration('autostart') - use_remappings = LaunchConfiguration('use_remappings') stdout_linebuf_envvar = SetEnvironmentVariable( 'RCUTILS_CONSOLE_STDOUT_LINE_BUFFERED', '1') @@ -81,10 +80,6 @@ def generate_launch_description(): 'autostart', default_value='true', description='Automatically startup the nav2 stack') - declare_use_remappings_cmd = DeclareLaunchArgument( - 'use_remappings', default_value='false', - description='Arguments to pass to all nodes launched by the file') - # Specify the actions bringup_cmd_group = GroupAction([ PushRosNamespace( @@ -98,8 +93,7 @@ def generate_launch_description(): 'use_sim_time': use_sim_time, 'autostart': autostart, 'params_file': params_file, - 'use_lifecycle_mgr': 'false', - 'use_remappings': use_remappings}.items()), + 'use_lifecycle_mgr': 'false'}.items()), IncludeLaunchDescription( PythonLaunchDescriptionSource(os.path.join(launch_dir, 'nav2_navigation_launch.py')), @@ -109,7 +103,6 @@ def generate_launch_description(): 'params_file': params_file, 'bt_xml_file': bt_xml_file, 'use_lifecycle_mgr': 'false', - 'use_remappings': use_remappings, 'map_subscribe_transient_local': 'true'}.items()), Node( @@ -142,7 +135,6 @@ def generate_launch_description(): ld.add_action(declare_params_file_cmd) ld.add_action(declare_autostart_cmd) ld.add_action(declare_bt_xml_cmd) - ld.add_action(declare_use_remappings_cmd) # Add the actions to launch all of the navigation nodes ld.add_action(bringup_cmd_group) diff --git a/nav2_bringup/bringup/launch/nav2_localization_launch.py b/nav2_bringup/bringup/launch/nav2_localization_launch.py index a0a17d076ef48ee7f1d180210aaab283314d71e0..ce25ca8c7dd5b75d7e2c7fb1bff2dbffab80485c 100644 --- a/nav2_bringup/bringup/launch/nav2_localization_launch.py +++ b/nav2_bringup/bringup/launch/nav2_localization_launch.py @@ -20,8 +20,7 @@ from launch import LaunchDescription from launch.actions import DeclareLaunchArgument, SetEnvironmentVariable from launch.conditions import IfCondition from launch.substitutions import LaunchConfiguration - -from nav2_common.launch import Node +from launch_ros.actions import Node from nav2_common.launch import RewrittenYaml @@ -35,7 +34,6 @@ def generate_launch_description(): autostart = LaunchConfiguration('autostart') params_file = LaunchConfiguration('params_file') use_lifecycle_mgr = LaunchConfiguration('use_lifecycle_mgr') - use_remappings = LaunchConfiguration('use_remappings') # Map fully qualified names to relative ones so the node's namespace can be prepended. # In case of the transforms (tf), currently, there doesn't seem to be a better alternative @@ -43,9 +41,7 @@ def generate_launch_description(): # https://github.com/ros/robot_state_publisher/pull/30 # TODO(orduno) Substitute with `PushNodeRemapping` # https://github.com/ros2/launch_ros/issues/56 - remappings = [((namespace, '/tf'), '/tf'), - ((namespace, '/tf_static'), '/tf_static'), - ('/tf', 'tf'), + remappings = [('/tf', 'tf'), ('/tf_static', 'tf_static')] # Create our own temporary YAML files that include substitutions @@ -89,17 +85,12 @@ def generate_launch_description(): 'use_lifecycle_mgr', default_value='true', description='Whether to launch the lifecycle manager'), - DeclareLaunchArgument( - 'use_remappings', default_value='false', - description='Arguments to pass to all nodes launched by the file'), - Node( package='nav2_map_server', node_executable='map_server', node_name='map_server', output='screen', parameters=[configured_params], - use_remappings=IfCondition(use_remappings), remappings=remappings), Node( @@ -108,7 +99,6 @@ def generate_launch_description(): node_name='amcl', output='screen', parameters=[configured_params], - use_remappings=IfCondition(use_remappings), remappings=remappings), Node( diff --git a/nav2_bringup/bringup/launch/nav2_multi_tb3_simulation_launch.py b/nav2_bringup/bringup/launch/nav2_multi_tb3_simulation_launch.py index eb1ce88317f89844e3e70b634e85eda408928cd9..a95b29e963e65187e8d227736663f7ca14b76ee6 100644 --- a/nav2_bringup/bringup/launch/nav2_multi_tb3_simulation_launch.py +++ b/nav2_bringup/bringup/launch/nav2_multi_tb3_simulation_launch.py @@ -154,7 +154,6 @@ def generate_launch_description(): 'params_file': params_file, 'bt_xml_file': bt_xml_file, 'autostart': autostart, - 'use_remappings': 'True', 'use_rviz': 'False', 'use_simulator': 'False', 'headless': 'False', diff --git a/nav2_bringup/bringup/launch/nav2_navigation_launch.py b/nav2_bringup/bringup/launch/nav2_navigation_launch.py index d1f689c22236ab76014130fcdc48480d276a092a..7adc0fdf96de09f57f0e309a9167d0579f6c0f29 100644 --- a/nav2_bringup/bringup/launch/nav2_navigation_launch.py +++ b/nav2_bringup/bringup/launch/nav2_navigation_launch.py @@ -20,8 +20,7 @@ from launch import LaunchDescription from launch.actions import DeclareLaunchArgument, SetEnvironmentVariable from launch.conditions import IfCondition from launch.substitutions import LaunchConfiguration - -from nav2_common.launch import Node +from launch_ros.actions import Node from nav2_common.launch import RewrittenYaml @@ -35,7 +34,6 @@ def generate_launch_description(): params_file = LaunchConfiguration('params_file') bt_xml_file = LaunchConfiguration('bt_xml_file') use_lifecycle_mgr = LaunchConfiguration('use_lifecycle_mgr') - use_remappings = LaunchConfiguration('use_remappings') map_subscribe_transient_local = LaunchConfiguration('map_subscribe_transient_local') # Map fully qualified names to relative ones so the node's namespace can be prepended. @@ -44,9 +42,7 @@ def generate_launch_description(): # https://github.com/ros/robot_state_publisher/pull/30 # TODO(orduno) Substitute with `PushNodeRemapping` # https://github.com/ros2/launch_ros/issues/56 - remappings = [((namespace, '/tf'), '/tf'), - ((namespace, '/tf_static'), '/tf_static'), - ('/tf', 'tf'), + remappings = [('/tf', 'tf'), ('/tf_static', 'tf_static')] # Create our own temporary YAML files that include substitutions @@ -94,10 +90,6 @@ def generate_launch_description(): 'use_lifecycle_mgr', default_value='true', description='Whether to launch the lifecycle manager'), - DeclareLaunchArgument( - 'use_remappings', default_value='false', - description='Arguments to pass to all nodes launched by the file'), - DeclareLaunchArgument( 'map_subscribe_transient_local', default_value='false', description='Whether to set the map subscriber QoS to transient local'), @@ -107,7 +99,6 @@ def generate_launch_description(): node_executable='controller_server', output='screen', parameters=[configured_params], - use_remappings=IfCondition(use_remappings), remappings=remappings), Node( @@ -116,7 +107,6 @@ def generate_launch_description(): node_name='planner_server', output='screen', parameters=[configured_params], - use_remappings=IfCondition(use_remappings), remappings=remappings), Node( @@ -125,7 +115,6 @@ def generate_launch_description(): node_name='recoveries_server', output='screen', parameters=[{'use_sim_time': use_sim_time}], - use_remappings=IfCondition(use_remappings), remappings=remappings), Node( @@ -134,7 +123,6 @@ def generate_launch_description(): node_name='bt_navigator', output='screen', parameters=[configured_params], - use_remappings=IfCondition(use_remappings), remappings=remappings), Node( @@ -143,7 +131,6 @@ def generate_launch_description(): node_name='waypoint_follower', output='screen', parameters=[configured_params], - use_remappings=IfCondition(use_remappings), remappings=remappings), Node( diff --git a/nav2_bringup/bringup/launch/nav2_rviz_launch.py b/nav2_bringup/bringup/launch/nav2_rviz_launch.py index fcae590a75a3060a1a881fee081331e437dfb7d7..67ab0c3ff2dc6afe0c4b7537219aad9a6ffc2b41 100644 --- a/nav2_bringup/bringup/launch/nav2_rviz_launch.py +++ b/nav2_bringup/bringup/launch/nav2_rviz_launch.py @@ -22,8 +22,8 @@ from launch.conditions import IfCondition, UnlessCondition from launch.event_handlers import OnProcessExit from launch.events import Shutdown from launch.substitutions import LaunchConfiguration - -from nav2_common.launch import Node, ReplaceString +from launch_ros.actions import Node +from nav2_common.launch import ReplaceString def generate_launch_description(): @@ -73,7 +73,6 @@ def generate_launch_description(): node_namespace=namespace, arguments=['-d', namespaced_rviz_config_file], output='screen', - use_remappings=IfCondition('True'), remappings=[('/tf', 'tf'), ('/tf_static', 'tf_static'), ('/goal_pose', 'goal_pose'), diff --git a/nav2_bringup/bringup/launch/nav2_tb3_simulation_launch.py b/nav2_bringup/bringup/launch/nav2_tb3_simulation_launch.py index 08bf91da0251ff2404a2e464846d9ba5670572ac..b1206fc7b83116e6a64078116ffcfcb00dbe9bfc 100644 --- a/nav2_bringup/bringup/launch/nav2_tb3_simulation_launch.py +++ b/nav2_bringup/bringup/launch/nav2_tb3_simulation_launch.py @@ -23,8 +23,7 @@ from launch.actions import DeclareLaunchArgument, ExecuteProcess, IncludeLaunchD from launch.conditions import IfCondition from launch.launch_description_sources import PythonLaunchDescriptionSource from launch.substitutions import LaunchConfiguration, PythonExpression - -from nav2_common.launch import Node +from launch_ros.actions import Node def generate_launch_description(): @@ -40,7 +39,6 @@ def generate_launch_description(): params_file = LaunchConfiguration('params_file') bt_xml_file = LaunchConfiguration('bt_xml_file') autostart = LaunchConfiguration('autostart') - use_remappings = LaunchConfiguration('use_remappings') # Launch configuration variables specific to simulation rviz_config_file = LaunchConfiguration('rviz_config_file') @@ -56,9 +54,7 @@ def generate_launch_description(): # https://github.com/ros/robot_state_publisher/pull/30 # TODO(orduno) Substitute with `PushNodeRemapping` # https://github.com/ros2/launch_ros/issues/56 - remappings = [((namespace, '/tf'), '/tf'), - ((namespace, '/tf_static'), '/tf_static'), - ('/tf', 'tf'), + remappings = [('/tf', 'tf'), ('/tf_static', 'tf_static')] # Declare the launch arguments @@ -98,10 +94,6 @@ def generate_launch_description(): 'autostart', default_value='false', description='Automatically startup the nav2 stack') - declare_use_remappings_cmd = DeclareLaunchArgument( - 'use_remappings', default_value='false', - description='Arguments to pass to all nodes launched by the file') - declare_rviz_config_file_cmd = DeclareLaunchArgument( 'rviz_config_file', default_value=os.path.join(bringup_dir, 'rviz', 'nav2_default_view.rviz'), @@ -157,7 +149,6 @@ def generate_launch_description(): node_namespace=namespace, output='screen', parameters=[{'use_sim_time': use_sim_time}], - use_remappings=IfCondition(use_remappings), remappings=remappings, arguments=[urdf]) @@ -189,7 +180,6 @@ def generate_launch_description(): ld.add_action(declare_params_file_cmd) ld.add_action(declare_bt_xml_cmd) ld.add_action(declare_autostart_cmd) - ld.add_action(declare_use_remappings_cmd) ld.add_action(declare_rviz_config_file_cmd) ld.add_action(declare_use_simulator_cmd) diff --git a/nav2_common/nav2_common/launch/__init__.py b/nav2_common/nav2_common/launch/__init__.py index 82764712d088abc82d282abfb6b4af42a2a626d8..1f0638f81a02babb117be0d3ec58e19c50980d2f 100644 --- a/nav2_common/nav2_common/launch/__init__.py +++ b/nav2_common/nav2_common/launch/__init__.py @@ -14,4 +14,3 @@ from .rewritten_yaml import RewrittenYaml from .replace_string import ReplaceString -from .node import Node diff --git a/nav2_common/nav2_common/launch/node.py b/nav2_common/nav2_common/launch/node.py deleted file mode 100644 index 2d16776f2778ccb4e534973da21059258e0b25d8..0000000000000000000000000000000000000000 --- a/nav2_common/nav2_common/launch/node.py +++ /dev/null @@ -1,97 +0,0 @@ -# Copyright 2018 Open Source Robotics Foundation, Inc. -# Copyright (c) 2019 Intel Corporation -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Module for the Node action.""" - -from typing import List -from typing import Optional - -from launch import Condition -from launch.action import Action -from launch.launch_context import LaunchContext - -import launch_ros - -class Node(launch_ros.actions.Node): - def __init__( - self, *, - use_remappings: Optional[Condition] = None, - **kwargs - ) -> None: - """ - Construct an Node action. - - Many arguments are passed eventually to - :class:`launch.actions.ExecuteProcess`, so see the documentation of - that class for additional details. - However, the `cmd` is not meant to be used, instead use the - `node_executable` and `arguments` keyword arguments to this function. - - This action, once executed, delegates most work to the - :class:`launch.actions.ExecuteProcess`, but it also converts some ROS - specific arguments into generic command line arguments. - - The launch_ros.substitutions.ExecutableInPackage substitution is used - to find the executable at runtime, so this Action also raise the - exceptions that substituion can raise when the package or executable - are not found. - - If the node_name is not given (or is None) then no name is passed to - the node on creation and instead the default name specified within the - code of the node is used instead. - - The node_namespace can either be absolute (i.e. starts with /) or - relative. - If absolute, then nothing else is considered and this is passed - directly to the node to set the namespace. - If relative, the namespace in the 'ros_namespace' LaunchConfiguration - will be prepended to the given relative node namespace. - If no node_namespace is given, then the default namespace `/` is - assumed. - - The parameters are passed as a list, with each element either a yaml - file that contains parameter rules (string or pathlib.Path to the full - path of the file), or a dictionary that specifies parameter rules. - Keys of the dictionary can be strings or an iterable of Substitutions - that will be expanded to a string. - Values in the dictionary can be strings, integers, floats, or tuples - of Substitutions that will be expanded to a string. - Additionally, values in the dictionary can be lists of the - aforementioned types, or another dictionary with the same properties. - A yaml file with the resulting parameters from the dictionary will be - written to a temporary file, the path to which will be passed to the - node. - Multiple dictionaries/files can be passed: each file path will be - passed in in order to the node (where the last definition of a - parameter takes effect). - - :param: package the package in which the node executable can be found - :param: node_executable the name of the executable to find - :param: node_name the name of the node - :param: node_namespace the ros namespace for this Node - :param: parameters list of names of yaml files with parameter rules, - or dictionaries of parameters. - :param: use_remappings whether to apply the remappings at runtime. - :param: remappings ordered list of 'to' and 'from' string pairs to be - passed to the node as ROS remapping rules - :param: arguments list of extra arguments for the node - """ - super().__init__(**kwargs) - self.__use_remappings = use_remappings - - def execute(self, context: LaunchContext) -> Optional[List[Action]]: - if self.__use_remappings is not None and not self.__use_remappings.evaluate(context): - self.__expanded_remappings = None - return super().execute(context)