Skip to content

Commit

Permalink
set on_exit_shutdown argument for gz-sim ExecuteProcess (#355) (#452)
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Anderson <[email protected]>
Co-authored-by: andermi <[email protected]>
  • Loading branch information
mjcarroll and andermi authored Sep 21, 2023
1 parent e93c35d commit bc4f777
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions ros_gz_sim/launch/gz_sim.launch.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ from os import environ

from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument, OpaqueFunction
from launch.actions import ExecuteProcess
from launch.actions import ExecuteProcess, Shutdown
from launch.substitutions import LaunchConfiguration

def launch_gz(context, *args, **kwargs):
Expand All @@ -34,6 +34,7 @@ def launch_gz(context, *args, **kwargs):
ign_args = LaunchConfiguration('ign_args').perform(context)
ign_version = LaunchConfiguration('ign_version').perform(context)
debugger = LaunchConfiguration('debugger').perform(context)
on_exit_shutdown = LaunchConfiguration('on_exit_shutdown').perform(context)

if not len(gz_args) and len(ign_args):
print("ign_args is deprecated, migrate to gz_args!")
Expand All @@ -54,12 +55,18 @@ def launch_gz(context, *args, **kwargs):
else:
debug_prefix = None

if on_exit_shutdown:
on_exit = Shutdown()
else:
on_exit = None

return [ExecuteProcess(
cmd=[exec, exec_args, '--force-version', gz_version],
output='screen',
additional_env=env,
shell=True,
prefix=debug_prefix
prefix=debug_prefix,
on_exit=on_exit
)]


Expand All @@ -84,5 +91,8 @@ def generate_launch_description():
DeclareLaunchArgument(
'debugger', default_value='false',
description='Run in Debugger'),
DeclareLaunchArgument(
'on_exit_shutdown', default_value='false',
description='Shutdown on gz-sim exit'),
OpaqueFunction(function = launch_gz),
])

0 comments on commit bc4f777

Please sign in to comment.