Skip to content

Commit c471bfa

Browse files
Lifecycle manager with respawn option + adding respawn options in launch (ros-navigation#2910)
* updated launch files for respawn options * adding respawn capabilities to lifecycle manager * closer to working * updates for get_state (still WIP) * working lifecycle manager + respawn * adding delay * more context in description of launch configurationg * adding lint exception * Update config.yml * fixing CI issues
1 parent 6e941b2 commit c471bfa

File tree

5 files changed

+54
-2
lines changed

5 files changed

+54
-2
lines changed

‎nav2_bringup/launch/bringup_launch.py‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ def generate_launch_description():
4141
params_file = LaunchConfiguration('params_file')
4242
autostart = LaunchConfiguration('autostart')
4343
use_composition = LaunchConfiguration('use_composition')
44+
use_respawn = LaunchConfiguration('use_respawn')
4445

4546
# Map fully qualified names to relative ones so the node's namespace can be prepended.
4647
# In case of the transforms (tf), currently, there doesn't seem to be a better alternative
@@ -102,6 +103,10 @@ def generate_launch_description():
102103
'use_composition', default_value='True',
103104
description='Whether to use composed bringup')
104105

106+
declare_use_respawn_cmd = DeclareLaunchArgument(
107+
'use_respawn', default_value='False',
108+
description='Whether to respawn if a node crashes. Applied when composition is disabled.')
109+
105110
# Specify the actions
106111
bringup_cmd_group = GroupAction([
107112
PushRosNamespace(
@@ -123,6 +128,7 @@ def generate_launch_description():
123128
launch_arguments={'namespace': namespace,
124129
'use_sim_time': use_sim_time,
125130
'autostart': autostart,
131+
'use_respawn': use_respawn,
126132
'params_file': params_file}.items()),
127133

128134
IncludeLaunchDescription(
@@ -135,6 +141,7 @@ def generate_launch_description():
135141
'autostart': autostart,
136142
'params_file': params_file,
137143
'use_composition': use_composition,
144+
'use_respawn': use_respawn,
138145
'container_name': 'nav2_container'}.items()),
139146

140147
IncludeLaunchDescription(
@@ -144,6 +151,7 @@ def generate_launch_description():
144151
'autostart': autostart,
145152
'params_file': params_file,
146153
'use_composition': use_composition,
154+
'use_respawn': use_respawn,
147155
'container_name': 'nav2_container'}.items()),
148156
])
149157

@@ -162,6 +170,7 @@ def generate_launch_description():
162170
ld.add_action(declare_params_file_cmd)
163171
ld.add_action(declare_autostart_cmd)
164172
ld.add_action(declare_use_composition_cmd)
173+
ld.add_action(declare_use_respawn_cmd)
165174

166175
# Add the actions to launch all of the navigation nodes
167176
ld.add_action(bringup_cmd_group)

‎nav2_bringup/launch/localization_launch.py‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ def generate_launch_description():
3737
params_file = LaunchConfiguration('params_file')
3838
use_composition = LaunchConfiguration('use_composition')
3939
container_name = LaunchConfiguration('container_name')
40+
use_respawn = LaunchConfiguration('use_respawn')
4041

4142
lifecycle_nodes = ['map_server', 'amcl']
4243

@@ -94,6 +95,10 @@ def generate_launch_description():
9495
'container_name', default_value='nav2_container',
9596
description='the name of conatiner that nodes will load in if use composition')
9697

