17from ament_index_python.packages
import get_package_share_directory
19from launch
import LaunchDescription
20from launch.actions
import DeclareLaunchArgument, SetEnvironmentVariable
21from launch.substitutions
import LaunchConfiguration
22from launch_ros.actions
import Node
23from nav2_common.launch
import RewrittenYaml
28 sm_dance_bot_dir = get_package_share_directory(
"sm_dance_bot")
30 namespace = LaunchConfiguration(
"namespace")
31 use_sim_time = LaunchConfiguration(
"use_sim_time")
32 autostart = LaunchConfiguration(
"autostart")
33 params_file = LaunchConfiguration(
"params_file")
34 default_nav_to_pose_bt_xml = LaunchConfiguration(
"default_nav_to_pose_bt_xml")
35 map_subscribe_transient_local = LaunchConfiguration(
"map_subscribe_transient_local")
37 lifecycle_nodes = [
"controller_server",
"planner_server",
"recoveries_server",
"bt_navigator"]
45 remappings = [(
"/tf",
"tf"), (
"/tf_static",
"tf_static")]
48 param_substitutions = {
49 "use_sim_time": use_sim_time,
51 "default_nav_to_pose_bt_xml": os.path.join(
52 sm_dance_bot_dir,
"params",
"nav2z_client",
"navigation_tree.xml"
54 "autostart": autostart,
55 "map_subscribe_transient_local": map_subscribe_transient_local,
58 configured_params = RewrittenYaml(
59 source_file=params_file,
61 param_rewrites=param_substitutions,
65 xtermprefix =
"xterm -xrm 'XTerm*scrollBar: true' -xrm 'xterm*rightScrollBar: true' -hold -geometry 1000x600 -sl 10000 -e"
67 print(
"+********************************")
68 print(str(param_substitutions))
69 print(str(default_nav_to_pose_bt_xml))
71 return LaunchDescription(
74 SetEnvironmentVariable(
"RCUTILS_LOGGING_BUFFERED_STREAM",
"1"),
75 DeclareLaunchArgument(
76 "namespace", default_value=
"", description=
"Top-level namespace"
78 DeclareLaunchArgument(
80 default_value=
"false",
81 description=
"Use simulation (Gazebo) clock if true",
83 DeclareLaunchArgument(
86 description=
"Automatically startup the nav2 stack",
88 DeclareLaunchArgument(
90 default_value=os.path.join(
91 sm_dance_bot_dir,
"params",
"nav2z_client",
"nav2_params.yaml"
93 description=
"Full path to the ROS2 parameters file to use",
95 DeclareLaunchArgument(
96 "default_nav_to_pose_bt_xml",
98 default_value=os.path.join(
99 sm_dance_bot_dir,
"params",
"nav2z_client",
"navigation_tree.xml"
101 description=
"Full path to the behavior tree xml file to use",
103 DeclareLaunchArgument(
104 "map_subscribe_transient_local",
105 default_value=
"false",
106 description=
"Whether to set the map subscriber QoS to transient local",
109 package=
"nav2_controller",
110 executable=
"controller_server",
113 parameters=[configured_params],
114 remappings=remappings,
115 arguments=[
"--ros-args",
"--log-level",
"INFO"],
118 package=
"nav2_planner",
119 executable=
"planner_server",
120 name=
"planner_server",
123 parameters=[configured_params],
124 remappings=remappings,
125 arguments=[
"--ros-args",
"--log-level",
"INFO"],
128 package=
"nav2_recoveries",
129 executable=
"recoveries_server",
130 name=
"recoveries_server",
132 parameters=[configured_params],
133 remappings=remappings,
134 arguments=[
"--ros-args",
"--log-level",
"INFO"],
137 package=
"nav2_bt_navigator",
138 executable=
"bt_navigator",
142 parameters=[configured_params],
143 remappings=remappings,
144 arguments=[
"--ros-args",
"--log-level",
"INFO"],
147 package=
"nav2_waypoint_follower",
148 executable=
"waypoint_follower",
149 name=
"waypoint_follower",
151 parameters=[configured_params],
152 remappings=remappings,
155 package=
"nav2_lifecycle_manager",
156 executable=
"lifecycle_manager",
157 name=
"lifecycle_manager_navigation",
161 {
"use_sim_time": use_sim_time},
162 {
"autostart": autostart},
163 {
"node_names": lifecycle_nodes},
165 arguments=[
"--ros-args",
"--log-level",
"INFO"],
def generate_launch_description()