Skip to content

Commit

Permalink
Add gazebo_gui argument
Browse files Browse the repository at this point in the history
  • Loading branch information
fmauch committed Apr 15, 2024
1 parent 9d91758 commit c141ee0
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions ur_simulation_gz/launch/ur_sim_control.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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]
Expand Down Expand Up @@ -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 = [
Expand Down Expand Up @@ -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)])

0 comments on commit c141ee0

Please sign in to comment.