Skip to content

Commit

Permalink
Add comment explaining temp file
Browse files Browse the repository at this point in the history
Signed-off-by: Addisu Z. Taddese <[email protected]>
  • Loading branch information
azeey committed Feb 17, 2024
1 parent 6a462be commit 225f1f3
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions nav2_bringup/launch/tb3_gz_simulation_launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,12 @@ def generate_launch_description():
'use_respawn': use_respawn,
}.items(),
)

world_sdf = tempfile.mktemp(prefix='nav2_', suffix='.sdf')
# The SDF file for the world is a xacro file because we wanted to
# conditionally load the SceneBroadcaster plugin based on wheter we're
# running in headless mode. But currently, the Gazebo command line doesn't
# take SDF strings for worlds, so the output of xacro needs to be saved into
# a temporary file and passed to Gazebo.
world_sdf = tempfile.mktemp(prefix="nav2_", suffix=".sdf")
world_sdf_xacro = ExecuteProcess(
cmd=['xacro', '-o', world_sdf, ['headless:=', headless], world])
gazebo_server = IncludeLaunchDescription(
Expand All @@ -231,7 +235,7 @@ def generate_launch_description():

remove_temp_sdf_file = RegisterEventHandler(event_handler=OnShutdown(
on_shutdown=[
OpaqueFunction(function=lambda context: os.remove(world_sdf))
OpaqueFunction(function=lambda _: os.remove(world_sdf))
]))

set_env_vars_resources = AppendEnvironmentVariable(
Expand Down

0 comments on commit 225f1f3

Please sign in to comment.