Nav2 Navigation Stack - lyrical  lyrical
ROS 2 Navigation Stack
dual_ekf_navsat.launch.py
1 # Copyright 2018 Open Source Robotics Foundation, Inc.
2 # Licensed under the Apache License, Version 2.0 (the "License");
3 # you may not use this file except in compliance with the License.
4 # You may obtain a copy of the License at
5 #
6 # http://www.apache.org/licenses/LICENSE-2.0
7 #
8 # Unless required by applicable law or agreed to in writing, software
9 # distributed under the License is distributed on an "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 # See the License for the specific language governing permissions and
12 # limitations under the License.
13 
14 import os
15 
16 from launch import LaunchDescription
17 import launch.actions
18 import launch_ros.actions
19 
20 
21 def generate_launch_description() -> LaunchDescription:
22  launch_dir = os.path.dirname(os.path.realpath(__file__))
23  params_file = os.path.join(launch_dir, 'dual_ekf_navsat_params.yaml')
24  os.environ['FILE_PATH'] = str(launch_dir)
25 
26  # robot_localization nodes are lifecycle nodes on Rolling/Lyrical and newer
27  ros_distro = os.environ.get('ROS_DISTRO', '')
28  use_lifecycle = ros_distro not in ('jazzy', 'kilted')
29 
30  lifecycle_nodes = [
31  'ekf_filter_node_odom',
32  'ekf_filter_node_map',
33  ]
34 
35  nodes = [
36  launch.actions.DeclareLaunchArgument(
37  'output_final_position', default_value='false'
38  ),
39  launch.actions.DeclareLaunchArgument(
40  'output_location', default_value='~/dual_ekf_navsat_example_debug.txt'
41  ),
42  launch_ros.actions.Node(
43  package='robot_localization',
44  executable='ekf_node',
45  name='ekf_filter_node_odom',
46  output='screen',
47  parameters=[params_file, {'use_sim_time': True}],
48  remappings=[('odometry/filtered', 'odometry/local')],
49  ),
50  launch_ros.actions.Node(
51  package='robot_localization',
52  executable='ekf_node',
53  name='ekf_filter_node_map',
54  output='screen',
55  parameters=[params_file, {'use_sim_time': True}],
56  remappings=[('odometry/filtered', 'odometry/global')],
57  ),
58  launch_ros.actions.Node(
59  package='robot_localization',
60  executable='navsat_transform_node',
61  name='navsat_transform',
62  output='screen',
63  parameters=[params_file, {'use_sim_time': True}],
64  remappings=[
65  ('imu/data', 'imu/data'),
66  ('gps/fix', 'gps/fix'),
67  ('gps/filtered', 'gps/filtered'),
68  ('odometry/gps', 'odometry/gps'),
69  ('odometry/filtered', 'odometry/global'),
70  ],
71  ),
72  ]
73 
74  if use_lifecycle:
75  nodes.append(
76  launch_ros.actions.Node(
77  package='nav2_lifecycle_manager',
78  executable='lifecycle_manager',
79  name='lifecycle_manager_localization',
80  output='screen',
81  parameters=[
82  {'use_sim_time': True},
83  {'autostart': True},
84  {'bond_timeout': 0.0},
85  {'node_names': lifecycle_nodes},
86  ],
87  ),
88  )
89 
90  return LaunchDescription(nodes)