Skip to content

Commit

Permalink
fix: refactor
Browse files Browse the repository at this point in the history
Signed-off-by: badai-nguyen <[email protected]>
  • Loading branch information
badai-nguyen committed Jan 23, 2025
1 parent d5cfb5e commit abe46bb
Show file tree
Hide file tree
Showing 10 changed files with 199 additions and 101 deletions.
7 changes: 5 additions & 2 deletions launch/tier4_perception_launch/launch/perception.launch.xml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@

<!-- Traffic light recognition parameters -->
<arg name="use_traffic_light_recognition" default="false"/>
<arg name="traffic_light_recognition/enable_fine_detection" default="true"/>
<arg name="traffic_light_recognition/use_ml_detector" default="false" description="where ml model is used for TL detection"/>
<arg name="traffic_light_recognition/ml_detection_model_type" default="fine_detection_model" description="select ml model for TL detection: fine_detection_model or whole_image_detection_model"/>
<arg name="traffic_light_recognition/fusion_only" default="false"/>
<arg name="all_traffic_light_camera" default="[camera6, camera7]" description="choose camera which use for traffic light recognition"/>
<arg
Expand Down Expand Up @@ -296,7 +297,9 @@
<group if="$(var use_traffic_light_recognition)">
<push-ros-namespace namespace="traffic_light_recognition"/>
<include file="$(find-pkg-share tier4_perception_launch)/launch/traffic_light_recognition/traffic_light.launch.xml">
<arg name="enable_fine_detection" value="$(var traffic_light_recognition/enable_fine_detection)"/>
<arg name="use_ml_detector" value="$(var traffic_light_recognition/use_ml_detector)"/>
<arg name="ml_detection_model_type" value="$(var traffic_light_recognition/ml_detection_model_type)"/>
<arg name="whole_image_detector_model_path" value="$(var data_path)"/>
<arg name="fusion_only" value="$(var traffic_light_recognition/fusion_only)"/>
<arg name="all_camera_namespaces" value="$(var all_traffic_light_camera)"/>
<arg name="traffic_light_arbiter_param_path" value="$(var traffic_light_arbiter_param_path)"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?xml version="1.0"?>
<launch>
<arg name="enable_image_decompressor" default="true" description="enable image decompressor"/>
<arg name="enable_fine_detection" default="true" description="enable fine position adjustment of traffic light"/>
<arg name="use_ml_detector" default="true" description="enable fine position adjustment of traffic light"/>
<arg name="ml_detection_model_type" default="fine_detection_model" description="select ml model for TL detection: fine_detection_model or whole_image_detection_model"/>
<arg name="fusion_only" default="false" description="launch only occlusion_predictor and multi_camera_fusion"/>
<arg name="input/cloud" default="/sensing/lidar/top/pointcloud_raw_ex" description="point cloud for occlusion prediction"/>
<arg name="judged/traffic_signals" default="/perception/traffic_light_recognition/judged/traffic_signals"/>
Expand All @@ -13,6 +14,8 @@
<arg name="all_camera_namespaces" default="[camera6, camera7]"/>

<!-- ML parameters -->
<arg name="whole_image_detector_model_path" default="/home/autoware/autoware_data"/>
<arg name="whole_image_detector_model_name" default="tlr_car_ped_yolox_s_960_960_batch_1.onnx"/>
<arg name="fine_detector_param_path" default="$(find-pkg-share autoware_traffic_light_fine_detector)/config/traffic_light_fine_detector.param.yaml"/>
<arg name="car_classifier_param_path" default="$(find-pkg-share autoware_traffic_light_classifier)/config/car_traffic_light_classifier.param.yaml"/>
<arg name="pedestrian_classifier_param_path" default="$(find-pkg-share autoware_traffic_light_classifier)/config/pedestrian_traffic_light_classifier.param.yaml"/>
Expand All @@ -32,20 +35,37 @@
</include>
<include file="$(find-pkg-share tier4_perception_launch)/launch/traffic_light_recognition/traffic_light_map_based_detector.launch.py">
<arg name="all_camera_namespaces" value="$(var all_camera_namespaces)"/>
<arg name="enable_fine_detection" value="$(var enable_fine_detection)"/>
<arg name="use_ml_detector" value="$(var use_ml_detector)"/>
</include>
<include file="$(find-pkg-share tier4_perception_launch)/launch/traffic_light_recognition/traffic_light_node_container.launch.py">
<arg name="all_camera_namespaces" value="$(var all_camera_namespaces)"/>
<arg name="enable_image_decompressor" value="$(var enable_image_decompressor)"/>
<arg name="enable_fine_detection" value="$(var enable_fine_detection)"/>
<arg name="ml_detection_model_type" value="$(var ml_detection_model_type)"/>
<arg name="use_ml_detector" value="$(var use_ml_detector)"/>
<arg name="use_intra_process" value="true"/>
<arg name="use_multithread" value="true"/>
<arg name="whole_image_detector_model_path" value="$(var whole_image_detector_model_path)"/>
<arg name="whole_image_detector_model_name" value="$(var whole_image_detector_model_name)"/>
<arg name="fine_detector_param_path" value="$(var fine_detector_param_path)"/>
<arg name="car_classifier_param_path" value="$(var car_classifier_param_path)"/>
<arg name="pedestrian_classifier_param_path" value="$(var pedestrian_classifier_param_path)"/>
</include>
</group>

