Skip to content

Commit

Permalink
Call gz sim directly without shell=True for a clean exit
Browse files Browse the repository at this point in the history
Signed-off-by: Addisu Z. Taddese <[email protected]>
  • Loading branch information
azeey committed Jun 20, 2024
1 parent 9057456 commit 4d09eeb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 22 deletions.
17 changes: 5 additions & 12 deletions nav2_system_tests/src/localization/test_localization_launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,11 @@
import launch_ros.actions
from launch_testing.legacy import LaunchTestService

from nav2_simple_commander.utils import kill_os_processes


def main(argv=sys.argv[1:]):
testExecutable = os.getenv('TEST_EXECUTABLE')
sim_dir = get_package_share_directory('nav2_minimal_tb3_sim')
nav2_bringup_dir = get_package_share_directory('nav2_bringup')
ros_gz_sim_dir = get_package_share_directory('ros_gz_sim')

world_sdf_xacro = os.path.join(sim_dir, 'worlds', 'tb3_sandbox.sdf.xacro')
robot_sdf = os.path.join(sim_dir, 'urdf', 'gz_waffle.sdf')
Expand All @@ -53,12 +50,10 @@ def main(argv=sys.argv[1:]):
str(Path(os.path.join(sim_dir)).parent.resolve())
)

start_gazebo_server = IncludeLaunchDescription(
PythonLaunchDescriptionSource(
os.path.join(ros_gz_sim_dir, 'launch', 'gz_sim.launch.py')
),
launch_arguments={'gz_args': ['-r -s ', world_sdf_xacro]}.items(),
)
start_gazebo_server = ExecuteProcess(
cmd=['gz', 'sim', '-r', '-s', world_sdf_xacro],
output='screen',
),

spawn_robot = IncludeLaunchDescription(
PythonLaunchDescriptionSource(
Expand Down Expand Up @@ -122,9 +117,7 @@ def main(argv=sys.argv[1:]):
lts.add_test_action(ld, test1_action)
ls = LaunchService(argv=argv)
ls.include_launch_description(ld)
return_code = lts.run(ls)
kill_os_processes('gz sim')
return return_code
return lts.run(ls)


if __name__ == '__main__':
Expand Down
14 changes: 4 additions & 10 deletions nav2_system_tests/src/system/test_system_launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,11 @@
from launch_testing.legacy import LaunchTestService

from nav2_common.launch import RewrittenYaml
from nav2_simple_commander.utils import kill_os_processes


def generate_launch_description():
sim_dir = get_package_share_directory('nav2_minimal_tb3_sim')
nav2_bringup_dir = get_package_share_directory('nav2_bringup')
ros_gz_sim_dir = get_package_share_directory('ros_gz_sim')

world_sdf_xacro = os.path.join(sim_dir, 'worlds', 'tb3_sandbox.sdf.xacro')
robot_sdf = os.path.join(sim_dir, 'urdf', 'gz_waffle.sdf')
Expand Down Expand Up @@ -97,11 +95,9 @@ def generate_launch_description():
'GZ_SIM_RESOURCE_PATH',
str(Path(os.path.join(sim_dir)).parent.resolve())
),
IncludeLaunchDescription(
PythonLaunchDescriptionSource(
os.path.join(ros_gz_sim_dir, 'launch', 'gz_sim.launch.py')
),
launch_arguments={'gz_args': ['-r -s ', world_sdf_xacro]}.items(),
ExecuteProcess(
cmd=['gz', 'sim', '-r', '-s', world_sdf_xacro],
output='screen',
),
IncludeLaunchDescription(
PythonLaunchDescriptionSource(
Expand Down Expand Up @@ -168,9 +164,7 @@ def main(argv=sys.argv[1:]):
lts.add_test_action(ld, test1_action)
ls = LaunchService(argv=argv)
ls.include_launch_description(ld)
return_code = lts.run(ls)
kill_os_processes('gz sim')
return return_code
return lts.run(ls)


if __name__ == '__main__':
Expand Down

0 comments on commit 4d09eeb

Please sign in to comment.