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_strikes_back_dir = get_package_share_directory(
"sm_dance_bot_strikes_back")
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_strikes_back_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_strikes_back_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",
99 default_value=os.path.join(
100 sm_dance_bot_strikes_back_dir,
103 "navigation_tree.xml",
105 description=
"Full path to the behavior tree xml file to use",
107 DeclareLaunchArgument(
108 "map_subscribe_transient_local",
109 default_value=
"false",
110 description=
"Whether to set the map subscriber QoS to transient local",
113 package=
"nav2_controller",
114 executable=
"controller_server",
117 parameters=[configured_params],
118 remappings=remappings,
119 arguments=[
"--ros-args",
"--log-level",
"INFO"],
122 package=
"nav2_planner",
123 executable=
"planner_server",
124 name=
"planner_server",
127 parameters=[configured_params],
128 remappings=remappings,
129 arguments=[
"--ros-args",
"--log-level",
"INFO"],
132 package=
"nav2_recoveries",
133 executable=
"recoveries_server",
134 name=
"recoveries_server",
136 parameters=[configured_params],
137 remappings=remappings,
138 arguments=[
"--ros-args",
"--log-level",
"INFO"],
141 package=
"nav2_bt_navigator",
142 executable=
"bt_navigator",
146 parameters=[configured_params],
147 remappings=remappings,
148 arguments=[
"--ros-args",
"--log-level",
"INFO"],
151 package=
"nav2_waypoint_follower",
152 executable=
"waypoint_follower",
153 name=
"waypoint_follower",
155 parameters=[configured_params],
156 remappings=remappings,
159 package=
"nav2_lifecycle_manager",
160 executable=
"lifecycle_manager",
161 name=
"lifecycle_manager_navigation",
165 {
"use_sim_time": use_sim_time},
166 {
"autostart": autostart},
167 {
"node_names": lifecycle_nodes},
169 arguments=[
"--ros-args",
"--log-level",
"INFO"],
def generate_launch_description()