<group if="$(eval &quot;'$(var ml_detection_model_type)'=='whole_image_detection_model'&quot;)">
<include file="$(find-pkg-share autoware_traffic_light_signals_merger)/launch/traffic_light_signals_merger.launch.xml">
<arg name="all_camera_namespaces" value="$(var all_camera_namespaces)"/>
</include>
</group>

<!-- traffic_light_occlusion_predictor on each camera -->
<group if="$(eval &quot;'$(var ml_detection_model_type)'=='fine_detection_model'&quot;)">
<include file="$(find-pkg-share tier4_perception_launch)/launch/traffic_light_recognition/traffic_light_occlusion_predictor.launch.py">
<arg name="all_camera_namespaces" value="$(var all_camera_namespaces)"/>
<arg name="input/cloud" value="$(var input/cloud)"/>
</include>
</group>

<!-- traffic_light_multi_camera_fusion -->
<group>
<node pkg="autoware_traffic_light_multi_camera_fusion" exec="traffic_light_multi_camera_fusion_node" name="traffic_light_multi_camera_fusion" output="screen">
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def create_traffic_light_map_based_detector(namespace, context):

output_rois = (
"rough/rois"
if IfCondition(LaunchConfiguration("enable_fine_detection")).evaluate(context)
if IfCondition(LaunchConfiguration("use_ml_detector")).evaluate(context)
else f"/perception/traffic_light_recognition/{namespace}/detection/rois"
)

Expand All @@ -56,27 +56,6 @@ def create_traffic_light_map_based_detector(namespace, context):
return group


def create_traffic_light_detector(namespace, context):
package = FindPackageShare("tier4_perception_launch")
include = PathJoinSubstitution(
[package, "launch/traffic_light_recognition/traffic_light_detector.launch.xml"]
)
arguments = {
"namespace": namespace,
"use_decompress": "true",
}.items()

group = GroupAction(
[
PushRosNamespace(namespace),
PushRosNamespace("detection"),
IncludeLaunchDescription(include, launch_arguments=arguments),
]
)

return group


def launch_setup(context, *args, **kwargs):
# Load all camera namespaces
all_camera_namespaces = LaunchConfiguration("all_camera_namespaces").perform(context)
Expand All @@ -97,13 +76,6 @@ def launch_setup(context, *args, **kwargs):
create_traffic_light_map_based_detector(namespace, context)
for namespace in all_camera_namespaces
]

_ = [
traffic_light_recognition_containers.append(
create_traffic_light_detector(namespace, context)
)
for namespace in all_camera_namespaces
]
return traffic_light_recognition_containers


Expand All @@ -118,9 +90,9 @@ def add_launch_arg(name: str, default_value=None, description=None):

add_launch_arg("all_camera_namespaces", "[camera6, camera7]")
add_launch_arg(
"enable_fine_detection",
"use_ml_detector",
"True",
"If True, output_topic will be for fine detector, otherwise for classifier",
"If True, output_topic will be for ml detector, otherwise for classifier",
)

return launch.LaunchDescription(
Expand Down
Loading

0 comments on commit abe46bb

Please sign in to comment.