Nav2 Navigation Stack - kilted  kilted
ROS 2 Navigation Stack
planning_benchmark_bringup.py
1 # Copyright (c) 2022 Samsung Research America
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 IncludeLaunchDescription
20 from launch.launch_description_sources import PythonLaunchDescriptionSource
21 from launch_ros.actions import Node
22 
23 
24 def generate_launch_description() -> LaunchDescription:
25  nav2_bringup_dir = get_package_share_directory('nav2_bringup')
26  config = os.path.join(
27  get_package_share_directory('nav2_bringup'), 'params', 'nav2_params.yaml'
28  )
29  map_file = os.path.join(nav2_bringup_dir, 'maps', 'tb3_sandbox.yaml')
30  lifecycle_nodes = ['map_server', 'planner_server']
31 
32  return LaunchDescription(
33  [
34  Node(
35  package='nav2_map_server',
36  executable='map_server',
37  name='map_server',
38  output='screen',
39  parameters=[
40  {'use_sim_time': True},
41  {'yaml_filename': map_file},
42  {'topic_name': 'map'},
43  ],
44  ),
45  Node(
46  package='nav2_planner',
47  executable='planner_server',
48  name='planner_server',
49  output='screen',
50  parameters=[config],
51  ),
52  Node(
53  package='tf2_ros',
54  executable='static_transform_publisher',
55  output='screen',
56  arguments=[
57  '--x', '0',
58  '--y', '0',
59  '--z', '0',
60  '--roll', '0',
61  '--pitch', '0',
62  '--yaw', '0',
63  '--frame-id', 'base_link',
64  '--child-frame-id', 'map'
65  ],
66  ),
67  Node(
68  package='tf2_ros',
69  executable='static_transform_publisher',
70  output='screen',
71  arguments=[
72  '--x', '0',
73  '--y', '0',
74  '--z', '0',
75  '--roll', '0',
76  '--pitch', '0',
77  '--yaw', '0',
78  '--frame-id', 'base_link',
79  '--child-frame-id', 'odom'
80  ],
81  ),
82  Node(
83  package='nav2_lifecycle_manager',
84  executable='lifecycle_manager',
85  name='lifecycle_manager',
86  output='screen',
87  parameters=[
88  {'use_sim_time': True},
89  {'autostart': True},
90  {'node_names': lifecycle_nodes},
91  ],
92  ),
93  IncludeLaunchDescription(
94  PythonLaunchDescriptionSource(
95  os.path.join(nav2_bringup_dir, 'launch', 'rviz_launch.py')
96  ),
97  launch_arguments={'namespace': ''}.items(),
98  ),
99  ]
100  )