Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log environment variables with which gazebo was launched #680

Open
wants to merge 4 commits into
base: ros2
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 25 additions & 9 deletions ros_gz_sim/launch/gz_sim.launch.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ from ros2pkg.api import get_package_names
from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument, OpaqueFunction
from launch.actions import ExecuteProcess, Shutdown
from launch.actions import LogInfo
from launch.substitutions import LaunchConfiguration

# Copied from https://github.com/ros-simulation/gazebo_ros_pkgs/blob/79fd94c6da76781a91499bc0f54b70560b90a9d2/gazebo_ros/scripts/gazebo_ros_paths.py
Expand Down Expand Up @@ -101,6 +102,7 @@ def launch_gz(context, *args, **kwargs):
ign_version = LaunchConfiguration('ign_version').perform(context)
debugger = LaunchConfiguration('debugger').perform(context)
on_exit_shutdown = LaunchConfiguration('on_exit_shutdown').perform(context)
debug_env = LaunchConfiguration('debug_env').perform(context)

if not len(gz_args) and len(ign_args):
print("ign_args is deprecated, migrate to gz_args!")
Expand All @@ -126,15 +128,29 @@ def launch_gz(context, *args, **kwargs):
else:
on_exit = None

return [ExecuteProcess(
cmd=[exec, exec_args, '--force-version', gz_version],
name='gazebo',
output='screen',
additional_env=env,
shell=True,
prefix=debug_prefix,
on_exit=on_exit
)]
if debug_env == 'true':
return [
LogInfo(f"Launching gazebo with the environment variables: {env}"),
ExecuteProcess(
cmd=[exec, exec_args, '--force-version', gz_version],
name='gazebo',
output='screen',
additional_env=env,
shell=True,
prefix=debug_prefix,
on_exit=on_exit
)]
else:
return [
ExecuteProcess(
cmd=[exec, exec_args, '--force-version', gz_version],
name='gazebo',
output='screen',
additional_env=env,
shell=True,
prefix=debug_prefix,
on_exit=on_exit
)]
Comment on lines +131 to +153
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can deduplicate this

Suggested change
if debug_env == 'true':
return [
LogInfo(f"Launching gazebo with the environment variables: {env}"),
ExecuteProcess(
cmd=[exec, exec_args, '--force-version', gz_version],
name='gazebo',
output='screen',
additional_env=env,
shell=True,
prefix=debug_prefix,
on_exit=on_exit
)]
else:
return [
ExecuteProcess(
cmd=[exec, exec_args, '--force-version', gz_version],
name='gazebo',
output='screen',
additional_env=env,
shell=True,
prefix=debug_prefix,
on_exit=on_exit
)]
ld = [ExecuteProcess(
cmd=[exec, exec_args, '--force-version', gz_version],
name='gazebo',
output='screen',
additional_env=env,
shell=True,
prefix=debug_prefix,
on_exit=on_exit
)
]
if debug_env == 'true':
ld.insert(0, LogInfo(f"Launching gazebo with the environment variables: {env}"))
return ld



def generate_launch_description():
Expand Down
Loading