15"""This is all-in-one launch script intended for use by nav2 developers."""
19from ament_index_python.packages
import get_package_share_directory
21from launch
import LaunchDescription
22from launch.actions
import DeclareLaunchArgument, IncludeLaunchDescription
23from launch.conditions
import IfCondition
24from launch.launch_description_sources
import PythonLaunchDescriptionSource
25from launch.substitutions
import LaunchConfiguration
26from launch_ros.actions
import Node
31 sm_husky_barrel_search_1_dir = get_package_share_directory(
"sm_husky_barrel_search_1")
32 sm_husky_barrel_search_1_launch_dir = os.path.join(sm_husky_barrel_search_1_dir,
"launch")
36 namespace = LaunchConfiguration(
"namespace")
37 use_namespace = LaunchConfiguration(
"use_namespace")
38 map_yaml_file = LaunchConfiguration(
"map")
39 use_sim_time = LaunchConfiguration(
"use_sim_time")
40 params_file = LaunchConfiguration(
"params_file")
41 default_nav_to_pose_bt_xml = LaunchConfiguration(
"default_nav_to_pose_bt_xml")
42 autostart = LaunchConfiguration(
"autostart")
46 rviz_config_file = LaunchConfiguration(
"rviz_config_file")
48 use_robot_state_pub = LaunchConfiguration(
"use_robot_state_pub")
49 use_rviz = LaunchConfiguration(
"use_rviz")
52 urdf = os.path.join(sm_husky_barrel_search_1_dir,
"urdf",
"turtlebot3_waffle.urdf")
60 remappings = [(
"/tf",
"tf"), (
"/tf_static",
"tf_static")]
63 declare_namespace_cmd = DeclareLaunchArgument(
64 "namespace", default_value=
"", description=
"Top-level namespace"
67 declare_headless_simulator_argument = DeclareLaunchArgument(
68 "headless", default_value=
"False", description=
"Whether to execute gzclient)"
71 declare_use_namespace_cmd = DeclareLaunchArgument(
73 default_value=
"false",
74 description=
"Whether to apply a namespace to the navigation stack",
77 declare_show_gz_lidar = DeclareLaunchArgument(
80 description=
"Whether to apply a namespace to the navigation stack",
87 declare_use_sim_time_cmd = DeclareLaunchArgument(
88 "use_sim_time", default_value=
"true", description=
"Use simulation (Gazebo) clock if true"
91 declare_params_file_cmd = DeclareLaunchArgument(
93 default_value=os.path.join(
94 sm_husky_barrel_search_1_dir,
"params",
"nav2z_client",
"nav2_params.yaml"
96 description=
"Full path to the ROS2 parameters file to use for all launched nodes",
99 declare_bt_xml_cmd = DeclareLaunchArgument(
100 "default_nav_to_pose_bt_xml",
101 default_value=os.path.join(
102 sm_husky_barrel_search_1_dir,
"params",
"nav2z_client",
"navigation_tree.xml"
104 description=
"Full path to the behavior tree xml file to use",
107 declare_autostart_cmd = DeclareLaunchArgument(
108 "autostart", default_value=
"true", description=
"Automatically startup the nav2 stack"
111 declare_rviz_config_file_cmd = DeclareLaunchArgument(
113 default_value=os.path.join(sm_husky_barrel_search_1_dir,
"rviz",
"nav2_default_view.rviz"),
114 description=
"Full path to the RVIZ config file to use",
117 declare_use_robot_state_pub_cmd = DeclareLaunchArgument(
118 "use_robot_state_pub",
119 default_value=
"True",
120 description=
"Whether to start the robot state publisher",
123 declare_use_rviz_cmd = DeclareLaunchArgument(
124 "use_rviz", default_value=
"True", description=
"Whether to start RVIZ"
127 declare_map_yaml_cmd = DeclareLaunchArgument(
129 default_value=os.path.join(sm_husky_barrel_search_1_dir,
"maps",
"turtlebot3_world.yaml"),
130 description=
"Full path to map file to load",
133 start_robot_state_publisher_cmd = Node(
134 condition=IfCondition(use_robot_state_pub),
135 package=
"robot_state_publisher",
136 executable=
"robot_state_publisher",
137 name=
"robot_state_publisher",
140 parameters=[{
"use_sim_time": use_sim_time}],
141 remappings=remappings,
145 rviz_cmd = IncludeLaunchDescription(
146 PythonLaunchDescriptionSource(
147 os.path.join(sm_husky_barrel_search_1_launch_dir,
"rviz_launch.py")
149 condition=IfCondition(use_rviz),
152 "use_namespace":
"False",
153 "rviz_config": rviz_config_file,
157 bringup_cmd = IncludeLaunchDescription(
158 PythonLaunchDescriptionSource(
159 os.path.join(sm_husky_barrel_search_1_launch_dir,
"bringup_launch.py")
162 "namespace": namespace,
163 "use_namespace": use_namespace,
164 "autostart": autostart,
165 "params_file": params_file,
167 "map": map_yaml_file,
168 "use_sim_time": use_sim_time,
169 "default_nav_to_pose_bt_xml": default_nav_to_pose_bt_xml,
173 ekf_gps_localization = IncludeLaunchDescription(
174 PythonLaunchDescriptionSource(
175 os.path.join(sm_husky_barrel_search_1_launch_dir,
"ekf_gps_launch.py")
178 "namespace": namespace,
179 "use_namespace": use_namespace,
180 "autostart": autostart,
181 "params_file": params_file,
183 "map": map_yaml_file,
184 "use_sim_time": use_sim_time,
185 "default_nav_to_pose_bt_xml": default_nav_to_pose_bt_xml,
189 gazebo_simulator = IncludeLaunchDescription(
190 PythonLaunchDescriptionSource(
191 os.path.join(sm_husky_barrel_search_1_launch_dir,
"gazebo_launch.py")
194 "world": os.path.join(
195 sm_husky_barrel_search_1_dir,
"worlds",
"barrel_valley.world.sdf"
207 xtermprefix =
"xterm -xrm 'XTerm*scrollBar: true' -xrm 'xterm*rightScrollBar: true' -hold -geometry 1000x600 -sl 10000 -e"
209 sm_husky_barrel_search_1_node = Node(
210 package=
"sm_husky_barrel_search_1",
211 executable=
"sm_husky_barrel_search_1_node",
212 name=
"SmHuskyBarrelSearch1",
217 get_package_share_directory(
"sm_husky_barrel_search_1"),
218 "params/sm_husky_barrel_search_1_config.yaml",
221 get_package_share_directory(
"sm_husky_barrel_search_1"),
222 "params/nav2z_client/odom_tracker.yaml",
230 arguments=[
"--ros-args",
"--log-level",
"INFO"],
258 ld = LaunchDescription()
261 ld.add_action(declare_namespace_cmd)
262 ld.add_action(declare_use_namespace_cmd)
264 ld.add_action(declare_use_sim_time_cmd)
265 ld.add_action(declare_params_file_cmd)
266 ld.add_action(declare_bt_xml_cmd)
267 ld.add_action(declare_autostart_cmd)
268 ld.add_action(declare_map_yaml_cmd)
269 ld.add_action(declare_show_gz_lidar)
270 ld.add_action(declare_headless_simulator_argument)
272 ld.add_action(declare_rviz_config_file_cmd)
273 ld.add_action(declare_use_robot_state_pub_cmd)
274 ld.add_action(declare_use_rviz_cmd)
275 ld.add_action(gazebo_simulator)
279 ld.add_action(sm_husky_barrel_search_1_node)
285 ld.add_action(start_robot_state_publisher_cmd)
286 ld.add_action(rviz_cmd)
287 ld.add_action(bringup_cmd)
288 ld.add_action(ekf_gps_localization)
def generate_launch_description()