Skip to content

Commit ef201bd

Browse files
committed
feat(traffic_light_estimator): support specialize tag
Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>
1 parent 53e40f6 commit ef201bd

File tree

1 file changed

+12
-0
lines changed
  • perception/traffic_light_estimator/src

1 file changed

+12
-0
lines changed

perception/traffic_light_estimator/src/node.cpp

+12
Original file line numberDiff line numberDiff line change
@@ -159,13 +159,17 @@ void TrafficLightEstimatorNode::onTrafficLightArray(const TrafficSignalArray::Co
159159
}
160160

161161
for (const auto & crosswalk : conflicting_crosswalks_) {
162+
const std::string related_vehicle_trafic_light =
163+
crosswalk.attributeOr("related_traffic_light", "none");
164+
162165
constexpr int VEHICLE_GRAPH_ID = 0;
163166
const auto conflict_lls = overall_graphs_ptr_->conflictingInGraph(crosswalk, VEHICLE_GRAPH_ID);
164167

165168
bool has_left_green_lane = false;
166169
bool has_right_green_lane = false;
167170
bool has_straight_green_lane = false;
168171
bool has_straight_lane = false;
172+
bool related_green_traffic_light = false;
169173

170174
lanelet::ConstLanelets green_lanes;
171175
for (const auto & lanelet : conflict_lls) {
@@ -198,12 +202,18 @@ void TrafficLightEstimatorNode::onTrafficLightArray(const TrafficSignalArray::Co
198202
if (highest_traffic_signal == TrafficLight::GREEN) {
199203
is_green = true;
200204
green_lanes.push_back(lanelet);
205+
related_green_traffic_light =
206+
related_green_traffic_light ||
207+
tl_reg_elem_for_vehicle->id() == std::atoi(related_vehicle_trafic_light.c_str());
201208
break;
202209
}
203210

204211
if (highest_traffic_signal == TrafficLight::UNKNOWN && was_green) {
205212
is_green = true;
206213
green_lanes.push_back(lanelet);
214+
related_green_traffic_light =
215+
related_green_traffic_light ||
216+
tl_reg_elem_for_vehicle->id() == std::atoi(related_vehicle_trafic_light.c_str());
207217
break;
208218
}
209219
}
@@ -228,6 +238,8 @@ void TrafficLightEstimatorNode::onTrafficLightArray(const TrafficSignalArray::Co
228238
is_red_crosswalk = !has_merge_lane && has_left_green_lane && has_right_green_lane;
229239
}
230240

241+
is_red_crosswalk = is_red_crosswalk || related_green_traffic_light;
242+
231243
const auto tl_reg_elems_for_pedestrian =
232244
crosswalk.regulatoryElementsAs<const lanelet::TrafficLight>();
233245
for (const auto & tl_reg_elem_for_pedestrian : tl_reg_elems_for_pedestrian) {

0 commit comments

Comments
 (0)