Skip to content

Commit d66d229

Browse files
luca-della-vedovaalexanderjyuen
authored andcommitted
Simplify namespaced bringups and multirobot sim (ros-navigation#4715)
* WIP single robot namespacing working Signed-off-by: Luca Della Vedova <[email protected]> * Remove manual namespace substitution Signed-off-by: Luca Della Vedova <[email protected]> * Remove all multirobot specific configs Signed-off-by: Luca Della Vedova <[email protected]> * Refactor parsing function to common, add for rest of layers Signed-off-by: Luca Della Vedova <[email protected]> * Fix dwb_critics test Signed-off-by: Luca Della Vedova <[email protected]> * Add alternative API for costmap construction Signed-off-by: Luca Della Vedova <[email protected]> * Address review feedback Signed-off-by: Luca Della Vedova <[email protected]> * Remove remaining usage of `use_namespace` parameter Signed-off-by: Luca Della Vedova <[email protected]> * Always join with parent namespace Signed-off-by: Luca Della Vedova <[email protected]> * Use private parameter for parent namespace Signed-off-by: Luca Della Vedova <[email protected]> * Fix integration test Signed-off-by: Luca Della Vedova <[email protected]> * Revert "Use private parameter for parent namespace" This reverts commit 0c958dc. Signed-off-by: Luca Della Vedova <[email protected]> * Revert "Fix integration test" This reverts commit 137d577. Signed-off-by: Luca Della Vedova <[email protected]> * Remove global map_topic parameter Signed-off-by: Luca Della Vedova <[email protected]> * Simplify Costmap2DROS constructor Signed-off-by: Luca Della Vedova <[email protected]> --------- Signed-off-by: Luca Della Vedova <[email protected]> Signed-off-by: Luca Della Vedova <[email protected]> Signed-off-by: alexander <[email protected]>
1 parent e3109bb commit d66d229

File tree

49 files changed

+146
-1613
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+146
-1613
lines changed

nav2_bringup/launch/bringup_launch.py

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
from launch_ros.actions import Node
3030
from launch_ros.actions import PushROSNamespace
3131
from launch_ros.descriptions import ParameterFile
32-
from nav2_common.launch import ReplaceString, RewrittenYaml
32+
from nav2_common.launch import RewrittenYaml
3333

3434

3535
def generate_launch_description():
@@ -39,7 +39,6 @@ def generate_launch_description():
3939

4040
# Create the launch configuration variables
4141
namespace = LaunchConfiguration('namespace')
42-
use_namespace = LaunchConfiguration('use_namespace')
4342
slam = LaunchConfiguration('slam')
4443
map_yaml_file = LaunchConfiguration('map')
4544
use_sim_time = LaunchConfiguration('use_sim_time')
@@ -58,16 +57,6 @@ def generate_launch_description():
5857
# https://github.com/ros2/launch_ros/issues/56
5958
remappings = [('/tf', 'tf'), ('/tf_static', 'tf_static')]
6059

61-
# Only it applys when `use_namespace` is True.
62-
# '<robot_namespace>' keyword shall be replaced by 'namespace' launch argument
63-
# in config file 'nav2_multirobot_params.yaml' as a default & example.
64-
# User defined config file should contain '<robot_namespace>' keyword for the replacements.
65-
params_file = ReplaceString(
66-
source_file=params_file,
67-
replacements={'<robot_namespace>': ('/', namespace)},
68-
condition=IfCondition(use_namespace),
69-
)
70-
7160
configured_params = ParameterFile(
7261
RewrittenYaml(
7362
source_file=params_file,
@@ -86,12 +75,6 @@ def generate_launch_description():
8675
'namespace', default_value='', description='Top-level namespace'
8776
)
8877

89-
declare_use_namespace_cmd = DeclareLaunchArgument(
90-
'use_namespace',
91-
default_value='false',
92-
description='Whether to apply a namespace to the navigation stack',
93-
)
94-
9578
declare_slam_cmd = DeclareLaunchArgument(
9679
'slam', default_value='False', description='Whether run a SLAM'
9780
)
@@ -142,7 +125,7 @@ def generate_launch_description():
142125
# Specify the actions
143126
bringup_cmd_group = GroupAction(
144127
[
145-
PushROSNamespace(condition=IfCondition(use_namespace), namespace=namespace),
128+
PushROSNamespace(namespace),
146129
Node(
147130
condition=IfCondition(use_composition),
148131
name='nav2_container',
@@ -207,7 +190,6 @@ def generate_launch_description():
207190

208191
# Declare the launch options
209192
ld.add_action(declare_namespace_cmd)
210-
ld.add_action(declare_use_namespace_cmd)
211193
ld.add_action(declare_slam_cmd)
212194
ld.add_action(declare_map_yaml_cmd)
213195
ld.add_action(declare_use_sim_time_cmd)

nav2_bringup/launch/cloned_multi_tb3_simulation_launch.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def generate_launch_description():
8080
declare_params_file_cmd = DeclareLaunchArgument(
8181
'params_file',
8282
default_value=os.path.join(
83-
bringup_dir, 'params', 'nav2_multirobot_params_all.yaml'
83+
bringup_dir, 'params', 'nav2_params.yaml'
8484
),
8585
description='Full path to the ROS2 parameters file to use for all launched nodes',
8686
)
@@ -93,7 +93,7 @@ def generate_launch_description():
9393

9494
declare_rviz_config_file_cmd = DeclareLaunchArgument(
9595
'rviz_config',
96-
default_value=os.path.join(bringup_dir, 'rviz', 'nav2_namespaced_view.rviz'),
96+
default_value=os.path.join(bringup_dir, 'rviz', 'nav2_default_view.rviz'),
9797
description='Full path to the RVIZ config file to use.',
9898
)
9999

@@ -144,7 +144,6 @@ def generate_launch_description():
144144
condition=IfCondition(use_rviz),
145145
launch_arguments={
146146
'namespace': TextSubstitution(text=robot_name),
147-
'use_namespace': 'True',
148147
'rviz_config': rviz_config_file,
149148
}.items(),
150149
),
@@ -154,7 +153,6 @@ def generate_launch_description():
154153
),
155154
launch_arguments={
156155
'namespace': robot_name,
157-
'use_namespace': 'True',
158156
'map': map_yaml_file,
159157
'use_sim_time': 'True',
160158
'params_file': params_file,

nav2_bringup/launch/rviz_launch.py

Lines changed: 1 addition & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,10 @@
1818

1919
from launch import LaunchDescription
2020
from launch.actions import DeclareLaunchArgument, EmitEvent, RegisterEventHandler
21-
from launch.conditions import IfCondition, UnlessCondition
2221
from launch.event_handlers import OnProcessExit
2322
from launch.events import Shutdown
2423
from launch.substitutions import LaunchConfiguration
2524
from launch_ros.actions import Node
26-
from nav2_common.launch import ReplaceString
2725

2826

2927
def generate_launch_description():
@@ -32,7 +30,6 @@ def generate_launch_description():
3230

3331
# Create the launch configuration variables
3432
namespace = LaunchConfiguration('namespace')
35-
use_namespace = LaunchConfiguration('use_namespace')
3633
rviz_config_file = LaunchConfiguration('rviz_config')
3734
use_sim_time = LaunchConfiguration('use_sim_time')
3835

@@ -46,12 +43,6 @@ def generate_launch_description():
4643
),
4744
)
4845

49-
declare_use_namespace_cmd = DeclareLaunchArgument(
50-
'use_namespace',
51-
default_value='false',
52-
description='Whether to apply a namespace to the navigation stack',
53-
)
54-
5546
declare_rviz_config_file_cmd = DeclareLaunchArgument(
5647
'rviz_config',
5748
default_value=os.path.join(bringup_dir, 'rviz', 'nav2_default_view.rviz'),
@@ -65,68 +56,37 @@ def generate_launch_description():
6556

6657
# Launch rviz
6758
start_rviz_cmd = Node(
68-
condition=UnlessCondition(use_namespace),
6959
package='rviz2',
7060
executable='rviz2',
61+
namespace=namespace,
7162
arguments=['-d', rviz_config_file],
7263
output='screen',
7364
parameters=[{'use_sim_time': use_sim_time}],
74-
)
75-
76-
namespaced_rviz_config_file = ReplaceString(
77-
source_file=rviz_config_file,
78-
replacements={'<robot_namespace>': ('/', namespace)},
79-
)
80-
81-
start_namespaced_rviz_cmd = Node(
82-
condition=IfCondition(use_namespace),
83-
package='rviz2',
84-
executable='rviz2',
85-
namespace=namespace,
86-
arguments=['-d', namespaced_rviz_config_file],
87-
parameters=[{'use_sim_time': use_sim_time}],
88-
output='screen',
8965
remappings=[
90-
('/map', 'map'),
9166
('/tf', 'tf'),
9267
('/tf_static', 'tf_static'),
93-
('/goal_pose', 'goal_pose'),
94-
('/clicked_point', 'clicked_point'),
95-
('/initialpose', 'initialpose'),
9668
],
9769
)
9870

9971
exit_event_handler = RegisterEventHandler(
100-
condition=UnlessCondition(use_namespace),
10172
event_handler=OnProcessExit(
10273
target_action=start_rviz_cmd,
10374
on_exit=EmitEvent(event=Shutdown(reason='rviz exited')),
10475
),
10576
)
10677

107-
exit_event_handler_namespaced = RegisterEventHandler(
108-
condition=IfCondition(use_namespace),
109-
event_handler=OnProcessExit(
110-
target_action=start_namespaced_rviz_cmd,
111-
on_exit=EmitEvent(event=Shutdown(reason='rviz exited')),
112-
),
113-
)
114-
11578
# Create the launch description and populate
11679
ld = LaunchDescription()
11780

11881
# Declare the launch options
11982
ld.add_action(declare_namespace_cmd)
120-
ld.add_action(declare_use_namespace_cmd)
12183
ld.add_action(declare_rviz_config_file_cmd)
12284
ld.add_action(declare_use_sim_time_cmd)
12385

12486
# Add any conditioned actions
12587
ld.add_action(start_rviz_cmd)
126-
ld.add_action(start_namespaced_rviz_cmd)
12788

12889
# Add other nodes and processes we need
12990
ld.add_action(exit_event_handler)
130-
ld.add_action(exit_event_handler_namespaced)
13191

13292
return ld

nav2_bringup/launch/tb3_loopback_simulation.launch.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ def generate_launch_description():
4242

4343
# Create the launch configuration variables
4444
namespace = LaunchConfiguration('namespace')
45-
use_namespace = LaunchConfiguration('use_namespace')
4645
map_yaml_file = LaunchConfiguration('map')
4746
params_file = LaunchConfiguration('params_file')
4847
autostart = LaunchConfiguration('autostart')
@@ -61,12 +60,6 @@ def generate_launch_description():
6160
'namespace', default_value='', description='Top-level namespace'
6261
)
6362

64-
declare_use_namespace_cmd = DeclareLaunchArgument(
65-
'use_namespace',
66-
default_value='false',
67-
description='Whether to apply a namespace to the navigation stack',
68-
)
69-
7063
declare_map_yaml_cmd = DeclareLaunchArgument(
7164
'map',
7265
default_value=os.path.join(bringup_dir, 'maps', 'tb3_sandbox.yaml'),
@@ -134,7 +127,6 @@ def generate_launch_description():
134127
condition=IfCondition(use_rviz),
135128
launch_arguments={
136129
'namespace': namespace,
137-
'use_namespace': use_namespace,
138130
'use_sim_time': 'True',
139131
'rviz_config': rviz_config_file,
140132
}.items(),
@@ -144,7 +136,6 @@ def generate_launch_description():
144136
PythonLaunchDescriptionSource(os.path.join(launch_dir, 'bringup_launch.py')),
145137
launch_arguments={
146138
'namespace': namespace,
147-
'use_namespace': use_namespace,
148139
'map': map_yaml_file,
149140
'use_sim_time': 'True',
150141
'params_file': params_file,
@@ -203,7 +194,6 @@ def generate_launch_description():
203194

204195
# Declare the launch options
205196
ld.add_action(declare_namespace_cmd)
206-
ld.add_action(declare_use_namespace_cmd)
207197
ld.add_action(declare_map_yaml_cmd)
208198
ld.add_action(declare_params_file_cmd)
209199
ld.add_action(declare_autostart_cmd)

nav2_bringup/launch/tb3_simulation_launch.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ def generate_launch_description():
4444
# Create the launch configuration variables
4545
slam = LaunchConfiguration('slam')
4646
namespace = LaunchConfiguration('namespace')
47-
use_namespace = LaunchConfiguration('use_namespace')
4847
map_yaml_file = LaunchConfiguration('map')
4948
use_sim_time = LaunchConfiguration('use_sim_time')
5049
params_file = LaunchConfiguration('params_file')
@@ -77,12 +76,6 @@ def generate_launch_description():
7776
'namespace', default_value='', description='Top-level namespace'
7877
)
7978

80-
declare_use_namespace_cmd = DeclareLaunchArgument(
81-
'use_namespace',
82-
default_value='false',
83-
description='Whether to apply a namespace to the navigation stack',
84-
)
85-
8679
declare_slam_cmd = DeclareLaunchArgument(
8780
'slam', default_value='False', description='Whether run a SLAM'
8881
)
@@ -186,7 +179,6 @@ def generate_launch_description():
186179
condition=IfCondition(use_rviz),
187180
launch_arguments={
188181
'namespace': namespace,
189-
'use_namespace': use_namespace,
190182
'use_sim_time': use_sim_time,
191183
'rviz_config': rviz_config_file,
192184
}.items(),
@@ -196,7 +188,6 @@ def generate_launch_description():
196188
PythonLaunchDescriptionSource(os.path.join(launch_dir, 'bringup_launch.py')),
197189
launch_arguments={
198190
'namespace': namespace,
199-
'use_namespace': use_namespace,
200191
'slam': slam,
201192
'map': map_yaml_file,
202193
'use_sim_time': use_sim_time,
@@ -255,7 +246,6 @@ def generate_launch_description():
255246

256247
# Declare the launch options
257248
ld.add_action(declare_namespace_cmd)
258-
ld.add_action(declare_use_namespace_cmd)
259249
ld.add_action(declare_slam_cmd)
260250
ld.add_action(declare_map_yaml_cmd)
261251
ld.add_action(declare_use_sim_time_cmd)

nav2_bringup/launch/tb4_loopback_simulation.launch.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ def generate_launch_description():
4242

4343
# Create the launch configuration variables
4444
namespace = LaunchConfiguration('namespace')
45-
use_namespace = LaunchConfiguration('use_namespace')
4645
map_yaml_file = LaunchConfiguration('map')
4746
params_file = LaunchConfiguration('params_file')
4847
autostart = LaunchConfiguration('autostart')
@@ -61,12 +60,6 @@ def generate_launch_description():
6160
'namespace', default_value='', description='Top-level namespace'
6261
)
6362

64-
declare_use_namespace_cmd = DeclareLaunchArgument(
65-
'use_namespace',
66-
default_value='false',
67-
description='Whether to apply a namespace to the navigation stack',
68-
)
69-
7063
declare_map_yaml_cmd = DeclareLaunchArgument(
7164
'map',
7265
default_value=os.path.join(bringup_dir, 'maps', 'depot.yaml'), # Try warehouse.yaml!
@@ -132,7 +125,6 @@ def generate_launch_description():
132125
condition=IfCondition(use_rviz),
133126
launch_arguments={
134127
'namespace': namespace,
135-
'use_namespace': use_namespace,
136128
'use_sim_time': 'True',
137129
'rviz_config': rviz_config_file,
138130
}.items(),
@@ -142,7 +134,6 @@ def generate_launch_description():
142134
PythonLaunchDescriptionSource(os.path.join(launch_dir, 'bringup_launch.py')),
143135
launch_arguments={
144136
'namespace': namespace,
145-
'use_namespace': use_namespace,
146137
'map': map_yaml_file,
147138
'use_sim_time': 'True',
148139
'params_file': params_file,
@@ -210,7 +201,6 @@ def generate_launch_description():
210201

211202
# Declare the launch options
212203
ld.add_action(declare_namespace_cmd)
213-
ld.add_action(declare_use_namespace_cmd)
214204
ld.add_action(declare_map_yaml_cmd)
215205
ld.add_action(declare_params_file_cmd)
216206
ld.add_action(declare_autostart_cmd)

nav2_bringup/launch/tb4_simulation_launch.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ def generate_launch_description():
4848
# Create the launch configuration variables
4949
slam = LaunchConfiguration('slam')
5050
namespace = LaunchConfiguration('namespace')
51-
use_namespace = LaunchConfiguration('use_namespace')
5251
map_yaml_file = LaunchConfiguration('map')
5352
use_sim_time = LaunchConfiguration('use_sim_time')
5453
params_file = LaunchConfiguration('params_file')
@@ -81,12 +80,6 @@ def generate_launch_description():
8180
'namespace', default_value='', description='Top-level namespace'
8281
)
8382

84-
declare_use_namespace_cmd = DeclareLaunchArgument(
85-
'use_namespace',
86-
default_value='false',
87-
description='Whether to apply a namespace to the navigation stack',
88-
)
89-
9083
declare_slam_cmd = DeclareLaunchArgument(
9184
'slam', default_value='False', description='Whether run a SLAM'
9285
)
@@ -187,7 +180,6 @@ def generate_launch_description():
187180
condition=IfCondition(use_rviz),
188181
launch_arguments={
189182
'namespace': namespace,
190-
'use_namespace': use_namespace,
191183
'use_sim_time': use_sim_time,
192184
'rviz_config': rviz_config_file,
193185
}.items(),
@@ -197,7 +189,6 @@ def generate_launch_description():
197189
PythonLaunchDescriptionSource(os.path.join(launch_dir, 'bringup_launch.py')),
198190
launch_arguments={
199191
'namespace': namespace,
200-
'use_namespace': use_namespace,
201192
'slam': slam,
202193
'map': map_yaml_file,
203194
'use_sim_time': use_sim_time,
@@ -261,7 +252,6 @@ def generate_launch_description():
261252

262253
# Declare the launch options
263254
ld.add_action(declare_namespace_cmd)
264-
ld.add_action(declare_use_namespace_cmd)
265255
ld.add_action(declare_slam_cmd)
266256
ld.add_action(declare_map_yaml_cmd)
267257
ld.add_action(declare_use_sim_time_cmd)

0 commit comments

Comments
 (0)