Nav2 Navigation Stack - jazzy  jazzy
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 
19 from launch import LaunchDescription
20 from launch.actions import DeclareLaunchArgument
21 from launch.substitutions import LaunchConfiguration
22 from launch_ros.actions import Node
23 
24 
25 def generate_launch_description():
26  bringup_dir = get_package_share_directory('nav2_bringup')
27  params_file = LaunchConfiguration('params_file')
28  declare_params_file_cmd = DeclareLaunchArgument(
29  'params_file',
30  default_value=os.path.join(bringup_dir, 'params', 'nav2_params.yaml'),
31  description='Full path to the ROS2 parameters file to use for all launched nodes',
32  )
33 
34  scan_frame_id = LaunchConfiguration('scan_frame_id')
35  declare_scan_frame_id_cmd = DeclareLaunchArgument(
36  'scan_frame_id',
37  default_value='base_scan',
38  )
39 
40  loopback_sim_cmd = Node(
41  package='nav2_loopback_sim',
42  executable='loopback_simulator',
43  name='loopback_simulator',
44  output='screen',
45  parameters=[params_file, {'scan_frame_id': scan_frame_id}],
46  )
47 
48  ld = LaunchDescription()
49  ld.add_action(declare_scan_frame_id_cmd)
50  ld.add_action(declare_params_file_cmd)
51  ld.add_action(loopback_sim_cmd)
52  return ld