diff --git a/ur_simulation_gz/launch/ur_sim_control.launch.py b/ur_simulation_gz/launch/ur_sim_control.launch.py index 0a1a2d7..df56acf 100644 --- a/ur_simulation_gz/launch/ur_sim_control.launch.py +++ b/ur_simulation_gz/launch/ur_sim_control.launch.py @@ -38,7 +38,13 @@ from launch.conditions import IfCondition, UnlessCondition from launch.event_handlers import OnProcessExit from launch.launch_description_sources import PythonLaunchDescriptionSource -from launch.substitutions import Command, FindExecutable, LaunchConfiguration, PathJoinSubstitution +from launch.substitutions import ( + Command, + FindExecutable, + LaunchConfiguration, + PathJoinSubstitution, + IfElseSubstitution, +) from launch_ros.actions import Node from launch_ros.substitutions import FindPackageShare @@ -56,6 +62,7 @@ def launch_setup(context, *args, **kwargs): activate_joint_controller = LaunchConfiguration("activate_joint_controller") initial_joint_controller = LaunchConfiguration("initial_joint_controller") launch_rviz = LaunchConfiguration("launch_rviz") + gazebo_gui = LaunchConfiguration("gazebo_gui") initial_joint_controllers = PathJoinSubstitution( [FindPackageShare(runtime_config_package), "config", controllers_file] @@ -161,7 +168,11 @@ def launch_setup(context, *args, **kwargs): PythonLaunchDescriptionSource( [FindPackageShare("ros_gz_sim"), "/launch/gz_sim.launch.py"] ), - launch_arguments={"gz_args": " -r -v 4 empty.sdf"}.items(), + launch_arguments={ + "gz_args": IfElseSubstitution( + gazebo_gui, if_value=" -r -v 4 empty.sdf", else_value=" -s -r -v 4 empty.sdf" + ) + }.items(), ) nodes_to_start = [ @@ -251,5 +262,10 @@ def generate_launch_description(): declared_arguments.append( DeclareLaunchArgument("launch_rviz", default_value="true", description="Launch RViz?") ) + declared_arguments.append( + DeclareLaunchArgument( + "gazebo_gui", default_value="true", description="Start gazebo with GUI?" + ) + ) return LaunchDescription(declared_arguments + [OpaqueFunction(function=launch_setup)])