17from ament_index_python.packages
import get_package_share_directory
19from launch
import LaunchDescription
20from launch.actions
import (
21 DeclareLaunchArgument,
23 IncludeLaunchDescription,
24 SetEnvironmentVariable,
28from launch.launch_description_sources
import PythonLaunchDescriptionSource
30from launch.substitutions
import LaunchConfiguration
37 sm_husky_barrel_search_1 = get_package_share_directory(
"sm_husky_barrel_search_1")
38 launch_dir = os.path.join(sm_husky_barrel_search_1,
"launch")
41 namespace = LaunchConfiguration(
"namespace")
45 use_sim_time = LaunchConfiguration(
"use_sim_time")
46 params_file = LaunchConfiguration(
"params_file")
47 default_nav_to_pose_bt_xml = LaunchConfiguration(
"default_nav_to_pose_bt_xml")
48 autostart = LaunchConfiguration(
"autostart")
50 stdout_linebuf_envvar = SetEnvironmentVariable(
"RCUTILS_LOGGING_BUFFERED_STREAM",
"1")
52 declare_namespace_cmd = DeclareLaunchArgument(
53 "namespace", default_value=
"", description=
"Top-level namespace"
56 declare_use_namespace_cmd = DeclareLaunchArgument(
58 default_value=
"false",
59 description=
"Whether to apply a namespace to the navigation stack",
62 declare_slam_cmd = DeclareLaunchArgument(
63 "slam", default_value=
"False", description=
"Whether run a SLAM"
66 declare_map_yaml_cmd = DeclareLaunchArgument(
67 "map", description=
"Full path to map yaml file to load"
70 declare_use_sim_time_cmd = DeclareLaunchArgument(
71 "use_sim_time", default_value=
"false", description=
"Use simulation (Gazebo) clock if true"
74 declare_params_file_cmd = DeclareLaunchArgument(
76 default_value=os.path.join(
77 sm_husky_barrel_search_1,
"params",
"nav2z_client",
"nav2_params.yaml"
79 description=
"Full path to the ROS2 parameters file to use for all launched nodes",
82 declare_bt_xml_cmd = DeclareLaunchArgument(
83 "default_nav_to_pose_bt_xml",
84 default_value=os.path.join(
85 sm_husky_barrel_search_1,
"params",
"nav2z_client",
"navigation_tree.xml"
87 description=
"Full path to the behavior tree xml file to use",
90 declare_autostart_cmd = DeclareLaunchArgument(
91 "autostart", default_value=
"true", description=
"Automatically startup the nav2 stack"
95 bringup_cmd_group = GroupAction(
97 IncludeLaunchDescription(
98 PythonLaunchDescriptionSource(os.path.join(launch_dir,
"navigation_launch.py")),
100 "namespace": namespace,
101 "use_sim_time": use_sim_time,
102 "autostart": autostart,
103 "params_file": params_file,
104 "default_nav_to_pose_bt_xml": default_nav_to_pose_bt_xml,
105 "use_lifecycle_mgr":
"false",
106 "map_subscribe_transient_local":
"true",
113 ld = LaunchDescription()
116 ld.add_action(stdout_linebuf_envvar)
119 ld.add_action(declare_namespace_cmd)
120 ld.add_action(declare_use_namespace_cmd)
121 ld.add_action(declare_slam_cmd)
122 ld.add_action(declare_map_yaml_cmd)
123 ld.add_action(declare_use_sim_time_cmd)
124 ld.add_action(declare_params_file_cmd)
125 ld.add_action(declare_autostart_cmd)
126 ld.add_action(declare_bt_xml_cmd)
129 ld.add_action(bringup_cmd_group)
def generate_launch_description()