17 from ament_index_python.packages
import get_package_share_directory
18 from launch
import LaunchDescription
19 from launch.actions
import DeclareLaunchArgument
20 from launch.substitutions
import LaunchConfiguration
21 from launch_ros.actions
import LifecycleNode
22 from launch_ros.descriptions
import ParameterFile
26 def generate_launch_description() -> LaunchDescription:
27 bringup_dir = get_package_share_directory(
'nav2_bringup')
28 namespace = LaunchConfiguration(
'namespace')
29 declare_namespace_cmd = DeclareLaunchArgument(
32 description=
'Top-level namespace',
35 params_file = LaunchConfiguration(
'params_file')
36 declare_params_file_cmd = DeclareLaunchArgument(
38 default_value=os.path.join(bringup_dir,
'params',
'nav2_params.yaml'),
39 description=
'Full path to the ROS2 parameters file to use for all launched nodes',
42 scan_frame_id = LaunchConfiguration(
'scan_frame_id')
43 declare_scan_frame_id_cmd = DeclareLaunchArgument(
45 default_value=
'base_scan',
48 remappings = [(
'/tf',
'tf'), (
'/tf_static',
'tf_static')]
50 configured_params = ParameterFile(
52 source_file=params_file,
60 loopback_sim_cmd = LifecycleNode(
61 package=
'nav2_loopback_sim',
62 executable=
'loopback_simulator',
63 name=
'loopback_simulator',
69 {
'scan_frame_id': scan_frame_id,
'use_sim_time':
True},
71 remappings=remappings,
74 ld = LaunchDescription()
75 ld.add_action(declare_namespace_cmd)
76 ld.add_action(declare_scan_frame_id_cmd)
77 ld.add_action(declare_params_file_cmd)
78 ld.add_action(loopback_sim_cmd)