1
- # Copyright 2023 Tier IV, Inc. All rights reserved.
1
+ # Copyright 2024 Tier IV, Inc. All rights reserved.
2
2
#
3
3
# Licensed under the Apache License, Version 2.0 (the "License");
4
4
# you may not use this file except in compliance with the License.
23
23
from launch .conditions import UnlessCondition
24
24
from launch .substitutions import LaunchConfiguration
25
25
from launch_ros .actions import ComposableNodeContainer
26
+ from launch_ros .actions import LoadComposableNodes
26
27
from launch_ros .descriptions import ComposableNode
27
28
from launch_ros .parameter_descriptions import ParameterFile
28
29
import yaml
@@ -101,13 +102,14 @@ def create_parameter_dict(*args):
101
102
102
103
nodes = []
103
104
104
- nodes .append (
105
- ComposableNode (
106
- package = "glog_component" ,
107
- plugin = "GlogComponent" ,
108
- name = "glog_component" ,
105
+ if UnlessCondition (LaunchConfiguration ("use_pointcloud_container" )).evaluate (context ):
106
+ nodes .append (
107
+ ComposableNode (
108
+ package = "glog_component" ,
109
+ plugin = "GlogComponent" ,
110
+ name = "glog_component" ,
111
+ )
109
112
)
110
- )
111
113
112
114
nodes .append (
113
115
ComposableNode (
@@ -149,87 +151,155 @@ def create_parameter_dict(*args):
149
151
)
150
152
)
151
153
152
- cropbox_parameters = create_parameter_dict ("input_frame" , "output_frame" )
153
- cropbox_parameters ["negative" ] = True
154
-
155
- vehicle_info = get_vehicle_info (context )
156
- cropbox_parameters ["min_x" ] = vehicle_info ["min_longitudinal_offset" ]
157
- cropbox_parameters ["max_x" ] = vehicle_info ["max_longitudinal_offset" ]
158
- cropbox_parameters ["min_y" ] = vehicle_info ["min_lateral_offset" ]
159
- cropbox_parameters ["max_y" ] = vehicle_info ["max_lateral_offset" ]
160
- cropbox_parameters ["min_z" ] = vehicle_info ["min_height_offset" ]
161
- cropbox_parameters ["max_z" ] = vehicle_info ["max_height_offset" ]
154
+ if IfCondition (LaunchConfiguration ("use_cuda_preprocessor" )).evaluate (context ):
155
+ nodes .append (
156
+ ComposableNode (
157
+ package = "autoware_cuda_pointcloud_preprocessor" ,
158
+ plugin = "autoware::cuda_organized_pointcloud_adapter::CudaOrganizedPointcloudAdapterNode" ,
159
+ name = "cuda_organized_pointcloud_adapter_node" ,
160
+ remappings = [
161
+ ("~/input/pointcloud" , "pointcloud_raw_ex" ),
162
+ ("~/output/pointcloud" , "cuda_points" ),
163
+ ("~/output/pointcloud/cuda" , "cuda_points/cuda" ),
164
+ ],
165
+ # The whole node can not set use_intra_process due to type negotiation internal topics
166
+ # extra_arguments=[{"use_intra_process_comms": LaunchConfiguration("use_intra_process")}],
167
+ )
168
+ )
162
169
163
- nodes .append (
164
- ComposableNode (
165
- package = "autoware_pointcloud_preprocessor" ,
166
- plugin = "autoware::pointcloud_preprocessor::CropBoxFilterComponent" ,
167
- name = "crop_box_filter_self" ,
168
- remappings = [
169
- ("input" , "pointcloud_raw_ex" ),
170
- ("output" , "self_cropped/pointcloud_ex" ),
171
- ],
172
- parameters = [cropbox_parameters ],
173
- extra_arguments = [{"use_intra_process_comms" : LaunchConfiguration ("use_intra_process" )}],
170
+ preprocessor_parameters = {}
171
+
172
+ vehicle_info = get_vehicle_info (context )
173
+ preprocessor_parameters ["self_crop.min_x" ] = vehicle_info ["min_longitudinal_offset" ]
174
+ preprocessor_parameters ["self_crop.max_x" ] = vehicle_info ["max_longitudinal_offset" ]
175
+ preprocessor_parameters ["self_crop.min_y" ] = vehicle_info ["min_lateral_offset" ]
176
+ preprocessor_parameters ["self_crop.max_y" ] = vehicle_info ["max_lateral_offset" ]
177
+ preprocessor_parameters ["self_crop.min_z" ] = vehicle_info ["min_height_offset" ]
178
+ preprocessor_parameters ["self_crop.max_z" ] = vehicle_info ["max_height_offset" ]
179
+
180
+ mirror_info = get_vehicle_mirror_info (context )
181
+ preprocessor_parameters ["mirror_crop.min_x" ] = mirror_info ["min_longitudinal_offset" ]
182
+ preprocessor_parameters ["mirror_crop.max_x" ] = mirror_info ["max_longitudinal_offset" ]
183
+ preprocessor_parameters ["mirror_crop.min_y" ] = mirror_info ["min_lateral_offset" ]
184
+ preprocessor_parameters ["mirror_crop.max_y" ] = mirror_info ["max_lateral_offset" ]
185
+ preprocessor_parameters ["mirror_crop.min_z" ] = mirror_info ["min_height_offset" ]
186
+ preprocessor_parameters ["mirror_crop.max_z" ] = mirror_info ["max_height_offset" ]
187
+
188
+ nodes .append (
189
+ ComposableNode (
190
+ package = "autoware_cuda_pointcloud_preprocessor" ,
191
+ plugin = "autoware::cuda_pointcloud_preprocessor::CudaPointcloudPreprocessorNode" ,
192
+ name = "cuda_pointcloud_preprocessor_node" ,
193
+ parameters = [
194
+ preprocessor_parameters ,
195
+ distortion_corrector_node_param ,
196
+ ring_outlier_filter_node_param ,
197
+ ],
198
+ remappings = [
199
+ ("~/input/pointcloud" , "cuda_points" ),
200
+ ("~/input/pointcloud/cuda" , "cuda_points/cuda" ),
201
+ ("~/input/twist" , "/sensing/vehicle_velocity_converter/twist_with_covariance" ),
202
+ ("~/input/imu" , "/sensing/imu/imu_data" ),
203
+ ("~/output/pointcloud" , "pointcloud_before_sync" ),
204
+ ("~/output/pointcloud/cuda" , "pointcloud_before_sync/cuda" ),
205
+ ],
206
+ # The whole node can not set use_intra_process due to type negotiation internal topics
207
+ # extra_arguments=[{"use_intra_process_comms": LaunchConfiguration("use_intra_process")}],
208
+ )
174
209
)
175
- )
176
210
177
- mirror_info = get_vehicle_mirror_info (context )
178
- cropbox_parameters ["min_x" ] = mirror_info ["min_longitudinal_offset" ]
179
- cropbox_parameters ["max_x" ] = mirror_info ["max_longitudinal_offset" ]
180
- cropbox_parameters ["min_y" ] = mirror_info ["min_lateral_offset" ]
181
- cropbox_parameters ["max_y" ] = mirror_info ["max_lateral_offset" ]
182
- cropbox_parameters ["min_z" ] = mirror_info ["min_height_offset" ]
183
- cropbox_parameters ["max_z" ] = mirror_info ["max_height_offset" ]
211
+ else :
212
+ cropbox_parameters = create_parameter_dict ("input_frame" , "output_frame" )
213
+ cropbox_parameters ["negative" ] = True
214
+
215
+ vehicle_info = get_vehicle_info (context )
216
+ cropbox_parameters ["min_x" ] = vehicle_info ["min_longitudinal_offset" ]
217
+ cropbox_parameters ["max_x" ] = vehicle_info ["max_longitudinal_offset" ]
218
+ cropbox_parameters ["min_y" ] = vehicle_info ["min_lateral_offset" ]
219
+ cropbox_parameters ["max_y" ] = vehicle_info ["max_lateral_offset" ]
220
+ cropbox_parameters ["min_z" ] = vehicle_info ["min_height_offset" ]
221
+ cropbox_parameters ["max_z" ] = vehicle_info ["max_height_offset" ]
222
+
223
+ nodes .append (
224
+ ComposableNode (
225
+ package = "autoware_pointcloud_preprocessor" ,
226
+ plugin = "autoware::pointcloud_preprocessor::CropBoxFilterComponent" ,
227
+ name = "crop_box_filter_self" ,
228
+ remappings = [
229
+ ("input" , "pointcloud_raw_ex" ),
230
+ ("output" , "self_cropped/pointcloud_ex" ),
231
+ ],
232
+ parameters = [cropbox_parameters ],
233
+ extra_arguments = [
234
+ {"use_intra_process_comms" : LaunchConfiguration ("use_intra_process" )}
235
+ ],
236
+ )
237
+ )
184
238
185
- nodes .append (
186
- ComposableNode (
187
- package = "autoware_pointcloud_preprocessor" ,
188
- plugin = "autoware::pointcloud_preprocessor::CropBoxFilterComponent" ,
189
- name = "crop_box_filter_mirror" ,
190
- remappings = [
191
- ("input" , "self_cropped/pointcloud_ex" ),
192
- ("output" , "mirror_cropped/pointcloud_ex" ),
193
- ],
194
- parameters = [cropbox_parameters ],
195
- extra_arguments = [{"use_intra_process_comms" : LaunchConfiguration ("use_intra_process" )}],
239
+ mirror_info = get_vehicle_mirror_info (context )
240
+ cropbox_parameters ["min_x" ] = mirror_info ["min_longitudinal_offset" ]
241
+ cropbox_parameters ["max_x" ] = mirror_info ["max_longitudinal_offset" ]
242
+ cropbox_parameters ["min_y" ] = mirror_info ["min_lateral_offset" ]
243
+ cropbox_parameters ["max_y" ] = mirror_info ["max_lateral_offset" ]
244
+ cropbox_parameters ["min_z" ] = mirror_info ["min_height_offset" ]
245
+ cropbox_parameters ["max_z" ] = mirror_info ["max_height_offset" ]
246
+
247
+ nodes .append (
248
+ ComposableNode (
249
+ package = "autoware_pointcloud_preprocessor" ,
250
+ plugin = "autoware::pointcloud_preprocessor::CropBoxFilterComponent" ,
251
+ name = "crop_box_filter_mirror" ,
252
+ remappings = [
253
+ ("input" , "self_cropped/pointcloud_ex" ),
254
+ ("output" , "mirror_cropped/pointcloud_ex" ),
255
+ ],
256
+ parameters = [cropbox_parameters ],
257
+ extra_arguments = [
258
+ {"use_intra_process_comms" : LaunchConfiguration ("use_intra_process" )}
259
+ ],
260
+ )
196
261
)
197
- )
198
262
199
- nodes .append (
200
- ComposableNode (
201
- package = "autoware_pointcloud_preprocessor" ,
202
- plugin = "autoware::pointcloud_preprocessor::DistortionCorrectorComponent" ,
203
- name = "distortion_corrector_node" ,
204
- remappings = [
205
- ("~/input/twist" , "/sensing/vehicle_velocity_converter/twist_with_covariance" ),
206
- ("~/input/imu" , "/sensing/imu/imu_data" ),
207
- ("~/input/pointcloud" , "mirror_cropped/pointcloud_ex" ),
208
- ("~/output/pointcloud" , "rectified/pointcloud_ex" ),
209
- ],
210
- parameters = [distortion_corrector_node_param ],
211
- extra_arguments = [{"use_intra_process_comms" : LaunchConfiguration ("use_intra_process" )}],
263
+ nodes .append (
264
+ ComposableNode (
265
+ package = "autoware_pointcloud_preprocessor" ,
266
+ plugin = "autoware::pointcloud_preprocessor::DistortionCorrectorComponent" ,
267
+ name = "distortion_corrector_node" ,
268
+ remappings = [
269
+ ("~/input/twist" , "/sensing/vehicle_velocity_converter/twist_with_covariance" ),
270
+ ("~/input/imu" , "/sensing/imu/imu_data" ),
271
+ ("~/input/pointcloud" , "mirror_cropped/pointcloud_ex" ),
272
+ ("~/output/pointcloud" , "rectified/pointcloud_ex" ),
273
+ ],
274
+ parameters = [distortion_corrector_node_param ],
275
+ extra_arguments = [
276
+ {"use_intra_process_comms" : LaunchConfiguration ("use_intra_process" )}
277
+ ],
278
+ )
212
279
)
213
- )
214
280
215
- # Ring Outlier Filter is the last component in the pipeline, so control the output frame here
216
- if LaunchConfiguration ("output_as_sensor_frame" ).perform (context ).lower () == "true" :
217
- ring_outlier_output_frame = {"output_frame" : LaunchConfiguration ("frame_id" )}
218
- else :
219
- ring_outlier_output_frame = {"output_frame" : "" } # keep the output frame as the input frame
220
- nodes .append (
221
- ComposableNode (
222
- package = "autoware_pointcloud_preprocessor" ,
223
- plugin = "autoware::pointcloud_preprocessor::RingOutlierFilterComponent" ,
224
- name = "ring_outlier_filter" ,
225
- remappings = [
226
- ("input" , "rectified/pointcloud_ex" ),
227
- ("output" , "pointcloud_before_sync" ),
228
- ],
229
- parameters = [ring_outlier_filter_node_param , ring_outlier_output_frame ],
230
- extra_arguments = [{"use_intra_process_comms" : LaunchConfiguration ("use_intra_process" )}],
281
+ # Ring Outlier Filter is the last component in the pipeline, so control the output frame here
282
+ if LaunchConfiguration ("output_as_sensor_frame" ).perform (context ).lower () == "true" :
283
+ ring_outlier_output_frame = {"output_frame" : LaunchConfiguration ("frame_id" )}
284
+ else :
285
+ ring_outlier_output_frame = {
286
+ "output_frame" : ""
287
+ } # keep the output frame as the input frame
288
+ nodes .append (
289
+ ComposableNode (
290
+ package = "autoware_pointcloud_preprocessor" ,
291
+ plugin = "autoware::pointcloud_preprocessor::RingOutlierFilterComponent" ,
292
+ name = "ring_outlier_filter" ,
293
+ remappings = [
294
+ ("input" , "rectified/pointcloud_ex" ),
295
+ ("output" , "pointcloud_before_sync" ),
296
+ ],
297
+ parameters = [ring_outlier_filter_node_param , ring_outlier_output_frame ],
298
+ extra_arguments = [
299
+ {"use_intra_process_comms" : LaunchConfiguration ("use_intra_process" )}
300
+ ],
301
+ )
231
302
)
232
- )
233
303
234
304
# set container to run all required components in the same process
235
305
container = ComposableNodeContainer (
@@ -238,10 +308,17 @@ def create_parameter_dict(*args):
238
308
package = "rclcpp_components" ,
239
309
executable = LaunchConfiguration ("container_executable" ),
240
310
composable_node_descriptions = nodes ,
311
+ condition = UnlessCondition (LaunchConfiguration ("use_pointcloud_container" )),
241
312
output = "both" ,
242
313
)
243
314
244
- return [container ]
315
+ load_composable_nodes = LoadComposableNodes (
316
+ composable_node_descriptions = nodes ,
317
+ target_container = LaunchConfiguration ("pointcloud_container_name" ),
318
+ condition = IfCondition (LaunchConfiguration ("use_pointcloud_container" )),
319
+ )
320
+
321
+ return [container , load_composable_nodes ]
245
322
246
323
247
324
def generate_launch_description ():
@@ -278,6 +355,9 @@ def add_launch_arg(name: str, default_value=None, description=None):
278
355
add_launch_arg ("use_multithread" , "False" , "use multithread" )
279
356
add_launch_arg ("use_intra_process" , "False" , "use ROS 2 component container communication" )
280
357
add_launch_arg ("lidar_container_name" , "nebula_node_container" )
358
+ add_launch_arg ("pointcloud_container_name" , "pointcloud_container" )
359
+ add_launch_arg ("use_pointcloud_container" , "False" )
360
+ add_launch_arg ("use_cuda_preprocessor" , "False" )
281
361
add_launch_arg ("output_as_sensor_frame" , "True" , "output final pointcloud in sensor frame" )
282
362
add_launch_arg (
283
363
"vehicle_mirror_param_file" , description = "path to the file of vehicle mirror position yaml"
0 commit comments