Skip to content

Commit

Permalink
feat(traffic_light_estimator): add flag to use last detect signal
Browse files Browse the repository at this point in the history
Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>
  • Loading branch information
satoshi-ota committed Jun 29, 2022
1 parent dcf02bc commit 420dc7c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ class TrafficLightEstimatorNode : public rclcpp::Node

uint8_t getLastDetectedTrafficSignal(const lanelet::Id & id) const;

// Node param
bool use_last_detect_color_;

// Signal history
std::unordered_map<uint32_t, uint8_t> last_detect_color_;

Expand Down
4 changes: 3 additions & 1 deletion perception/traffic_light_estimator/src/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ TrafficLightEstimatorNode::TrafficLightEstimatorNode(const rclcpp::NodeOptions &
{
using std::placeholders::_1;

use_last_detect_color_ = this->declare_parameter("use_last_detect_color", true);

sub_map_ = create_subscription<HADMapBin>(
"~/input/vector_map", rclcpp::QoS{1}.transient_local(),
std::bind(&TrafficLightEstimatorNode::onMap, this, _1));
Expand Down Expand Up @@ -231,7 +233,7 @@ lanelet::ConstLanelets TrafficLightEstimatorNode::getGreenLanelets(

const auto last_detected_signal = getLastDetectedTrafficSignal(tl_reg_elem->id());
const auto was_green = current_detected_signal == TrafficLight::UNKNOWN &&
last_detected_signal == TrafficLight::GREEN;
last_detected_signal == TrafficLight::GREEN && use_last_detect_color_;

updateLastDetectedSignal(tl_reg_elem->id(), current_detected_signal);

Expand Down

0 comments on commit 420dc7c

Please sign in to comment.