Skip to content
This repository was archived by the owner on Mar 28, 2025. It is now read-only.

Commit a17071b

Browse files
committed
feat: implemented the launcher-side changes for the cuda preprocessing and transport layer
Signed-off-by: Kenzo Lobos-Tsunekawa <[email protected]>
1 parent db5489e commit a17071b

8 files changed

+201
-81
lines changed

common_sensor_launch/launch/nebula_node_container.launch.py

+160-80
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2023 Tier IV, Inc. All rights reserved.
1+
# Copyright 2024 Tier IV, Inc. All rights reserved.
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -23,6 +23,7 @@
2323
from launch.conditions import UnlessCondition
2424
from launch.substitutions import LaunchConfiguration
2525
from launch_ros.actions import ComposableNodeContainer
26+
from launch_ros.actions import LoadComposableNodes
2627
from launch_ros.descriptions import ComposableNode
2728
from launch_ros.parameter_descriptions import ParameterFile
2829
import yaml
@@ -101,13 +102,14 @@ def create_parameter_dict(*args):
101102

102103
nodes = []
103104

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+
)
109112
)
110-
)
111113

112114
nodes.append(
113115
ComposableNode(
@@ -149,87 +151,155 @@ def create_parameter_dict(*args):
149151
)
150152
)
151153

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+
)
162169

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+
)
174209
)
175-
)
176210

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+
)
184238

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+
)
196261
)
197-
)
198262

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+
)
212279
)
213-
)
214280

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+
)
231302
)
232-
)
233303

234304
# set container to run all required components in the same process
235305
container = ComposableNodeContainer(
@@ -238,10 +308,17 @@ def create_parameter_dict(*args):
238308
package="rclcpp_components",
239309
executable=LaunchConfiguration("container_executable"),
240310
composable_node_descriptions=nodes,
311+
condition=UnlessCondition(LaunchConfiguration("use_pointcloud_container")),
241312
output="both",
242313
)
243314

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]
245322

246323

247324
def generate_launch_description():
@@ -278,6 +355,9 @@ def add_launch_arg(name: str, default_value=None, description=None):
278355
add_launch_arg("use_multithread", "False", "use multithread")
279356
add_launch_arg("use_intra_process", "False", "use ROS 2 component container communication")
280357
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")
281361
add_launch_arg("output_as_sensor_frame", "True", "output final pointcloud in sensor frame")
282362
add_launch_arg(
283363
"vehicle_mirror_param_file", description="path to the file of vehicle mirror position yaml"

common_sensor_launch/launch/robosense_Bpearl.launch.xml

+6
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
<arg name="cloud_max_angle" default="360"/>
1616
<arg name="vehicle_mirror_param_file"/>
1717
<arg name="container_name" default="robosense_node_container"/>
18+
<arg name="pointcloud_container_name" default="pointcloud_container"/>
19+
<arg name="use_pointcloud_container" default="false"/>
20+
<arg name="use_cuda_preprocessor" default="false"/>
1821

1922
<include file="$(find-pkg-share common_sensor_launch)/launch/nebula_node_container.launch.py">
2023
<arg name="launch_driver" value="$(var launch_driver)"/>
@@ -33,5 +36,8 @@
3336
<arg name="use_intra_process" value="true"/>
3437
<arg name="use_multithread" value="false"/>
3538
<arg name="container_name" value="$(var container_name)"/>
39+
<arg name="pointcloud_container_name" value="$(var pointcloud_container_name)"/>
40+
<arg name="use_pointcloud_container" value="$(var use_pointcloud_container)"/>
41+
<arg name="use_cuda_preprocessor" value="$(var use_cuda_preprocessor)"/>
3642
</include>
3743
</launch>

common_sensor_launch/launch/robosense_Helios.launch.xml

+6
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
<arg name="cloud_max_angle" default="360"/>
1616
<arg name="vehicle_mirror_param_file"/>
1717
<arg name="container_name" default="robosense_node_container"/>
18+
<arg name="pointcloud_container_name" default="pointcloud_container"/>
19+
<arg name="use_pointcloud_container" default="false"/>
20+
<arg name="use_cuda_preprocessor" default="false"/>
1821

1922
<include file="$(find-pkg-share common_sensor_launch)/launch/nebula_node_container.launch.py">
2023
<arg name="launch_driver" value="$(var launch_driver)"/>
@@ -33,5 +36,8 @@
3336
<arg name="use_intra_process" value="true"/>
3437
<arg name="use_multithread" value="false"/>
3538
<arg name="container_name" value="$(var container_name)"/>
39+
<arg name="pointcloud_container_name" value="$(var pointcloud_container_name)"/>
40+
<arg name="use_pointcloud_container" value="$(var use_pointcloud_container)"/>
41+
<arg name="use_cuda_preprocessor" value="$(var use_cuda_preprocessor)"/>
3642
</include>
3743
</launch>

common_sensor_launch/launch/velodyne_VLP16.launch.xml

+6
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
<arg name="cloud_max_angle" default="360"/>
1515
<arg name="vehicle_mirror_param_file"/>
1616
<arg name="container_name" default="velodyne_node_container"/>
17+
<arg name="pointcloud_container_name" default="pointcloud_container"/>
18+
<arg name="use_pointcloud_container" default="false"/>
19+
<arg name="use_cuda_preprocessor" default="false"/>
1720

1821
<include file="$(find-pkg-share common_sensor_launch)/launch/nebula_node_container.launch.py">
1922
<arg name="launch_driver" value="$(var launch_driver)"/>
@@ -32,6 +35,9 @@
3235
<arg name="use_intra_process" value="true"/>
3336
<arg name="use_multithread" value="false"/>
3437
<arg name="container_name" value="$(var container_name)"/>
38+
<arg name="pointcloud_container_name" value="$(var pointcloud_container_name)"/>
39+
<arg name="use_pointcloud_container" value="$(var use_pointcloud_container)"/>
40+
<arg name="use_cuda_preprocessor" value="$(var use_cuda_preprocessor)"/>
3541
</include>
3642

3743
<!-- Velodyne Monitor -->

common_sensor_launch/launch/velodyne_VLS128.launch.xml

+6
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
<arg name="cloud_max_angle" default="360"/>
1515
<arg name="vehicle_mirror_param_file"/>
1616
<arg name="container_name" default="velodyne_node_container"/>
17+
<arg name="pointcloud_container_name" default="pointcloud_container"/>
18+
<arg name="use_pointcloud_container" default="false"/>
19+
<arg name="use_cuda_preprocessor" default="false"/>
1720

1821
<include file="$(find-pkg-share common_sensor_launch)/launch/nebula_node_container.launch.py">
1922
<arg name="launch_driver" value="$(var launch_driver)"/>
@@ -32,6 +35,9 @@
3235
<arg name="use_intra_process" value="true"/>
3336
<arg name="use_multithread" value="true"/>
3437
<arg name="container_name" value="$(var container_name)"/>
38+
<arg name="pointcloud_container_name" value="$(var pointcloud_container_name)"/>
39+
<arg name="use_pointcloud_container" value="$(var use_pointcloud_container)"/>
40+
<arg name="use_cuda_preprocessor" value="$(var use_cuda_preprocessor)"/>
3541
</include>
3642

3743
<!-- Velodyne Monitor -->

sample_sensor_kit_launch/config/concatenate_and_time_sync_node.param.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/**:
22
ros__parameters:
3+
use_cuda: true
34
debug_mode: false
45
has_static_tf_only: false
56
rosbag_replay: false

0 commit comments

Comments
 (0)