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