17from ament_index_python.packages
import get_package_share_directory
19from launch
import LaunchDescription
20from launch.actions
import DeclareLaunchArgument, ExecuteProcess
21from launch.conditions
import IfCondition
22from launch.substitutions
import LaunchConfiguration, PythonExpression
23from launch_ros.actions.node
import Node
27 declare_use_simulator_cmd = DeclareLaunchArgument(
28 "use_simulator", default_value=
"False", description=
"Whether to execute gzclient)"
31 use_simulator = LaunchConfiguration(
"use_simulator")
32 world = LaunchConfiguration(
"world")
33 headless = LaunchConfiguration(
"headless")
35 sm_husky_barrel_search_1 = get_package_share_directory(
"sm_husky_barrel_search_1")
36 launch_dir = os.path.join(sm_husky_barrel_search_1,
"launch")
38 declare_use_simulator_cmd = DeclareLaunchArgument(
39 "use_simulator", default_value=
"True", description=
"Whether to start the simulator"
42 declare_headless_simulator_argument = DeclareLaunchArgument(
43 "headless", default_value=
"False", description=
"Whether to execute gzclient)"
46 declare_world_cmd = DeclareLaunchArgument(
48 default_value=os.path.join(sm_husky_barrel_search_1,
"worlds",
"industrial_sim.world"),
49 description=
"Full path to world model file to load",
53 declare_world_cmd_2 = DeclareLaunchArgument(
55 default_value=os.path.join(sm_husky_barrel_search_1,
"worlds",
"industrial_sim.world"),
56 description=
"Full path to world model file to load",
59 declare_urdf = DeclareLaunchArgument(
61 default_value=os.path.join(
62 sm_husky_barrel_search_1,
"models",
"husky_turtlebot3_waffle",
"model.sdf"
68 ld = LaunchDescription()
71 "xterm -xrm 'XTerm*scrollBar: true' -xrm 'xterm*rightScrollBar: true' "
72 "-hold -geometry 1000x600 -sl 10000 -e"
75 gzenv = dict(os.environ)
76 model_database_uri = os.environ[
"GAZEBO_MODEL_PATH"]
77 gzenv[
"GAZEBO_MODEL_DATABASE_URI"] = model_database_uri
80 start_gazebo_server_cmd = ExecuteProcess(
81 condition=IfCondition(use_simulator),
85 "libgazebo_ros_init.so",
87 "libgazebo_ros_factory.so",
97 start_gazebo_client_cmd = ExecuteProcess(
98 condition=IfCondition(PythonExpression([use_simulator,
" and not ", headless])),
105 spawn_entity_node = Node(
106 package=
"gazebo_ros",
107 executable=
"spawn_entity.py",
113 LaunchConfiguration(
"urdf"),
126 ld.add_action(declare_headless_simulator_argument)
127 ld.add_action(declare_use_simulator_cmd)
128 ld.add_action(declare_world_cmd)
129 ld.add_action(declare_world_cmd_2)
130 ld.add_action(declare_urdf)
132 ld.add_action(start_gazebo_server_cmd)
133 ld.add_action(start_gazebo_client_cmd)
134 ld.add_action(spawn_entity_node)
def generate_launch_description()