98+
declare_use_respawn_cmd = DeclareLaunchArgument(
99+
'use_respawn', default_value='False',
100+
description='Whether to respawn if a node crashes. Applied when composition is disabled.')
101+
97102
load_nodes = GroupAction(
98103
condition=IfCondition(PythonExpression(['not ', use_composition])),
99104
actions=[
@@ -102,13 +107,17 @@ def generate_launch_description():
102107
executable='map_server',
103108
name='map_server',
104109
output='screen',
110+
respawn=use_respawn,
111+
respawn_delay=2.0,
105112
parameters=[configured_params],
106113
remappings=remappings),
107114
Node(
108115
package='nav2_amcl',
109116
executable='amcl',
110117
name='amcl',
111118
output='screen',
119+
respawn=use_respawn,
120+
respawn_delay=2.0,
112121
parameters=[configured_params],
113122
remappings=remappings),
114123
Node(
@@ -162,6 +171,7 @@ def generate_launch_description():
162171
ld.add_action(declare_autostart_cmd)
163172
ld.add_action(declare_use_composition_cmd)
164173
ld.add_action(declare_container_name_cmd)
174+
ld.add_action(declare_use_respawn_cmd)
165175

166176
# Add the actions to launch all of the localiztion nodes
167177
ld.add_action(load_nodes)

‎nav2_bringup/launch/navigation_launch.py‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ def generate_launch_description():
3636
params_file = LaunchConfiguration('params_file')
3737
use_composition = LaunchConfiguration('use_composition')
3838
container_name = LaunchConfiguration('container_name')
39+
use_respawn = LaunchConfiguration('use_respawn')
3940

4041
lifecycle_nodes = ['controller_server',
4142
'smoother_server',
@@ -94,48 +95,64 @@ def generate_launch_description():
9495
'container_name', default_value='nav2_container',
9596
description='the name of conatiner that nodes will load in if use composition')
9697

98+
declare_use_respawn_cmd = DeclareLaunchArgument(
99+
'use_respawn', default_value='False',
100+
description='Whether to respawn if a node crashes. Applied when composition is disabled.')
101+
97102
load_nodes = GroupAction(
98103
condition=IfCondition(PythonExpression(['not ', use_composition])),
99104
actions=[
100105
Node(
101106
package='nav2_controller',
102107
executable='controller_server',
103108
output='screen',
109+
respawn=use_respawn,
110+
respawn_delay=2.0,
104111
parameters=[configured_params],
105112
remappings=remappings),
106113
Node(
107114
package='nav2_smoother',
108115
executable='smoother_server',
109116
name='smoother_server',
110117
output='screen',
118+
respawn=use_respawn,
119+
respawn_delay=2.0,
111120
parameters=[configured_params],
112121
remappings=remappings),
113122
Node(
114123
package='nav2_planner',
115124
executable='planner_server',
116125
name='planner_server',
117126
output='screen',
127+
respawn=use_respawn,
128+
respawn_delay=2.0,
118129
parameters=[configured_params],
119130
remappings=remappings),
120131
Node(
121132
package='nav2_behaviors',
122133
executable='behavior_server',
123134
name='behavior_server',
124135
output='screen',
136+
respawn=use_respawn,
137+
respawn_delay=2.0,
125138
parameters=[configured_params],
126139
remappings=remappings),
127140
Node(
128141
package='nav2_bt_navigator',
129142
executable='bt_navigator',
130143
name='bt_navigator',
131144
output='screen',
145+
respawn=use_respawn,
146+
respawn_delay=2.0,
132147
parameters=[configured_params],
133148
remappings=remappings),
134149
Node(
135150
package='nav2_waypoint_follower',
136151
executable='waypoint_follower',
137152
name='waypoint_follower',
138153
output='screen',
154+
respawn=use_respawn,
155+
respawn_delay=2.0,
139156
parameters=[configured_params],
140157
remappings=remappings),
141158
Node(
@@ -212,6 +229,7 @@ def generate_launch_description():
212229
ld.add_action(declare_autostart_cmd)
213230
ld.add_action(declare_use_composition_cmd)
214231
ld.add_action(declare_container_name_cmd)
232+
ld.add_action(declare_use_respawn_cmd)
215233

216234
# Add the actions to launch all of the navigation nodes
217235
ld.add_action(load_nodes)

‎nav2_bringup/launch/slam_launch.py‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ def generate_launch_description():
3131
params_file = LaunchConfiguration('params_file')
3232
use_sim_time = LaunchConfiguration('use_sim_time')
3333
autostart = LaunchConfiguration('autostart')
34+
use_respawn = LaunchConfiguration('use_respawn')
3435

3536
# Variables
3637
lifecycle_nodes = ['map_saver']
@@ -70,12 +71,18 @@ def generate_launch_description():
7071
'autostart', default_value='True',
7172
description='Automatically startup the nav2 stack')
7273

74+
declare_use_respawn_cmd = DeclareLaunchArgument(
75+
'use_respawn', default_value='False',
76+
description='Whether to respawn if a node crashes. Applied when composition is disabled.')
77+
7378
# Nodes launching commands
7479

7580
start_map_saver_server_cmd = Node(
7681
package='nav2_map_server',
7782
executable='map_saver_server',
7883
output='screen',
84+
respawn=use_respawn,
85+
respawn_delay=2.0,
7986
parameters=[configured_params])
8087

8188
start_lifecycle_manager_cmd = Node(
@@ -111,6 +118,7 @@ def generate_launch_description():
111118
ld.add_action(declare_params_file_cmd)
112119
ld.add_action(declare_use_sim_time_cmd)
113120
ld.add_action(declare_autostart_cmd)
121+
ld.add_action(declare_use_respawn_cmd)
114122

115123
# Running Map Saver Server
116124
ld.add_action(start_map_saver_server_cmd)

‎nav2_bringup/launch/tb3_simulation_launch.py‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ def generate_launch_description():
4040
params_file = LaunchConfiguration('params_file')
4141
autostart = LaunchConfiguration('autostart')
4242
use_composition = LaunchConfiguration('use_composition')
43+
use_respawn = LaunchConfiguration('use_respawn')
4344

4445
# Launch configuration variables specific to simulation
4546
rviz_config_file = LaunchConfiguration('rviz_config_file')
@@ -106,6 +107,10 @@ def generate_launch_description():
106107
'use_composition', default_value='True',
107108
description='Whether to use composed bringup')
108109

110+
declare_use_respawn_cmd = DeclareLaunchArgument(
111+
'use_respawn', default_value='False',
112+
description='Whether to respawn if a node crashes. Applied when composition is disabled.')
113+
109114
declare_rviz_config_file_cmd = DeclareLaunchArgument(
110115
'rviz_config_file',
111116
default_value=os.path.join(
@@ -129,7 +134,7 @@ def generate_launch_description():
129134

130135
declare_simulator_cmd = DeclareLaunchArgument(
131136
'headless',
132-
default_value='False',
137+
default_value='True',
133138
description='Whether to execute gzclient)')
134139

135140
declare_world_cmd = DeclareLaunchArgument(
@@ -208,7 +213,8 @@ def generate_launch_description():
208213
'use_sim_time': use_sim_time,
209214
'params_file': params_file,
210215
'autostart': autostart,
211-
'use_composition': use_composition}.items())
216+
'use_composition': use_composition,
217+
'use_respawn': use_respawn}.items())
212218

213219
# Create the launch description and populate
214220
ld = LaunchDescription()
@@ -231,6 +237,7 @@ def generate_launch_description():
231237
ld.add_action(declare_world_cmd)
232238
ld.add_action(declare_robot_name_cmd)
233239
ld.add_action(declare_robot_sdf_cmd)
240+
ld.add_action(declare_use_respawn_cmd)
234241

235242
# Add any conditioned actions
236243
ld.add_action(start_gazebo_server_cmd)

0 commit comments

Comments
 (0)