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, UnlessCondition
22from launch.substitutions
import LaunchConfiguration, PythonExpression
26 declare_use_simulator_cmd = DeclareLaunchArgument(
27 "use_simulator", default_value=
"False", description=
"Whether to execute gzclient)"
30 use_simulator = LaunchConfiguration(
"use_simulator")
31 world = LaunchConfiguration(
"world")
32 headless = LaunchConfiguration(
"headless")
33 show_gz_lidar = LaunchConfiguration(
"show_gz_lidar")
35 sm_dance_bot_dir = get_package_share_directory(
"sm_dance_bot")
36 launch_dir = os.path.join(sm_dance_bot_dir,
"launch")
38 declare_use_simulator_cmd = DeclareLaunchArgument(
39 "use_simulator", default_value=
"True", description=
"Whether to start the simulator"
42 declare_simulator_cmd = DeclareLaunchArgument(
43 "headless", default_value=
"False", description=
"Whether to execute gzclient)"
46 declare_show_gz_lidar = DeclareLaunchArgument(
49 description=
"Whether to apply a namespace to the navigation stack",
52 declare_world_cmd = DeclareLaunchArgument(
54 default_value=os.path.join(sm_dance_bot_dir,
"worlds",
"ridgeback_race.world"),
55 description=
"Full path to world model file to load",
56 condition=IfCondition(show_gz_lidar),
59 declare_world_cmd_2 = DeclareLaunchArgument(
61 default_value=os.path.join(sm_dance_bot_dir,
"worlds",
"ridgeback_race_no_lidar.world"),
62 description=
"Full path to world model file to load",
63 condition=UnlessCondition(show_gz_lidar),
67 ld = LaunchDescription()
72 gzenv = dict(os.environ)
73 model_database_uri = os.environ[
"GAZEBO_MODEL_PATH"]
74 gzenv[
"GAZEBO_MODEL_DATABASE_URI"] = model_database_uri
77 start_gazebo_server_cmd = ExecuteProcess(
78 condition=IfCondition(use_simulator),
79 cmd=[
"gzserver",
"-s",
"libgazebo_ros_init.so", world,
"--verbose"],
85 start_gazebo_client_cmd = ExecuteProcess(
86 condition=IfCondition(PythonExpression([use_simulator,
" and not ", headless])),
94 ld.add_action(declare_simulator_cmd)
95 ld.add_action(declare_use_simulator_cmd)
96 ld.add_action(declare_world_cmd)
97 ld.add_action(declare_world_cmd_2)
99 ld.add_action(declare_show_gz_lidar)
101 ld.add_action(start_gazebo_server_cmd)
102 ld.add_action(start_gazebo_client_cmd)
def generate_launch_description()