SMACC2
Functions
localization_launch Namespace Reference

Functions

def generate_launch_description ()
 

Function Documentation

◆ generate_launch_description()

def localization_launch.generate_launch_description ( )

Definition at line 26 of file localization_launch.py.

27 # Get the launch directory
28 bringup_dir = get_package_share_directory("nav2_bringup")
29
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"]
36
37 # Map fully qualified names to relative ones so the node's namespace can be prepended.
38 # In case of the transforms (tf), currently, there doesn't seem to be a better alternative
39 # https://github.com/ros/geometry2/issues/32
40 # https://github.com/ros/robot_state_publisher/pull/30
41 # TODO(orduno) Substitute with `PushNodeRemapping`
42 # https://github.com/ros2/launch_ros/issues/56
43 remappings = [("/tf", "tf"), ("/tf_static", "tf_static")]
44
45 # Create our own temporary YAML files that include substitutions
46 param_substitutions = {"use_sim_time": use_sim_time, "yaml_filename": map_yaml_file}
47
48 configured_params = RewrittenYaml(
49 source_file=params_file,
50 root_key=namespace,
51 param_rewrites=param_substitutions,
52 convert_types=True,
53 )
54
55 return LaunchDescription(
56 [
57 # Set env var to print messages to stdout immediately
58 SetEnvironmentVariable("RCUTILS_LOGGING_BUFFERED_STREAM", "1"),
59 DeclareLaunchArgument(
60 "namespace", default_value="", description="Top-level namespace"
61 ),
62 DeclareLaunchArgument(
63 "map",
64 default_value=os.path.join(bringup_dir, "maps", "turtlebot3_world.yaml"),
65 description="Full path to map yaml file to load",
66 ),
67 DeclareLaunchArgument(
68 "use_sim_time",
69 default_value="false",
70 description="Use simulation (Gazebo) clock if true",
71 ),
72 DeclareLaunchArgument(
73 "autostart",
74 default_value="true",
75 description="Automatically startup the nav2 stack",
76 ),
77 DeclareLaunchArgument(
78 "params_file",
79 default_value=os.path.join(bringup_dir, "params", "nav2_params.yaml"),
80 description="Full path to the ROS2 parameters file to use",
81 ),
82 Node(
83 package="nav2_map_server",
84 executable="map_server",
85 name="map_server",
86 output="screen",
87 parameters=[configured_params],
88 remappings=remappings,
89 ),
90 Node(
91 package="nav2_amcl",
92 executable="amcl",
93 name="amcl",
94 output="screen",
95 parameters=[configured_params],
96 remappings=remappings,
97 ),
98 Node(
99 package="nav2_lifecycle_manager",
100 executable="lifecycle_manager",
101 name="lifecycle_manager_localization",
102 output="screen",
103 parameters=[
104 {"use_sim_time": use_sim_time},
105 {"autostart": autostart},
106 {"node_names": lifecycle_nodes},
107 ],
108 ),
109 ]
110 )