@@ -159,13 +159,17 @@ void TrafficLightEstimatorNode::onTrafficLightArray(const TrafficSignalArray::Co
159
159
}
160
160
161
161
for (const auto & crosswalk : conflicting_crosswalks_) {
162
+ const std::string related_vehicle_trafic_light =
163
+ crosswalk.attributeOr (" related_traffic_light" , " none" );
164
+
162
165
constexpr int VEHICLE_GRAPH_ID = 0 ;
163
166
const auto conflict_lls = overall_graphs_ptr_->conflictingInGraph (crosswalk, VEHICLE_GRAPH_ID);
164
167
165
168
bool has_left_green_lane = false ;
166
169
bool has_right_green_lane = false ;
167
170
bool has_straight_green_lane = false ;
168
171
bool has_straight_lane = false ;
172
+ bool related_green_traffic_light = false ;
169
173
170
174
lanelet::ConstLanelets green_lanes;
171
175
for (const auto & lanelet : conflict_lls) {
@@ -198,12 +202,18 @@ void TrafficLightEstimatorNode::onTrafficLightArray(const TrafficSignalArray::Co
198
202
if (highest_traffic_signal == TrafficLight::GREEN) {
199
203
is_green = true ;
200
204
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 ());
201
208
break ;
202
209
}
203
210
204
211
if (highest_traffic_signal == TrafficLight::UNKNOWN && was_green) {
205
212
is_green = true ;
206
213
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 ());
207
217
break ;
208
218
}
209
219
}
@@ -228,6 +238,8 @@ void TrafficLightEstimatorNode::onTrafficLightArray(const TrafficSignalArray::Co
228
238
is_red_crosswalk = !has_merge_lane && has_left_green_lane && has_right_green_lane;
229
239
}
230
240
241
+ is_red_crosswalk = is_red_crosswalk || related_green_traffic_light;
242
+
231
243
const auto tl_reg_elems_for_pedestrian =
232
244
crosswalk.regulatoryElementsAs <const lanelet::TrafficLight>();
233
245
for (const auto & tl_reg_elem_for_pedestrian : tl_reg_elems_for_pedestrian) {
0 commit comments