SMACC2
slam_launch.py
Go to the documentation of this file.
1# Copyright (c) 2020 Samsung Research Russia
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
15import os
16
17from ament_index_python.packages import get_package_share_directory
18
19from launch import LaunchDescription
20from launch.actions import DeclareLaunchArgument, IncludeLaunchDescription
21from launch.launch_description_sources import PythonLaunchDescriptionSource
22from launch.substitutions import LaunchConfiguration
23
24# from launch_ros.actions import Node
25# from nav2_common.launch import RewrittenYaml
26
27
29 # Input parameters declaration
30 # namespace = LaunchConfiguration("namespace")
31 # params_file = LaunchConfiguration("params_file")
32 use_sim_time = LaunchConfiguration("use_sim_time")
33 # autostart = LaunchConfiguration("autostart")
34 # sm_dance_bot_strikes_back_dir = get_package_share_directory("sm_dance_bot_strikes_back")
35
36 # Variables
37 # lifecycle_nodes = ["slam_toolbox"]
38
39 # Getting directories and launch-files
40 # bringup_dir = get_package_share_directory("nav2_bringup")
41 sm_aws_warehouse_navigation_dir = get_package_share_directory("sm_aws_warehouse_navigation")
42 # slam_launch_file = os.path.join(sm_dance_bot_strikes_back_dir, 'launch', 'online_sync_launch.py')
43 slam_launch_file = os.path.join(
44 sm_aws_warehouse_navigation_dir, "launch", "online_sync_launch.py"
45 )
46
47 # Create our own temporary YAML files that include substitutions
48 # param_substitutions = {"use_sim_time": use_sim_time}
49
50 # configured_params = RewrittenYaml(
51 # source_file=params_file,
52 # root_key=namespace,
53 # param_rewrites=param_substitutions,
54 # convert_types=True,
55 # )
56
57 # Declare the launch arguments
58 declare_namespace_cmd = DeclareLaunchArgument(
59 "namespace", default_value="", description="Top-level namespace"
60 )
61
62 # declare_params_file_cmd = DeclareLaunchArgument(
63 # 'params_file',
64 # default_value=os.path.join(bringup_dir, 'params', 'nav2_params.yaml'),
65 # description='Full path to the ROS2 parameters file to use for all launched nodes')
66
67 declare_use_sim_time_cmd = DeclareLaunchArgument(
68 "use_sim_time", default_value="True", description="Use simulation (Gazebo) clock if true"
69 )
70
71 declare_autostart_cmd = DeclareLaunchArgument(
72 "autostart", default_value="True", description="Automatically startup the nav2 stack"
73 )
74
75 # Nodes launching commands
76
77 # start_map_saver_server_cmd = Node(
78 # package='nav2_map_server',
79 # executable='map_saver_server',
80 # output='screen',
81 # parameters=[configured_params])
82
83 # xtermprefix = "xterm -xrm 'XTerm*scrollBar: true' -xrm 'xterm*rightScrollBar: true' " \
84 # "-hold -geometry 1000x600 -sl 10000 -e"
85
86 # start_lifecycle_manager_cmd = Node(
87 # package="nav2_lifecycle_manager",
88 # executable="lifecycle_manager",
89 # name="lifecycle_manager_slam",
90 # output="screen",
91 # parameters=[
92 # {"use_sim_time": use_sim_time},
93 # {"autostart": autostart},
94 # {"node_names": lifecycle_nodes},
95 # ],
96 # prefix=xtermprefix,
97 # )
98
99 # If the provided param file doesn't have slam_toolbox params, we must remove the 'params_file'
100 # LaunchConfiguration, or it will be passed automatically to slam_toolbox and will not load
101 # the default file
102
103 start_slam_toolbox_cmd = IncludeLaunchDescription(
104 PythonLaunchDescriptionSource(slam_launch_file),
105 launch_arguments={"use_sim_time": use_sim_time}.items(),
106 )
107
108 # Pop (or load) previous LaunchConfiguration, resetting the state of params_file
109 # pop_launch_config = PopLaunchConfigurations(
110 # condition=UnlessCondition(has_slam_toolbox_params))
111
112 ld = LaunchDescription()
113
114 # Declare the launch options
115 ld.add_action(declare_namespace_cmd)
116 # ld.add_action(declare_params_file_cmd)
117 ld.add_action(declare_use_sim_time_cmd)
118 ld.add_action(declare_autostart_cmd)
119
120 # Running Map Saver Server
121 # ld.add_action(start_map_saver_server_cmd)
122 # ld.add_action(start_lifecycle_manager_cmd)
123
124 # Running SLAM Toolbox
125 # ld.add_action(push_launch_config)
126 # ld.add_action(remove_params_file)
127 ld.add_action(start_slam_toolbox_cmd)
128 # ld.add_action(pop_launch_config)
129
130 return ld
def generate_launch_description()
Definition: slam_launch.py:28