Skip to content

Commit

Permalink
Adding more launch arguments (backport of #37)
Browse files Browse the repository at this point in the history
* Added world_file as launch argument
* Added gazebo_gui launch argument

Co-authored-by: Vincenzo Di Pentima <[email protected]>
  • Loading branch information
mergify[bot] and VinDp authored Jul 4, 2024
1 parent d06b552 commit 858a542
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 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 @@ -58,6 +64,8 @@ def launch_setup(context, *args, **kwargs):
start_joint_controller = LaunchConfiguration("start_joint_controller")
initial_joint_controller = LaunchConfiguration("initial_joint_controller")
launch_rviz = LaunchConfiguration("launch_rviz")
gazebo_gui = LaunchConfiguration("gazebo_gui")
world_file = LaunchConfiguration("world_file")

initial_joint_controllers = PathJoinSubstitution(
[FindPackageShare(runtime_config_package), "config", controllers_file]
Expand Down Expand Up @@ -165,7 +173,13 @@ 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 ", world_file],
else_value=[" -s -r -v 4 ", world_file],
)
}.items(),
)

nodes_to_start = [
Expand Down Expand Up @@ -270,5 +284,17 @@ 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?"
)
)
declared_arguments.append(
DeclareLaunchArgument(
"world_file",
default_value="empty.sdf",
description="Gazebo world file (absolute path or filename from the gazebosim worlds collection) containing a custom world.",
)
)

return LaunchDescription(declared_arguments + [OpaqueFunction(function=launch_setup)])

0 comments on commit 858a542

Please sign in to comment.