diff --git a/launch/tier4_perception_launch/launch/traffic_light_recognition/traffic_light.launch.xml b/launch/tier4_perception_launch/launch/traffic_light_recognition/traffic_light.launch.xml
index 7b81a42fdb79f..dacdad933ebf8 100644
--- a/launch/tier4_perception_launch/launch/traffic_light_recognition/traffic_light.launch.xml
+++ b/launch/tier4_perception_launch/launch/traffic_light_recognition/traffic_light.launch.xml
@@ -24,12 +24,9 @@
-
-
-
-
-
-
+
+
+
@@ -62,12 +59,9 @@
-
-
-
-
-
-
+
+
+
@@ -119,12 +113,9 @@
-
-
-
-
-
-
+
+
+
diff --git a/launch/tier4_perception_launch/launch/traffic_light_recognition/traffic_light_node_container.launch.py b/launch/tier4_perception_launch/launch/traffic_light_recognition/traffic_light_node_container.launch.py
index dc5a2443d3f45..e467aba5d4e98 100644
--- a/launch/tier4_perception_launch/launch/traffic_light_recognition/traffic_light_node_container.launch.py
+++ b/launch/tier4_perception_launch/launch/traffic_light_recognition/traffic_light_node_container.launch.py
@@ -17,6 +17,7 @@
from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument
+from launch.actions import OpaqueFunction
from launch.actions import SetLaunchConfiguration
from launch.conditions import IfCondition
from launch.conditions import UnlessCondition
@@ -24,83 +25,29 @@
from launch_ros.actions import ComposableNodeContainer
from launch_ros.actions import LoadComposableNodes
from launch_ros.descriptions import ComposableNode
+from launch_ros.parameter_descriptions import ParameterFile
-def generate_launch_description():
- launch_arguments = []
-
- def add_launch_arg(name: str, default_value=None, description=None):
- # a default_value of None is equivalent to not passing that kwarg at all
- launch_arguments.append(
- DeclareLaunchArgument(name, default_value=default_value, description=description)
- )
-
- fine_detector_share_dir = get_package_share_directory("traffic_light_fine_detector")
- classifier_share_dir = get_package_share_directory("traffic_light_classifier")
- add_launch_arg("enable_image_decompressor", "True")
- add_launch_arg("enable_fine_detection", "True")
- add_launch_arg("input/image", "/sensing/camera/traffic_light/image_raw")
- add_launch_arg("output/rois", "/perception/traffic_light_recognition/rois")
- add_launch_arg(
- "output/traffic_signals",
- "/perception/traffic_light_recognition/traffic_signals",
- )
- add_launch_arg(
- "output/car/traffic_signals", "/perception/traffic_light_recognition/car/traffic_signals"
- )
- add_launch_arg(
- "output/pedestrian/traffic_signals",
- "/perception/traffic_light_recognition/pedestrian/traffic_signals",
- )
-
- # traffic_light_fine_detector
- add_launch_arg(
- "fine_detector_model_path",
- os.path.join(fine_detector_share_dir, "data", "tlr_yolox_s.onnx"),
- )
- add_launch_arg(
- "fine_detector_label_path",
- os.path.join(fine_detector_share_dir, "data", "tlr_labels.txt"),
- )
- add_launch_arg("fine_detector_precision", "fp16")
- add_launch_arg("fine_detector_score_thresh", "0.3")
- add_launch_arg("fine_detector_nms_thresh", "0.65")
-
- add_launch_arg("approximate_sync", "False")
-
- # traffic_light_classifier
- add_launch_arg("classifier_type", "1")
- add_launch_arg(
- "car_classifier_model_path",
- os.path.join(classifier_share_dir, "data", "traffic_light_classifier_efficientNet_b1.onnx"),
- )
- add_launch_arg(
- "pedestrian_classifier_model_path",
- os.path.join(
- classifier_share_dir, "data", "pedestrian_traffic_light_classifier_efficientNet_b1.onnx"
- ),
- )
- add_launch_arg(
- "car_classifier_label_path", os.path.join(classifier_share_dir, "data", "lamp_labels.txt")
- )
- add_launch_arg(
- "pedestrian_classifier_label_path",
- os.path.join(classifier_share_dir, "data", "lamp_labels_ped.txt"),
- )
- add_launch_arg("classifier_precision", "fp16")
- add_launch_arg("classifier_mean", "[123.675, 116.28, 103.53]")
- add_launch_arg("classifier_std", "[58.395, 57.12, 57.375]")
- add_launch_arg("backlight_threshold", "0.85")
-
- add_launch_arg("use_intra_process", "False")
- add_launch_arg("use_multithread", "False")
-
+def launch_setup(context, *args, **kwargs):
def create_parameter_dict(*args):
result = {}
for x in args:
result[x] = LaunchConfiguration(x)
return result
+ fine_detector_model_param = ParameterFile(
+ param_file=LaunchConfiguration("fine_detector_param_path").perform(context),
+ allow_substs=True,
+ )
+ car_traffic_light_classifier_model_param = ParameterFile(
+ param_file=LaunchConfiguration("car_classifier_param_path").perform(context),
+ allow_substs=True,
+ )
+ pedestrian_traffic_light_classifier_model_param = ParameterFile(
+ param_file=LaunchConfiguration("pedestrian_classifier_param_path").perform(context),
+ allow_substs=True,
+ )
+
container = ComposableNodeContainer(
name="traffic_light_node_container",
namespace="",
@@ -112,19 +59,7 @@ def create_parameter_dict(*args):
plugin="traffic_light::TrafficLightClassifierNodelet",
name="car_traffic_light_classifier",
namespace="classification",
- parameters=[
- {
- "approximate_sync": LaunchConfiguration("approximate_sync"),
- "classifier_type": LaunchConfiguration("classifier_type"),
- "classify_traffic_light_type": 0,
- "classifier_model_path": LaunchConfiguration("car_classifier_model_path"),
- "classifier_label_path": LaunchConfiguration("car_classifier_label_path"),
- "classifier_precision": LaunchConfiguration("classifier_precision"),
- "classifier_mean": LaunchConfiguration("classifier_mean"),
- "classifier_std": LaunchConfiguration("classifier_std"),
- "backlight_threshold": LaunchConfiguration("backlight_threshold"),
- }
- ],
+ parameters=[car_traffic_light_classifier_model_param],
remappings=[
("~/input/image", LaunchConfiguration("input/image")),
("~/input/rois", LaunchConfiguration("output/rois")),
@@ -139,23 +74,7 @@ def create_parameter_dict(*args):
plugin="traffic_light::TrafficLightClassifierNodelet",
name="pedestrian_traffic_light_classifier",
namespace="classification",
- parameters=[
- {
- "approximate_sync": LaunchConfiguration("approximate_sync"),
- "classifier_type": LaunchConfiguration("classifier_type"),
- "classify_traffic_light_type": 1,
- "classifier_model_path": LaunchConfiguration(
- "pedestrian_classifier_model_path"
- ),
- "classifier_label_path": LaunchConfiguration(
- "pedestrian_classifier_label_path"
- ),
- "classifier_precision": LaunchConfiguration("classifier_precision"),
- "classifier_mean": LaunchConfiguration("classifier_mean"),
- "classifier_std": LaunchConfiguration("classifier_std"),
- "backlight_threshold": LaunchConfiguration("backlight_threshold"),
- }
- ],
+ parameters=[pedestrian_traffic_light_classifier_model_param],
remappings=[
("~/input/image", LaunchConfiguration("input/image")),
("~/input/rois", LaunchConfiguration("output/rois")),
@@ -214,14 +133,6 @@ def create_parameter_dict(*args):
condition=IfCondition(LaunchConfiguration("enable_image_decompressor")),
)
- fine_detector_param = create_parameter_dict(
- "fine_detector_model_path",
- "fine_detector_label_path",
- "fine_detector_precision",
- "fine_detector_score_thresh",
- "fine_detector_nms_thresh",
- )
-
fine_detector_loader = LoadComposableNodes(
composable_node_descriptions=[
ComposableNode(
@@ -229,7 +140,7 @@ def create_parameter_dict(*args):
plugin="traffic_light::TrafficLightFineDetectorNodelet",
name="traffic_light_fine_detector",
namespace="detection",
- parameters=[fine_detector_param],
+ parameters=[fine_detector_model_param],
remappings=[
("~/input/image", LaunchConfiguration("input/image")),
("~/input/rois", "rough/rois"),
@@ -245,6 +156,61 @@ def create_parameter_dict(*args):
condition=IfCondition(LaunchConfiguration("enable_fine_detection")),
)
+ return [container, decompressor_loader, fine_detector_loader]
+
+
+def generate_launch_description():
+ launch_arguments = []
+
+ def add_launch_arg(name: str, default_value=None, description=None):
+ # a default_value of None is equivalent to not passing that kwarg at all
+ launch_arguments.append(
+ DeclareLaunchArgument(name, default_value=default_value, description=description)
+ )
+
+ fine_detector_share_dir = get_package_share_directory("traffic_light_fine_detector")
+ classifier_share_dir = get_package_share_directory("traffic_light_classifier")
+ add_launch_arg("enable_image_decompressor", "True")
+ add_launch_arg("enable_fine_detection", "True")
+ add_launch_arg("input/image", "/sensing/camera/traffic_light/image_raw")
+ add_launch_arg("output/rois", "/perception/traffic_light_recognition/rois")
+ add_launch_arg(
+ "output/traffic_signals",
+ "/perception/traffic_light_recognition/traffic_signals",
+ )
+ add_launch_arg(
+ "output/car/traffic_signals", "/perception/traffic_light_recognition/car/traffic_signals"
+ )
+ add_launch_arg(
+ "output/pedestrian/traffic_signals",
+ "/perception/traffic_light_recognition/pedestrian/traffic_signals",
+ )
+
+ # traffic_light_fine_detector
+ add_launch_arg(
+ "fine_detector_param_path",
+ os.path.join(fine_detector_share_dir, "config", "traffic_light_fine_detector.param.yaml"),
+ )
+
+ # traffic_light_classifier
+ add_launch_arg(
+ "car_classifier_param_path",
+ os.path.join(
+ classifier_share_dir, "config", "car_traffic_light_classifier_efficientNet.param.yaml"
+ ),
+ )
+ add_launch_arg(
+ "pedestrian_classifier_param_path",
+ os.path.join(
+ classifier_share_dir,
+ "config",
+ "pedestrian_traffic_light_classifier_efficientNet.param.yaml",
+ ),
+ )
+
+ add_launch_arg("use_intra_process", "False")
+ add_launch_arg("use_multithread", "False")
+
set_container_executable = SetLaunchConfiguration(
"container_executable",
"component_container",
@@ -262,8 +228,6 @@ def create_parameter_dict(*args):
*launch_arguments,
set_container_executable,
set_container_mt_executable,
- container,
- decompressor_loader,
- fine_detector_loader,
+ OpaqueFunction(function=launch_setup),
]
)
diff --git a/perception/traffic_light_classifier/CMakeLists.txt b/perception/traffic_light_classifier/CMakeLists.txt
index 22bc7521c6e31..a81dc6ab1e6ce 100644
--- a/perception/traffic_light_classifier/CMakeLists.txt
+++ b/perception/traffic_light_classifier/CMakeLists.txt
@@ -123,6 +123,7 @@ if(TRT_AVAIL AND CUDA_AVAIL AND CUDNN_AVAIL)
ament_auto_package(INSTALL_TO_SHARE
launch
+ config
)
else()
@@ -147,6 +148,7 @@ else()
ament_auto_package(INSTALL_TO_SHARE
launch
+ config
)
endif()
diff --git a/perception/traffic_light_classifier/config/car_traffic_light_classifier.param.yaml b/perception/traffic_light_classifier/config/car_traffic_light_classifier.param.yaml
new file mode 100644
index 0000000000000..78490a6f8ee0d
--- /dev/null
+++ b/perception/traffic_light_classifier/config/car_traffic_light_classifier.param.yaml
@@ -0,0 +1,11 @@
+/**:
+ ros__parameters:
+ approximate_sync: false
+ classifier_label_path: "$(var traffic_light_classifier_model_path)/$(var car_traffic_light_classifier_label_name)"
+ classifier_model_path: "$(var traffic_light_classifier_model_path)/$(var car_traffic_light_classifier_model_name).onnx"
+ classifier_precision: fp16
+ classifier_mean: [123.675, 116.28, 103.53]
+ classifier_std: [58.395, 57.12, 57.375]
+ backlight_threshold: 0.85
+ classifier_type: 1 #classifier_type {hsv_filter: 0, cnn: 1}
+ classify_traffic_light_type: 0 #classify_traffic_light_type {car: 0, pedestrian:1}
diff --git a/perception/traffic_light_classifier/config/pedestrian_traffic_light_classifier.param.yaml b/perception/traffic_light_classifier/config/pedestrian_traffic_light_classifier.param.yaml
new file mode 100644
index 0000000000000..9974ef3c55b73
--- /dev/null
+++ b/perception/traffic_light_classifier/config/pedestrian_traffic_light_classifier.param.yaml
@@ -0,0 +1,11 @@
+/**:
+ ros__parameters:
+ approximate_sync: false
+ classifier_label_path: "$(var traffic_light_classifier_model_path)/$(var pedestrian_traffic_light_classifier_label_name)"
+ classifier_model_path: "$(var traffic_light_classifier_model_path)/$(var pedestrian_traffic_light_classifier_model_name).onnx"
+ classifier_precision: fp16
+ classifier_mean: [123.675, 116.28, 103.53]
+ classifier_std: [58.395, 57.12, 57.375]
+ backlight_threshold: 0.85
+ classifier_type: 1 #classifier_type {hsv_filter: 0, cnn: 1}
+ classify_traffic_light_type: 1 #classify_traffic_light_type {car: 0, pedestrian:1}
diff --git a/perception/traffic_light_classifier/launch/traffic_light_classifier.launch.xml b/perception/traffic_light_classifier/launch/traffic_light_classifier.launch.xml
index e96f21b8ff01b..8348513e23c53 100644
--- a/perception/traffic_light_classifier/launch/traffic_light_classifier.launch.xml
+++ b/perception/traffic_light_classifier/launch/traffic_light_classifier.launch.xml
@@ -2,32 +2,14 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
-
-
-
-
-
-
+
-
diff --git a/perception/traffic_light_fine_detector/CMakeLists.txt b/perception/traffic_light_fine_detector/CMakeLists.txt
index f1f30a9da3195..fe9fa2ffcaa8b 100644
--- a/perception/traffic_light_fine_detector/CMakeLists.txt
+++ b/perception/traffic_light_fine_detector/CMakeLists.txt
@@ -101,6 +101,7 @@ if(TRT_AVAIL AND CUDA_AVAIL AND CUDNN_AVAIL)
ament_auto_package(INSTALL_TO_SHARE
launch
+ config
)
else()
@@ -108,5 +109,6 @@ else()
# to avoid launch file missing without a gpu
ament_auto_package(INSTALL_TO_SHARE
launch
+ config
)
endif()
diff --git a/perception/traffic_light_fine_detector/config/traffic_light_fine_detector.param.yaml b/perception/traffic_light_fine_detector/config/traffic_light_fine_detector.param.yaml
new file mode 100644
index 0000000000000..0265d0c4c7abb
--- /dev/null
+++ b/perception/traffic_light_fine_detector/config/traffic_light_fine_detector.param.yaml
@@ -0,0 +1,7 @@
+/**:
+ ros__parameters:
+ fine_detector_label_path: "$(var traffic_light_fine_detector_model_path)/$(var traffic_light_fine_detector_label_name)"
+ fine_detector_model_path: "$(var traffic_light_fine_detector_model_path)/$(var traffic_light_fine_detector_model_name).onnx"
+ fine_detector_precision: fp16
+ fine_detector_score_thresh: 0.3
+ fine_detector_nms_thresh: 0.65
diff --git a/perception/traffic_light_fine_detector/launch/traffic_light_fine_detector.launch.xml b/perception/traffic_light_fine_detector/launch/traffic_light_fine_detector.launch.xml
index d08378f3dd129..85bb79789af17 100644
--- a/perception/traffic_light_fine_detector/launch/traffic_light_fine_detector.launch.xml
+++ b/perception/traffic_light_fine_detector/launch/traffic_light_fine_detector.launch.xml
@@ -1,27 +1,17 @@
-
-
-
-
-
-
-
-
+
+
-
-
-
-
-
+