38
39 """
40 Launch V2X subsystem nodes.
41 """
42
43
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
84
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
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
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
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}],
223 on_exit= Shutdown(),
224 arguments=['--ros-args', '--log-level', GetLogLevel('subsystem_controllers', env_log_levels)]
225 )
226
227
228
229 REMOTE_USER="ubuntu"
230 REMOTE_ADDR="carma-cloud.com"
231 KEY_FILE="carma-cloud-1.pem"
232 HOST_PORT="33333"
233 REMOTE_PORT="22222"
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()