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 bringup_dir = get_package_share_directory(
"nav2_bringup")
30 namespace = LaunchConfiguration(
"namespace")
31 map_yaml_file = LaunchConfiguration(
"map")
32 use_sim_time = LaunchConfiguration(
"use_sim_time")
33 autostart = LaunchConfiguration(
"autostart")
34 params_file = LaunchConfiguration(
"params_file")
35 lifecycle_nodes = [
"map_server",
"amcl"]
43 remappings = [(
"/tf",
"tf"), (
"/tf_static",
"tf_static")]
46 param_substitutions = {
"use_sim_time": use_sim_time,
"yaml_filename": map_yaml_file}
48 configured_params = RewrittenYaml(
49 source_file=params_file,
51 param_rewrites=param_substitutions,
55 return LaunchDescription(
58 SetEnvironmentVariable(
"RCUTILS_LOGGING_BUFFERED_STREAM",
"1"),
59 DeclareLaunchArgument(
60 "namespace", default_value=
"", description=
"Top-level namespace"
62 DeclareLaunchArgument(
64 default_value=os.path.join(bringup_dir,
"maps",
"turtlebot3_world.yaml"),
65 description=
"Full path to map yaml file to load",
67 DeclareLaunchArgument(
69 default_value=
"false",
70 description=
"Use simulation (Gazebo) clock if true",
72 DeclareLaunchArgument(
75 description=
"Automatically startup the nav2 stack",
77 DeclareLaunchArgument(
79 default_value=os.path.join(bringup_dir,
"params",
"nav2_params.yaml"),
80 description=
"Full path to the ROS2 parameters file to use",
83 package=
"nav2_map_server",
84 executable=
"map_server",
87 parameters=[configured_params],
88 remappings=remappings,
95 parameters=[configured_params],
96 remappings=remappings,
99 package=
"nav2_lifecycle_manager",
100 executable=
"lifecycle_manager",
101 name=
"lifecycle_manager_localization",
104 {
"use_sim_time": use_sim_time},
105 {
"autostart": autostart},
106 {
"node_names": lifecycle_nodes},
def generate_launch_description()