Skip to content

Commit

Permalink
Merge pull request #1705 from tier4/tmp/beta/x2_gen2/v0.29.0/overwrit…
Browse files Browse the repository at this point in the history
…e_invalid_detection_result

feat(autoware_crosswalk_traffic_light_estimator): overwrite invalid detection result
  • Loading branch information
YoshiRi authored Dec 17, 2024
2 parents 3326ba5 + 360b561 commit 2934293
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ class CrosswalkTrafficLightEstimatorNode : public rclcpp::Node

void removeDuplicateIds(TrafficSignalArray & signal_array) const;

bool isInvalidDetectionStatus(const TrafficSignal & signal) const;

// Node param
bool use_last_detect_color_;
double last_detect_color_hold_time_;
Expand Down
21 changes: 21 additions & 0 deletions perception/autoware_crosswalk_traffic_light_estimator/src/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,14 @@ void CrosswalkTrafficLightEstimatorNode::setCrosswalkTrafficSignal(
if (valid_id2idx_map.count(id)) {
size_t idx = valid_id2idx_map[id];
auto signal = msg.traffic_light_groups[idx];
if (isInvalidDetectionStatus(signal)) {
TrafficSignalElement output_traffic_signal_element;
output_traffic_signal_element.color = color;
output_traffic_signal_element.shape = TrafficSignalElement::CIRCLE;
output_traffic_signal_element.confidence = 1.0;
output.traffic_light_groups[idx].elements[0] = output_traffic_signal_element;
continue;
}
updateFlashingState(signal); // check if it is flashing
// update output msg according to flashing and current state
output.traffic_light_groups[idx].elements[0].color = updateAndGetColorState(signal);
Expand All @@ -311,6 +319,19 @@ void CrosswalkTrafficLightEstimatorNode::setCrosswalkTrafficSignal(
}
}

bool CrosswalkTrafficLightEstimatorNode::isInvalidDetectionStatus(
const TrafficSignal & signal) const
{
// check occlusion, backlight(shape is unknown) and no detection(shape is circle)
if (
signal.elements.front().color == TrafficSignalElement::UNKNOWN &&
signal.elements.front().confidence == 0.0) {
return true;
}

return false;
}

void CrosswalkTrafficLightEstimatorNode::updateFlashingState(const TrafficSignal & signal)
{
const auto id = signal.traffic_light_group_id;
Expand Down

0 comments on commit 2934293

Please sign in to comment.