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.
message.launch.py
Go to the documentation of this file.
1# Copyright (C) 2022 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
16from launch.actions import Shutdown
17from launch import LaunchDescription
18from launch_ros.actions import Node
19from launch_ros.actions import ComposableNodeContainer
20from launch_ros.descriptions import ComposableNode
21from launch.substitutions import EnvironmentVariable
22from carma_ros2_utils.launch.get_log_level import GetLogLevel
23from carma_ros2_utils.launch.get_current_namespace import GetCurrentNamespace
24from launch.substitutions import LaunchConfiguration
25from launch.actions import DeclareLaunchArgument, ExecuteProcess
26from launch.conditions import IfCondition
27
28import os
29import subprocess
30
31from launch.actions import IncludeLaunchDescription
32from launch.launch_description_sources import PythonLaunchDescriptionSource
33from launch.actions import GroupAction
34from launch_ros.actions import set_remap
35
36
38
39 """
40 Launch V2X subsystem nodes.
41 """
42
43 # Log level is set from CARMA_ROS_LOGGING_CONFIG, generated from carma_rosconsole.conf in the vehicle config dir (carma-config)
44 env_log_levels = EnvironmentVariable('CARMA_ROS_LOGGING_CONFIG', default_value='{ "default_level" : "WARN" }')
45
46 subsystem_controller_default_param_file = os.path.join(
47 get_package_share_directory('subsystem_controllers'), 'config/v2x_controller_config.yaml')
48
49 mobilitypath_publisher_param_file = os.path.join(
50 get_package_share_directory('mobilitypath_publisher'), 'config/parameters.yaml')
51
52 bsm_generator_param_file = os.path.join(
53 get_package_share_directory('bsm_generator'), 'config/parameters.yaml')
54
55 vehicle_characteristics_param_file = LaunchConfiguration('vehicle_characteristics_param_file')
56 declare_vehicle_characteristics_param_file_arg = DeclareLaunchArgument(
57 name = 'vehicle_characteristics_param_file',
58 default_value = "/opt/carma/vehicle/calibration/identifiers/UniqueVehicleParams.yaml",
59 description = "Path to file containing unique vehicle calibrations"
60 )
61
62 vehicle_config_param_file = LaunchConfiguration('vehicle_config_param_file')
63 declare_vehicle_config_param_file_arg = DeclareLaunchArgument(
64 name = 'vehicle_config_param_file',
65 default_value = "/opt/carma/vehicle/config/VehicleConfigParams.yaml",
66 description = "Path to file contain vehicle configuration parameters"
67 )
68
69 subsystem_controller_param_file = LaunchConfiguration('subsystem_controller_param_file')
70 declare_subsystem_controller_param_file_arg = DeclareLaunchArgument(
71 name = 'subsystem_controller_param_file',
72 default_value = subsystem_controller_default_param_file,
73 description = "Path to file containing override parameters for the subsystem controller"
74 )
75
76 vehicle_config_dir = LaunchConfiguration('vehicle_config_dir')
77 declare_vehicle_config_dir_arg = DeclareLaunchArgument(
78 name = 'vehicle_config_dir',
79 default_value = "/opt/carma/vehicle/config",
80 description = "Path to vehicle configuration directory populated by carma-config"
81 )
82
83 # Declare the global_params_override_file launch argument
84 # Parameters in this file will override any parameters loaded in their respective packages
85 global_params_override_file = LaunchConfiguration('global_params_override_file')
86 declare_global_params_override_file_arg = DeclareLaunchArgument(
87 name = 'global_params_override_file',
88 default_value = [vehicle_config_dir, "/GlobalParamsOverride.yaml"],
89 description = "Path to global file containing the parameters overwrite"
90 )
91
92 # Declare enable_opening_tunnels
93 enable_opening_tunnels = LaunchConfiguration('enable_opening_tunnels')
94 declare_enable_opening_tunnels = DeclareLaunchArgument(
95 name = 'enable_opening_tunnels',
96 default_value= 'True',
97 description='Flag to enable opening http tunnesl to CARMA Cloud'
98 )
99
100 carma_cloud_client_param_file = os.path.join(
101 get_package_share_directory('carma_cloud_client'), 'config/parameters.yaml')
102
103 use_sim_time = LaunchConfiguration('use_sim_time')
104 declare_use_sim_time_arg = DeclareLaunchArgument(
105 name = 'use_sim_time',
106 default_value = "False",
107 description = "True if simulation mode is on"
108 )
109
110 # Nodes
111 carma_v2x_container = ComposableNodeContainer(
112 package='carma_ros2_utils',
113 name='carma_v2x_container',
114 executable='carma_component_container_mt',
115 namespace=GetCurrentNamespace(),
116 composable_node_descriptions=[
117
118 ComposableNode(
119 package='mobilitypath_publisher',
120 plugin='mobilitypath_publisher::MobilityPathPublication',
121 name='mobilitypath_publisher_node',
122 extra_arguments=[
123 {'use_intra_process_comms': True},
124 ],
125 remappings=[
126 ("plan_trajectory", [ EnvironmentVariable('CARMA_GUIDE_NS', default_value=''), "/plan_trajectory" ] ),
127 ("guidance_state", [ EnvironmentVariable('CARMA_GUIDE_NS', default_value=''), "/state" ] ),
128 ("georeference", [ EnvironmentVariable('CARMA_LOCZ_NS', default_value=''), "/map_param_loader/georeference" ] ),
129 ("mobility_path_msg", [ EnvironmentVariable('CARMA_MSG_NS', default_value=''), "/outgoing_mobility_path" ] )
130 ],
131 parameters=[
132 mobilitypath_publisher_param_file,
133 vehicle_characteristics_param_file,
134 vehicle_config_param_file,
135 global_params_override_file
136 ]
137 ),
138 ComposableNode(
139 package='bsm_generator',
140 plugin='bsm_generator::BSMGenerator',
141 name='bsm_generator_node',
142 extra_arguments=[
143 {'use_intra_process_comms': True},
144 ],
145 remappings=[
146 ("velocity_accel_cov", [ EnvironmentVariable('CARMA_INTR_NS', default_value=''), "/velocity_accel_cov" ] ),
147 ("ekf_twist", [ EnvironmentVariable('CARMA_INTR_NS', default_value=''), "/vehicle/twist" ] ),
148 ("imu_raw", [ EnvironmentVariable('CARMA_INTR_NS', default_value=''), "/imu_raw" ] ),
149 ("transmission_state", [ EnvironmentVariable('CARMA_INTR_NS', default_value=''), "/can/transmission_state" ] ),
150 ("brake_position", [ EnvironmentVariable('CARMA_INTR_NS', default_value=''), "/can/brake_position" ] ),
151 ("steering_wheel_angle", [ EnvironmentVariable('CARMA_INTR_NS', default_value=''), "/can/steering_wheel_angle" ] ),
152 ("gnss_fix_fused", [ EnvironmentVariable('CARMA_INTR_NS', default_value=''), "/gnss_fix_fused" ] ),
153 ("pose", [ EnvironmentVariable('CARMA_LOCZ_NS', default_value=''), "/current_pose" ] ),
154 ("georeference", [ EnvironmentVariable('CARMA_LOCZ_NS', default_value=''), "/map_param_loader/georeference" ] )
155 ],
156 parameters=[
157 bsm_generator_param_file,
158 vehicle_characteristics_param_file,
159 vehicle_config_param_file,
160 global_params_override_file
161 ]
162 ),
163 ComposableNode(
164 package='cpp_message',
165 plugin='cpp_message::Node',
166 name='cpp_message_node',
167 extra_arguments=[
168 {'use_intra_process_comms': True},
169 ],
170 remappings=[
171 ("inbound_binary_msg", [ EnvironmentVariable('CARMA_INTR_NS', default_value=''), "/comms/inbound_binary_msg" ] ),
172 ("outbound_binary_msg", [ EnvironmentVariable('CARMA_INTR_NS', default_value=''), "/comms/outbound_binary_msg" ] ),
173 ],
174 parameters=[
175 vehicle_config_param_file,
176 global_params_override_file
177 ]
178 ),
179 ComposableNode(
180 package='j2735_convertor',
181 plugin='j2735_convertor::Node',
182 name='j2735_convertor_node',
183 extra_arguments=[
184 {'use_intra_process_comms': True},
185 ],
186 remappings=[
187 ("outgoing_bsm", "bsm_outbound" )
188 ],
189 parameters=[
190 vehicle_config_param_file,
191 global_params_override_file
192 ]
193 ),
194 ComposableNode(
195 package='carma_cloud_client',
196 plugin='carma_cloud_client::CarmaCloudClient',
197 name='carma_cloud_client_node',
198 extra_arguments=[
199 {'use_intra_process_comms': True},
200 ],
201 remappings=[
202 ("incoming_geofence_control", [ EnvironmentVariable('CARMA_MSG_NS', default_value=''), "/incoming_geofence_control" ] ),
203 ],
204 parameters = [
205 vehicle_config_param_file,
206 carma_cloud_client_param_file,
207 global_params_override_file
208 ]
209
210 ),
211 ]
212 )
213
214 # subsystem_controller which orchestrates the lifecycle of this subsystem's components
215 subsystem_controller = Node(
216 package='subsystem_controllers',
217 name='v2x_controller',
218 executable='v2x_controller',
219 parameters=[
220 subsystem_controller_default_param_file,
221 subsystem_controller_param_file,
222 {"use_sim_time" : use_sim_time}], # Default file is loaded first followed by config file
223 on_exit= Shutdown(), # Mark the subsystem controller as required
224 arguments=['--ros-args', '--log-level', GetLogLevel('subsystem_controllers', env_log_levels)]
225 )
226
227 # Info needed for opening the tunnels
228 # TODO: Investigate if this can be further cleaned up
229 REMOTE_USER="ubuntu"
230 REMOTE_ADDR="carma-cloud.com" # Dev instance is www.carma-cloud.com, prod instance is carma-cloud.com
231 KEY_FILE="carma-cloud-1.pem" # Dev key is carma-cloud-test-1.pem, prod key is carma-cloud-1.pem
232 HOST_PORT="33333" # This port is forwarded to remote host (carma-cloud)
233 REMOTE_PORT="22222" # This port is forwarded to local host
234 param_launch_path = os.path.join(
235 get_package_share_directory('carma_cloud_client'), 'launch/scripts')
236
237 script = param_launch_path + '/open_tunnels.sh'
238
239 subprocess.check_call(['chmod','u+x', script])
240
241 key_path = "/opt/carma/vehicle/calibration/cloud_permission"
242
243 keyfile = key_path + '/' + KEY_FILE
244
245 subprocess.check_call(['sudo','chmod','400', keyfile])
246
247 open_tunnels_action = ExecuteProcess(
248
249 condition=IfCondition(enable_opening_tunnels),
250 cmd = ['sudo', script, '-u', REMOTE_USER, '-a', REMOTE_ADDR, '-k', keyfile, '-p', REMOTE_PORT, '-r', HOST_PORT],
251 output = 'screen'
252 )
253
254 return LaunchDescription([
255 declare_vehicle_config_param_file_arg,
256 declare_vehicle_config_dir_arg,
257 declare_global_params_override_file_arg,
258 declare_use_sim_time_arg,
259 declare_vehicle_characteristics_param_file_arg,
260 declare_subsystem_controller_param_file_arg,
261 declare_enable_opening_tunnels,
262 open_tunnels_action,
263 carma_v2x_container,
264 subsystem_controller
265 ])
def generate_launch_description()