Carma-platform v4.11.0
CARMA Platform is built on robot operating system (ROS) and utilizes open source software (OSS) that enables Cooperative Driving Automation (CDA) features to allow Automated Driving Systems to interact and cooperate with infrastructure and other vehicles through communication.
carma_src.launch.py
Go to the documentation of this file.
1# Copyright (C) 2021-2023 LEIDOS.
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
15from ament_index_python import get_package_share_directory
16import launch
17from launch.actions import Shutdown
18from launch import LaunchDescription
19from launch_ros.actions import Node
20from launch.actions import IncludeLaunchDescription
21from launch.launch_description_sources import PythonLaunchDescriptionSource
22from launch.substitutions import ThisLaunchFileDir
23from launch.substitutions import EnvironmentVariable
24from launch.actions import GroupAction
25from launch.conditions import IfCondition
26from launch_ros.actions import PushRosNamespace
27from carma_ros2_utils.launch.get_log_level import GetLogLevel
28from launch.substitutions import LaunchConfiguration, PythonExpression
29from launch.actions import DeclareLaunchArgument
30from launch.actions import OpaqueFunction
31
32from tracetools_launch.action import Trace
33
34from datetime import datetime
35
36import os
37
38from launch import LaunchDescription, LaunchContext
39
40
41def create_ros2_tracing_action(context, *args, **kwargs):
42 """
43 Opaque Function for generating a 'Trace' ROS 2 launch action, which is dependent on the
44 'ROS_LOG_DIR' EnvironmentVariable and the 'is_ros2_tracing_enabled' LaunchConfiguration.
45
46 NOTE: This Opaque Function is required in order to evaluate the 'ROS_LOG_DIR' environment
47 variable as a string.
48 """
49 log_directory_string = launch.substitutions.EnvironmentVariable('ROS_LOG_DIR').perform(context)
50
51 trace = GroupAction(
52 condition=IfCondition(LaunchConfiguration('is_ros2_tracing_enabled')),
53 actions=[
54 Trace(
55 base_path = log_directory_string,
56 session_name='my-tracing-session-' + str(datetime.now().strftime('%Y-%m-%d_%H%M%S')),
57 events_kernel = [], # Empty since kernel tracing is not enabled for CARMA Platform
58 )
59 ]
60 )
61
62 return [trace]
63
64
66 """
67 Launch CARMA System.
68 """
69
70 system_controller_param_file = os.path.join(
71 get_package_share_directory('system_controller'), 'config/config.yaml')
72
73 # Log level is set from CARMA_ROS_LOGGING_CONFIG, generated from carma_rosconsole.conf in the vehicle config dir (carma-config)
74 env_log_levels = EnvironmentVariable('CARMA_ROS_LOGGING_CONFIG', default_value='{ "default_level" : "WARN" }')
75
76 # Declare the vehicle_calibration_dir launch argument
77 vehicle_calibration_dir = LaunchConfiguration('vehicle_calibration_dir')
78 declare_vehicle_calibration_dir_arg = DeclareLaunchArgument(
79 name = 'vehicle_calibration_dir',
80 default_value = "/opt/carma/vehicle/calibration",
81 description = "Path to folder containing vehicle calibration directories"
82 )
83
84 vehicle_config_dir = LaunchConfiguration('vehicle_config_dir')
85 declare_vehicle_config_dir_arg = DeclareLaunchArgument(
86 name = 'vehicle_config_dir',
87 default_value = "/opt/carma/vehicle/config",
88 description = "Path to vehicle configuration directory populated by carma-config"
89 )
90
91 vehicle_characteristics_param_file = LaunchConfiguration('vehicle_characteristics_param_file')
92 declare_vehicle_characteristics_param_file_arg = DeclareLaunchArgument(
93 name = 'vehicle_characteristics_param_file',
94 default_value = [vehicle_calibration_dir, "/identifiers/UniqueVehicleParams.yaml"],
95 description = "Path to file containing unique vehicle characteristics"
96 )
97
98 # Declare the vehicle_config_param_file launch argument
99 vehicle_config_param_file = LaunchConfiguration('vehicle_config_param_file')
100 declare_vehicle_config_param_file_arg = DeclareLaunchArgument(
101 name = 'vehicle_config_param_file',
102 default_value = [vehicle_config_dir, "/VehicleConfigParams.yaml"],
103 description = "Path to file contain vehicle configuration parameters"
104 )
105
106 # Declare the global_params_override_file launch argument
107 # Parameters in this file will override any parameters loaded in their respective packages
108 global_params_override_file = LaunchConfiguration('global_params_override_file')
109 declare_global_params_override_file_arg = DeclareLaunchArgument(
110 name = 'global_params_override_file',
111 default_value = [vehicle_config_dir, "/GlobalParamsOverride.yaml"],
112 description = "Path to global file containing the parameters overwrite"
113 )
114
115 use_sim_time = LaunchConfiguration('use_sim_time')
116 declare_use_sim_time_arg = DeclareLaunchArgument(
117 name = 'use_sim_time',
118 default_value = 'False',
119 description = "True of simulation mode is on"
120 )
121
122 use_real_time_spat_in_sim = LaunchConfiguration('use_real_time_spat_in_sim')
123 declare_use_real_time_spat_in_sim_arg = DeclareLaunchArgument(
124 name = 'use_real_time_spat_in_sim',
125 default_value = 'False',
126 description = "True if SPaT is being published based on wall clock"
127 )
128
129 #Declare the route file folder launch argument
130 route_file_folder = LaunchConfiguration('route_file_folder')
131 declare_route_file_folder = DeclareLaunchArgument(
132 name = 'route_file_folder',
133 default_value='/opt/carma/routes/',
134 description = 'Path of folder containing routes to load'
135 )
136
137 # Declare enable_guidance_plugin_validate
138 enable_guidance_plugin_validator = LaunchConfiguration('enable_guidance_plugin_validator')
139 declare_enable_guidance_plugin_validator = DeclareLaunchArgument(
140 name = 'enable_guidance_plugin_validator',
141 default_value='false',
142 description='Flag indicating whether the Guidance Plugin Validator node will actively validate guidance strategic, tactical, and control plugins'
143 )
144
145 # Declare strategic_plugins_to_validate
146 strategic_plugins_to_validate = LaunchConfiguration('strategic_plugins_to_validate')
147 declare_strategic_plugins_to_validate = DeclareLaunchArgument(
148 name = 'strategic_plugins_to_validate',
149 default_value = '[]',
150 description = 'List of String: Guidance Strategic Plugins that will be validated by the Guidance Plugin Validator Node if enabled'
151 )
152
153 # Declare tactical_plugins_to_validate
154 tactical_plugins_to_validate = LaunchConfiguration('tactical_plugins_to_validate')
155 declare_tactical_plugins_to_validate = DeclareLaunchArgument(
156 name = 'tactical_plugins_to_validate',
157 default_value='[]',
158 description='List of String: Guidance Tactical Plugins that will be validated by the Guidance Plugin Validator Node if enabled'
159 )
160
161 # Declare control_plugins_to_validate
162 control_plugins_to_validate = LaunchConfiguration('control_plugins_to_validate')
163 declare_control_plugins_to_validate = DeclareLaunchArgument(
164 name = 'control_plugins_to_validate',
165 default_value= '[]',
166 description='List of String: Guidance Control Plugins that will be validated by the Guidance Plugin Validator Node if enabled'
167 )
168
169 # Declare enable_opening_tunnels
170 enable_opening_tunnels = LaunchConfiguration('enable_opening_tunnels')
171 declare_enable_opening_tunnels = DeclareLaunchArgument(
172 name = 'enable_opening_tunnels',
173 default_value= 'False',
174 description='Flag to enable opening http tunnesl to CARMA Cloud'
175 )
176
177 # Declare port
178 port = LaunchConfiguration('port')
179 declare_port = DeclareLaunchArgument(
180 name = 'port',
181 default_value= "9090",
182 description='The default port for rosbridge is 909'
183 )
184
185 # Declare launch arguments for points_map_loader
186 load_type = LaunchConfiguration('load_type')
187 declare_load_type= DeclareLaunchArgument(name = 'load_type', default_value = "noupdate")
188
189 single_pcd_path = LaunchConfiguration('single_pcd_path')
190 declare_single_pcd_path = DeclareLaunchArgument(name='single_pcd_path', default_value="['/opt/carma/maps/pcd_map.pcd']")
191
192 area = LaunchConfiguration('area')
193 declare_area = DeclareLaunchArgument(name='area', default_value="1x1")
194
195 arealist_path = LaunchConfiguration('arealist_path')
196 declare_arealist_path = DeclareLaunchArgument(name='arealist_path', default_value="/opt/carma/maps/arealist.txt")
197
198 vector_map_file = LaunchConfiguration('vector_map_file')
199 declare_vector_map_file = DeclareLaunchArgument(name='vector_map_file', default_value='/opt/carma/maps/vector_map.osm')
200
201 is_ros2_tracing_enabled = LaunchConfiguration('is_ros2_tracing_enabled')
202 declare_is_ros2_tracing_enabled = DeclareLaunchArgument(
203 name='is_ros2_tracing_enabled',
204 default_value = 'False',
205 description = 'True if user wants ROS 2 Tracing logs to be generated from CARMA Platform.')
206
207 # When enabled, the vehicle fuses incoming SDSM with its own sensor data to create a more accurate representation of the environment
208 # When turned off, topics get remapped to solely rely on its own sensor data
209 is_cp_mot_enabled = LaunchConfiguration('is_cp_mot_enabled')
210 declare_is_cp_mot_enabled = DeclareLaunchArgument(
211 name='is_cp_mot_enabled',
212 default_value = 'False',
213 description = 'True if user wants Cooperative Perception capability using Multiple Object Tracking to be enabled'
214 )
215
216 # When enabled, the vehicle has lidar detected objects in its external objects list
217 # TODO: Currently the stack is not shutting down automatically https://usdot-carma.atlassian.net.mcas-gov.us/browse/CAR-6109
218 is_autoware_lidar_obj_detection_enabled = LaunchConfiguration('is_autoware_lidar_obj_detection_enabled')
219 declare_is_autoware_lidar_obj_detection_enabled = DeclareLaunchArgument(
220 name='is_autoware_lidar_obj_detection_enabled',
221 default_value = 'False',
222 description = 'True if user wants Autoware Lidar Object Detection to be enabled'
223 )
224
225 # Launch ROS2 rosbag logging
226 ros2_rosbag_launch = GroupAction(
227 actions=[
228 IncludeLaunchDescription(
229 PythonLaunchDescriptionSource([ThisLaunchFileDir(), '/ros2_rosbag.launch.py']),
230 launch_arguments = {
231 'vehicle_config_dir' : vehicle_config_dir,
232 'vehicle_config_param_file' : vehicle_config_param_file
233 }.items()
234 )
235 ]
236 )
237
238 # Nodes
239
240 transform_group = GroupAction(
241 actions=[
242 PushRosNamespace(EnvironmentVariable('CARMA_TF_NS', default_value='/')),
243 IncludeLaunchDescription(
244 PythonLaunchDescriptionSource([ThisLaunchFileDir(), '/transforms.launch.py']),
245 launch_arguments = {
246 'vehicle_config_param_file' : vehicle_config_param_file,
247 'use_sim_time' : use_sim_time
248 }.items()
249 ),
250 ]
251 )
252
253 environment_group = GroupAction(
254 actions=[
255 PushRosNamespace(EnvironmentVariable('CARMA_ENV_NS', default_value='environment')),
256 IncludeLaunchDescription(
257 PythonLaunchDescriptionSource([ThisLaunchFileDir(), '/environment.launch.py']),
258 launch_arguments = {
259 'subsystem_controller_param_file' : [vehicle_config_dir, '/SubsystemControllerParams.yaml'],
260 'global_params_override_file' : global_params_override_file,
261 'vehicle_config_param_file' : vehicle_config_param_file,
262 'vehicle_calibration_dir': vehicle_calibration_dir,
263 'vehicle_characteristics_param_file' : vehicle_characteristics_param_file,
264 'vector_map_file' : vector_map_file,
265 'use_sim_time' : use_sim_time,
266 'is_cp_mot_enabled' : is_cp_mot_enabled,
267 'is_autoware_lidar_obj_detection_enabled' : is_autoware_lidar_obj_detection_enabled
268 }.items()
269 ),
270 ]
271 )
272
273 localization_group = GroupAction(
274 actions=[
275 PushRosNamespace(EnvironmentVariable('CARMA_LOCZ_NS', default_value='localization')),
276 IncludeLaunchDescription(
277 PythonLaunchDescriptionSource([ThisLaunchFileDir(), '/localization.launch.py']),
278 launch_arguments = {
279 'vehicle_config_param_file' : vehicle_config_param_file,
280 'global_params_override_file' : global_params_override_file,
281 'subsystem_controller_param_file' : [vehicle_config_dir, '/SubsystemControllerParams.yaml'],
282 'load_type' : load_type,
283 'single_pcd_path' : single_pcd_path,
284 'area' : area,
285 'arealist_path' : arealist_path,
286 'vector_map_file' : vector_map_file,
287 'vehicle_calibration_dir': vehicle_calibration_dir,
288 'use_sim_time' : use_sim_time
289 }.items()
290 )
291 ]
292 )
293
294 v2x_group = GroupAction(
295 actions=[
296 PushRosNamespace(EnvironmentVariable('CARMA_MSG_NS', default_value='message')),
297 IncludeLaunchDescription(
298 PythonLaunchDescriptionSource([ThisLaunchFileDir(), '/message.launch.py']),
299 launch_arguments = {
300 'vehicle_characteristics_param_file' : vehicle_characteristics_param_file,
301 'global_params_override_file' : global_params_override_file,
302 'vehicle_config_param_file' : vehicle_config_param_file,
303 'enable_opening_tunnels' : enable_opening_tunnels,
304 'subsystem_controller_param_file' : [vehicle_config_dir, '/SubsystemControllerParams.yaml'],
305 'use_sim_time' : use_sim_time
306 }.items()
307 ),
308 ]
309 )
310
311 guidance_group = GroupAction(
312 actions=[
313 PushRosNamespace(EnvironmentVariable('CARMA_GUIDE_NS', default_value='guidance')),
314
315 IncludeLaunchDescription(
316 PythonLaunchDescriptionSource([ThisLaunchFileDir(), '/guidance.launch.py']),
317 launch_arguments={
318 'route_file_folder' : route_file_folder,
319 'global_params_override_file' : global_params_override_file,
320 'vehicle_characteristics_param_file' : vehicle_characteristics_param_file,
321 'vehicle_config_param_file' : vehicle_config_param_file,
322 'enable_guidance_plugin_validator' : enable_guidance_plugin_validator,
323 'strategic_plugins_to_validate' : strategic_plugins_to_validate,
324 'tactical_plugins_to_validate' : tactical_plugins_to_validate,
325 'control_plugins_to_validate' : control_plugins_to_validate,
326 'subsystem_controller_param_file' : [vehicle_config_dir, '/SubsystemControllerParams.yaml'],
327 'use_sim_time' : use_sim_time,
328 'use_real_time_spat_in_sim' : use_real_time_spat_in_sim
329 }.items()
330 ),
331 ]
332 )
333
334 drivers_group = GroupAction(
335 actions=[
336 PushRosNamespace(EnvironmentVariable('CARMA_INTR_NS', default_value='hardware_interface')),
337 IncludeLaunchDescription(
338 PythonLaunchDescriptionSource([ThisLaunchFileDir(), '/drivers.launch.py']),
339 launch_arguments = {
340 'subsystem_controller_param_file' : [vehicle_config_dir, '/SubsystemControllerParams.yaml'],
341 'vehicle_config_param_file' : vehicle_config_param_file,
342 'global_params_override_file' : global_params_override_file,
343 'use_sim_time' : use_sim_time
344 }.items()
345 ),
346 ]
347 )
348
349 system_controller = Node(
350 package='system_controller',
351 name='system_controller',
352 executable='system_controller',
353 parameters=[
354 system_controller_param_file,
355 {"use_sim_time" : use_sim_time},
356 global_params_override_file],
357 on_exit = Shutdown(), # Mark the subsystem controller as required for segfaults
358 arguments=['--ros-args', '--log-level', GetLogLevel('system_controller', env_log_levels)]
359 )
360
361 ui_group = GroupAction(
362 actions=[
363 PushRosNamespace(EnvironmentVariable('CARMA_UI_NS', default_value='ui')),
364
365 IncludeLaunchDescription(
366 PythonLaunchDescriptionSource([ThisLaunchFileDir(), '/ui.launch.py']),
367 launch_arguments={
368 'port' : port
369 }.items()
370 ),
371 ]
372 )
373
374 return LaunchDescription([
375 declare_vehicle_calibration_dir_arg,
376 declare_vehicle_config_dir_arg,
377 declare_vehicle_characteristics_param_file_arg,
378 declare_vehicle_config_param_file_arg,
379 declare_use_sim_time_arg,
380 declare_use_real_time_spat_in_sim_arg,
381 declare_route_file_folder,
382 declare_enable_guidance_plugin_validator,
383 declare_strategic_plugins_to_validate,
384 declare_tactical_plugins_to_validate,
385 declare_control_plugins_to_validate,
386 declare_enable_opening_tunnels,
387 declare_port,
388 declare_load_type,
389 declare_single_pcd_path,
390 declare_area,
391 declare_arealist_path,
392 declare_vector_map_file,
393 declare_is_ros2_tracing_enabled,
394 declare_is_cp_mot_enabled,
395 declare_is_autoware_lidar_obj_detection_enabled,
396 declare_global_params_override_file_arg,
397 ros2_rosbag_launch,
398 OpaqueFunction(function=create_ros2_tracing_action),
399 drivers_group,
400 transform_group,
401 environment_group,
402 localization_group,
403 v2x_group,
404 guidance_group,
405 ui_group,
406 system_controller
407 ])
def create_ros2_tracing_action(context, *args, **kwargs)
def generate_launch_description()