Nav2 Navigation Stack - rolling  main
ROS 2 Navigation Stack
loopback_simulation.launch.py
1 # Copyright (c) 2024 Open Navigation LLC
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 
15 import os
16 
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 Node
22 
23 
24 def generate_launch_description() -> LaunchDescription:
25  bringup_dir = get_package_share_directory('nav2_bringup')
26  params_file = LaunchConfiguration('params_file')
27  declare_params_file_cmd = DeclareLaunchArgument(
28  'params_file',
29  default_value=os.path.join(bringup_dir, 'params', 'nav2_params.yaml'),
30  description='Full path to the ROS2 parameters file to use for all launched nodes',
31  )
32 
33  scan_frame_id = LaunchConfiguration('scan_frame_id')
34  declare_scan_frame_id_cmd = DeclareLaunchArgument(
35  'scan_frame_id',
36  default_value='base_scan',
37  )
38 
39  loopback_sim_cmd = Node(
40  package='nav2_loopback_sim',
41  executable='loopback_simulator',
42  name='loopback_simulator',
43  output='screen',
44  parameters=[params_file, {'scan_frame_id': scan_frame_id}],
45  )
46 
47  ld = LaunchDescription()
48  ld.add_action(declare_scan_frame_id_cmd)
49  ld.add_action(declare_params_file_cmd)
50  ld.add_action(loopback_sim_cmd)
51  return ld