Skip to content

Commit

Permalink
fixing gz sim launch file by using gz directly (ros-navigation#4514)
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveMacenski authored and Marc-Morcos committed Jul 4, 2024
1 parent 96e21da commit 7a29e17
Show file tree
Hide file tree
Showing 14 changed files with 48 additions and 103 deletions.
9 changes: 4 additions & 5 deletions nav2_bringup/launch/cloned_multi_tb3_simulation_launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,10 @@ def generate_launch_description():
world_sdf = tempfile.mktemp(prefix='nav2_', suffix='.sdf')
world_sdf_xacro = ExecuteProcess(
cmd=['xacro', '-o', world_sdf, ['headless:=', 'False'], world])
start_gazebo_cmd = IncludeLaunchDescription(
PythonLaunchDescriptionSource(
os.path.join(get_package_share_directory('ros_gz_sim'), 'launch',
'gz_sim.launch.py')),
launch_arguments={'gz_args': ['-r -s ', world_sdf]}.items())
start_gazebo_cmd = ExecuteProcess(
cmd=['gz', 'sim', '-r', '-s', world_sdf],
output='screen',
)

remove_temp_sdf_file = RegisterEventHandler(event_handler=OnShutdown(
on_shutdown=[
Expand Down
11 changes: 5 additions & 6 deletions nav2_bringup/launch/tb3_simulation_launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,12 +214,11 @@ def generate_launch_description():
world_sdf = tempfile.mktemp(prefix='nav2_', suffix='.sdf')
world_sdf_xacro = ExecuteProcess(
cmd=['xacro', '-o', world_sdf, ['headless:=', headless], world])
gazebo_server = IncludeLaunchDescription(
PythonLaunchDescriptionSource(
os.path.join(get_package_share_directory('ros_gz_sim'), 'launch',
'gz_sim.launch.py')),
launch_arguments={'gz_args': ['-r -s ', world_sdf]}.items(),
condition=IfCondition(use_simulator))
gazebo_server = ExecuteProcess(
cmd=['gz', 'sim', '-r', '-s', world_sdf],
output='screen',
condition=IfCondition(use_simulator)
)

remove_temp_sdf_file = RegisterEventHandler(event_handler=OnShutdown(
on_shutdown=[
Expand Down
11 changes: 5 additions & 6 deletions nav2_bringup/launch/tb4_simulation_launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,12 +216,11 @@ def generate_launch_description():
world_sdf = tempfile.mktemp(prefix='nav2_', suffix='.sdf')
world_sdf_xacro = ExecuteProcess(
cmd=['xacro', '-o', world_sdf, ['headless:=', headless], world])
gazebo_server = IncludeLaunchDescription(
PythonLaunchDescriptionSource(
os.path.join(get_package_share_directory('ros_gz_sim'), 'launch',
'gz_sim.launch.py')),
launch_arguments={'gz_args': ['-r -s ', world_sdf]}.items(),
condition=IfCondition(use_simulator))
gazebo_server = ExecuteProcess(
cmd=['gz', 'sim', '-r', '-s', world_sdf],
output='screen',
condition=IfCondition(use_simulator)
)

remove_temp_sdf_file = RegisterEventHandler(event_handler=OnShutdown(
on_shutdown=[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,10 @@ def generate_launch_description():
world_sdf = tempfile.mktemp(prefix='nav2_', suffix='.sdf')
world_sdf_xacro = ExecuteProcess(
cmd=['xacro', '-o', world_sdf, ['headless:=', 'False'], world])
start_gazebo_cmd = IncludeLaunchDescription(
PythonLaunchDescriptionSource(
os.path.join(get_package_share_directory('ros_gz_sim'), 'launch',
'gz_sim.launch.py')),
launch_arguments={'gz_args': ['-r -s ', world_sdf]}.items())
start_gazebo_cmd = ExecuteProcess(
cmd=['gz', 'sim', '-r', '-s', world_sdf],
output='screen',
)

remove_temp_sdf_file = RegisterEventHandler(event_handler=OnShutdown(
on_shutdown=[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,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.xacro')
Expand Down Expand Up @@ -73,11 +71,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 @@ -134,7 +130,6 @@ def main(argv=sys.argv[1:]):
ls = LaunchService(argv=argv)
ls.include_launch_description(ld)
return_code = lts.run(ls)
kill_os_processes('gz sim')
return return_code


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,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.xacro')
Expand Down Expand Up @@ -75,11 +73,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 @@ -136,7 +132,6 @@ def main(argv=sys.argv[1:]):
ls = LaunchService(argv=argv)
ls.include_launch_description(ld)
return_code = lts.run(ls)
kill_os_processes('gz sim')
return return_code


Expand Down
11 changes: 3 additions & 8 deletions nav2_system_tests/src/costmap_filters/test_keepout_launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,12 @@
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')
nav2_sys_test_dir = get_package_share_directory('nav2_system_tests')
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.xacro')
Expand Down Expand Up @@ -90,11 +88,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 @@ -199,7 +195,6 @@ def main(argv=sys.argv[1:]):
ls = LaunchService(argv=argv)
ls.include_launch_description(ld)
return_code = lts.run(ls)
kill_os_processes('gz sim')
return return_code


Expand Down
11 changes: 3 additions & 8 deletions nav2_system_tests/src/costmap_filters/test_speed_launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,12 @@
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')
nav2_sys_test_dir = get_package_share_directory('nav2_system_tests')
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.xacro')
Expand Down Expand Up @@ -88,11 +86,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 @@ -190,7 +186,6 @@ def main(argv=sys.argv[1:]):
ls = LaunchService(argv=argv)
ls.include_launch_description(ld)
return_code = lts.run(ls)
kill_os_processes('gz sim')
return return_code


Expand Down
12 changes: 3 additions & 9 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.xacro')
Expand All @@ -53,11 +50,9 @@ 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(
Expand Down Expand Up @@ -123,7 +118,6 @@ def main(argv=sys.argv[1:]):
ls = LaunchService(argv=argv)
ls.include_launch_description(ld)
return_code = lts.run(ls)
kill_os_processes('gz sim')
return return_code


Expand Down
11 changes: 3 additions & 8 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.xacro')
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 @@ -169,7 +165,6 @@ def main(argv=sys.argv[1:]):
ls = LaunchService(argv=argv)
ls.include_launch_description(ld)
return_code = lts.run(ls)
kill_os_processes('gz sim')
return return_code


Expand Down
11 changes: 3 additions & 8 deletions nav2_system_tests/src/system/test_system_with_obstacle_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')
nav2_system_tests_dir = get_package_share_directory('nav2_system_tests')

world_sdf_xacro = os.path.join(sim_dir, 'worlds', 'tb3_sandbox.sdf.xacro')
Expand Down Expand Up @@ -100,11 +98,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 @@ -182,7 +178,6 @@ def main(argv=sys.argv[1:]):
ls = LaunchService(argv=argv)
ls.include_launch_description(ld)
return_code = lts.run(ls)
kill_os_processes('gz sim')
return return_code


Expand Down
11 changes: 3 additions & 8 deletions nav2_system_tests/src/system/test_wrong_init_pose_launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,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.xacro')
Expand Down Expand Up @@ -96,11 +94,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,7 +164,6 @@ def main(argv=sys.argv[1:]):
ls = LaunchService(argv=argv)
ls.include_launch_description(ld)
return_code = lts.run(ls)
kill_os_processes('gz sim')
return return_code


Expand Down
Loading

0 comments on commit 7a29e17

Please sign in to comment.