Skip to content

Commit 8ae2419

Browse files
committed
fix(autoware_crosswalk_traffic_light_estimator) : add process that guard access to empty elements.
Signed-off-by: k-hazama-esol <k-hazama@esol.co.jp>
1 parent 5cec580 commit 8ae2419

File tree

1 file changed

+10
-1
lines changed
  • perception/autoware_crosswalk_traffic_light_estimator/src

1 file changed

+10
-1
lines changed

perception/autoware_crosswalk_traffic_light_estimator/src/node.cpp

+10-1
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,11 @@ void CrosswalkTrafficLightEstimatorNode::setCrosswalkTrafficSignal(
303303
output_traffic_signal_element.color = color;
304304
output_traffic_signal_element.shape = TrafficSignalElement::CIRCLE;
305305
output_traffic_signal_element.confidence = 1.0;
306-
output.traffic_light_groups[idx].elements[0] = output_traffic_signal_element;
306+
if (output.traffic_light_groups[idx].elements.empty()) {
307+
output.traffic_light_groups[idx].elements.push_back(output_traffic_signal_element);
308+
} else {
309+
output.traffic_light_groups[idx].elements[0] = output_traffic_signal_element;
310+
}
307311
continue;
308312
}
309313
updateFlashingState(signal); // check if it is flashing
@@ -325,6 +329,10 @@ void CrosswalkTrafficLightEstimatorNode::setCrosswalkTrafficSignal(
325329
bool CrosswalkTrafficLightEstimatorNode::isInvalidDetectionStatus(
326330
const TrafficSignal & signal) const
327331
{
332+
// invalid if elements is empty
333+
if (signal.elements.empty()) {
334+
return true;
335+
}
328336
// check occlusion, backlight(shape is unknown) and no detection(shape is circle)
329337
if (
330338
signal.elements.front().color == TrafficSignalElement::UNKNOWN &&
@@ -347,6 +355,7 @@ void CrosswalkTrafficLightEstimatorNode::updateFlashingState(const TrafficSignal
347355

348356
// flashing green
349357
if (
358+
!signal.elements.empty() &&
350359
signal.elements.front().color == TrafficSignalElement::UNKNOWN &&
351360
signal.elements.front().confidence != 0 && // not due to occlusion
352361
current_color_state_.at(id) != TrafficSignalElement::UNKNOWN) {

0 commit comments

Comments
 (0)