Skip to content

Commit 7f9cdb6

Browse files
badai-nguyenpre-commit-ci[bot]MasatoSaeki
authored
feat(traffic_light_category_merger): add new traffic_light_category_merger package (#9748)
* feat: init traffic light signal merger Signed-off-by: badai-nguyen <dai.nguyen@tier4.jp> * fix: add tl merger launch Signed-off-by: badai-nguyen <dai.nguyen@tier4.jp> * fix: cmake lt merger Signed-off-by: badai-nguyen <dai.nguyen@tier4.jp> * fix: remove unused depend Signed-off-by: badai-nguyen <dai.nguyen@tier4.jp> * chore: pre-commit Signed-off-by: badai-nguyen <dai.nguyen@tier4.jp> * feat: add occlusion unknown classifier Signed-off-by: badai-nguyen <dai.nguyen@tier4.jp> * chore: docs Signed-off-by: badai-nguyen <dai.nguyen@tier4.jp> * fix: launcher Signed-off-by: badai-nguyen <dai.nguyen@tier4.jp> * style(pre-commit): autofix * Revert "feat: add occlusion unknown classifier" This reverts commit 9999d28. * fix: launcher Signed-off-by: badai-nguyen <dai.nguyen@tier4.jp> * refactor Signed-off-by: badai-nguyen <dai.nguyen@tier4.jp> * chore: add maintainer Signed-off-by: badai-nguyen <dai.nguyen@tier4.jp> * chore: docs update Signed-off-by: badai-nguyen <dai.nguyen@tier4.jp> * style(pre-commit): autofix * refactor: rename package Signed-off-by: badai-nguyen <dai.nguyen@tier4.jp> * fix: typo Signed-off-by: badai-nguyen <dai.nguyen@tier4.jp> * change output topic name Signed-off-by: MasatoSaeki <masato.saeki@tier4.jp> --------- Signed-off-by: badai-nguyen <dai.nguyen@tier4.jp> Signed-off-by: MasatoSaeki <masato.saeki@tier4.jp> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Masato Saeki <78376491+MasatoSaeki@users.noreply.github.com> Co-authored-by: MasatoSaeki <masato.saeki@tier4.jp>
1 parent 91c8501 commit 7f9cdb6

File tree

6 files changed

+207
-0
lines changed

6 files changed

+207
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
cmake_minimum_required(VERSION 3.8)
2+
project(autoware_traffic_light_category_merger)
3+
4+
# find dependencies
5+
find_package(autoware_cmake REQUIRED)
6+
autoware_package()
7+
8+
# Targets
9+
ament_auto_add_library(${PROJECT_NAME} SHARED
10+
src/traffic_light_category_merger_node.cpp
11+
)
12+
13+
rclcpp_components_register_node(${PROJECT_NAME}
14+
PLUGIN "autoware::traffic_light::TrafficLightCategoryMergerNode"
15+
EXECUTABLE traffic_light_category_merger_node)
16+
17+
18+
if(BUILD_TESTING)
19+
list(APPEND AMENT_LINT_AUTO_EXCLUDE ament_cmake_uncrustify)
20+
find_package(ament_lint_auto REQUIRED)
21+
ament_lint_auto_find_test_dependencies()
22+
23+
endif()
24+
25+
ament_auto_package(
26+
INSTALL_TO_SHARE
27+
launch
28+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
`autoware_traffic_light_category_merger`
2+
3+
## Overview
4+
5+
`autoware_traffic_light_category_merger` receives the Traffic Light (TL) classification result from Car/Pedestrian classifiers to merge into single classification result. The expect ROIs TL without classification result will be filled as Unknown.
6+
7+
## Input topics
8+
9+
| Name | Type | Description |
10+
| -------------------------- | --------------------------------------------- | ----------------------------- |
11+
| `input/car_signals` | tier4_perception_msgs::msg::TrafficLightArray | Car TLs classification |
12+
| `input/pedestrian_signals` | tier4_perception_msgs::msg::TrafficLightArray | Pedestrian TLs classification |
13+
14+
## Output topics
15+
16+
| Name | Type | Description |
17+
| ------------------------ | --------------------------------------------- | ------------------------------------- |
18+
| `output/traffic_signals` | tier4_perception_msgs::msg::TrafficLightArray | Car and Pedestrian TLs classification |
19+
20+
## Node parameters
21+
22+
N/A
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<launch>
2+
<!-- Output -->
3+
<arg name="input/car_signals" default="classified/car/traffic_signals"/>
4+
<arg name="input/pedestrian_signals" default="classified/pedestrian/traffic_signals"/>
5+
<arg name="output/traffic_signals" default="classification/traffic_signals"/>
6+
7+
<!-- Node -->
8+
<node pkg="autoware_traffic_light_category_merger" exec="traffic_light_category_merger_node" name="traffic_light_category_merger" output="screen">
9+
<remap from="input/car_signals" to="$(var input/car_signals)"/>
10+
<remap from="input/pedestrian_signals" to="$(var input/pedestrian_signals)"/>
11+
<remap from="output/traffic_signals" to="$(var output/traffic_signals)"/>
12+
</node>
13+
</launch>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0"?>
2+
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
3+
<package format="3">
4+
<name>autoware_traffic_light_category_merger</name>
5+
<version>0.0.0</version>
6+
<description>The ROS 2 autoware_traffic_light_category_merger package</description>
7+
<maintainer email="yoshi.ri@tier4.jp">Yoshi Ri</maintainer>
8+
<maintainer email="masato.saeki@tier4.jp">Masato Saeki</maintainer>
9+
<maintainer email="dai.nguyen@tier4.jp">Dai Nguyen</maintainer>
10+
<license>Apache License 2.0</license>
11+
<author email="dai.nguyen@tier4.jp">Dai Nguyen</author>
12+
13+
<buildtool_depend>ament_cmake_auto</buildtool_depend>
14+
15+
<depend>autoware_test_utils</depend>
16+
<depend>message_filters</depend>
17+
<depend>rclcpp</depend>
18+
<depend>rclcpp_components</depend>
19+
<depend>tier4_perception_msgs</depend>
20+
<build_depend>autoware_cmake</build_depend>
21+
22+
<export>
23+
<build_type>ament_cmake</build_type>
24+
</export>
25+
</package>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
// Copyright 2025 TIER IV, Inc.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#include "traffic_light_category_merger_node.hpp"
16+
17+
#include <memory>
18+
#include <string>
19+
#include <vector>
20+
21+
namespace autoware::traffic_light
22+
{
23+
24+
TrafficLightCategoryMergerNode::TrafficLightCategoryMergerNode(
25+
const rclcpp::NodeOptions & node_options)
26+
: rclcpp::Node("traffic_light_category_merger_node", node_options),
27+
tf_buffer_(get_clock()),
28+
tf_listener_(tf_buffer_),
29+
car_signal_sub_(this, "input/car_signals", rclcpp::QoS{1}.get_rmw_qos_profile()),
30+
pedestrian_signal_sub_(this, "input/pedestrian_signals", rclcpp::QoS{1}.get_rmw_qos_profile()),
31+
sync_(SyncPolicy(10), car_signal_sub_, pedestrian_signal_sub_)
32+
{
33+
using std::placeholders::_1;
34+
using std::placeholders::_2;
35+
sync_.registerCallback(std::bind(&TrafficLightCategoryMergerNode::signalsCallback, this, _1, _2));
36+
pub_traffic_light_signals_ =
37+
create_publisher<TrafficLightArray>("output/traffic_signals", rclcpp::QoS{1});
38+
}
39+
40+
void TrafficLightCategoryMergerNode::signalsCallback(
41+
const TrafficLightArray::ConstSharedPtr & car_signals_msg,
42+
const TrafficLightArray::ConstSharedPtr & pedestrian_signals_msg)
43+
{
44+
TrafficLightArray output;
45+
output.header = car_signals_msg->header;
46+
output.signals.insert(
47+
output.signals.end(), car_signals_msg->signals.begin(), car_signals_msg->signals.end());
48+
output.signals.insert(
49+
output.signals.end(), pedestrian_signals_msg->signals.begin(),
50+
pedestrian_signals_msg->signals.end());
51+
pub_traffic_light_signals_->publish(output);
52+
}
53+
54+
} // namespace autoware::traffic_light
55+
56+
#include "rclcpp_components/register_node_macro.hpp"
57+
RCLCPP_COMPONENTS_REGISTER_NODE(autoware::traffic_light::TrafficLightCategoryMergerNode)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
// Copyright 2025 TIER IV, Inc.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#ifndef TRAFFIC_LIGHT_CATEGORY_MERGER_NODE_HPP_
16+
#define TRAFFIC_LIGHT_CATEGORY_MERGER_NODE_HPP_
17+
18+
#include <autoware/universe_utils/ros/transform_listener.hpp>
19+
#include <rclcpp/rclcpp.hpp>
20+
21+
#include <tier4_perception_msgs/msg/traffic_light_array.hpp>
22+
23+
#include <message_filters/subscriber.h>
24+
#include <message_filters/sync_policies/approximate_time.h>
25+
#include <message_filters/synchronizer.h>
26+
27+
#include <chrono>
28+
#include <memory>
29+
#include <string>
30+
#include <vector>
31+
32+
namespace autoware::traffic_light
33+
{
34+
using tier4_perception_msgs::msg::TrafficLightArray;
35+
36+
class TrafficLightCategoryMergerNode : public rclcpp::Node
37+
{
38+
public:
39+
explicit TrafficLightCategoryMergerNode(const rclcpp::NodeOptions & node_options);
40+
41+
private:
42+
// Subscriber
43+
tf2_ros::Buffer tf_buffer_;
44+
tf2_ros::TransformListener tf_listener_;
45+
46+
message_filters::Subscriber<TrafficLightArray> car_signal_sub_;
47+
message_filters::Subscriber<TrafficLightArray> pedestrian_signal_sub_;
48+
49+
typedef message_filters::sync_policies::ApproximateTime<TrafficLightArray, TrafficLightArray>
50+
SyncPolicy;
51+
message_filters::Synchronizer<SyncPolicy> sync_;
52+
53+
void signalsCallback(
54+
const TrafficLightArray::ConstSharedPtr & car_signals_msg,
55+
const TrafficLightArray::ConstSharedPtr & pedestrian_signals_msg);
56+
57+
rclcpp::Publisher<TrafficLightArray>::SharedPtr pub_traffic_light_signals_;
58+
};
59+
60+
} // namespace autoware::traffic_light
61+
62+
#endif // TRAFFIC_LIGHT_CATEGORY_MERGER_NODE_HPP_

0 commit comments

Comments
 (0)