@@ -940,12 +940,11 @@ bool IntersectionModule::modifyPathVelocity(PathWithLaneId * path, StopReason *
940
940
return true ;
941
941
}
942
942
943
- static bool isGreenSolidOn (
944
- lanelet::ConstLanelet lane, const std::map<int , TrafficSignalStamped> & tl_infos)
943
+ bool IntersectionModule::isGreenSolidOn (lanelet::ConstLanelet lane)
945
944
{
946
945
using TrafficSignalElement = autoware_perception_msgs::msg::TrafficSignalElement;
947
946
948
- std::optional<int > tl_id = std::nullopt;
947
+ std::optional<lanelet::Id > tl_id = std::nullopt;
949
948
for (auto && tl_reg_elem : lane.regulatoryElementsAs <lanelet::TrafficLight>()) {
950
949
tl_id = tl_reg_elem->id ();
951
950
break ;
@@ -954,12 +953,13 @@ static bool isGreenSolidOn(
954
953
// this lane has no traffic light
955
954
return false ;
956
955
}
957
- const auto tl_info_it = tl_infos.find (tl_id.value ());
958
- if (tl_info_it == tl_infos.end ()) {
956
+ const auto tl_info_opt = planner_data_->getTrafficSignal (
957
+ tl_id.value (), true /* traffic light module keeps last observation*/ );
958
+ if (!tl_info_opt) {
959
959
// the info of this traffic light is not available
960
960
return false ;
961
961
}
962
- const auto & tl_info = tl_info_it-> second ;
962
+ const auto & tl_info = tl_info_opt. value () ;
963
963
for (auto && tl_light : tl_info.signal .elements ) {
964
964
if (
965
965
tl_light.color == TrafficSignalElement::GREEN &&
@@ -1004,8 +1004,7 @@ IntersectionModule::DecisionResult IntersectionModule::modifyPathVelocityDetail(
1004
1004
1005
1005
// at the very first time of regisTration of this module, the path may not be conflicting with the
1006
1006
// attention area, so update() is called to update the internal data as well as traffic light info
1007
- const auto traffic_prioritized_level =
1008
- getTrafficPrioritizedLevel (assigned_lanelet, planner_data_->traffic_light_id_map );
1007
+ const auto traffic_prioritized_level = getTrafficPrioritizedLevel (assigned_lanelet);
1009
1008
const bool is_prioritized =
1010
1009
traffic_prioritized_level == TrafficPrioritizedLevel::FULLY_PRIORITIZED;
1011
1010
intersection_lanelets.update (
@@ -1300,8 +1299,7 @@ IntersectionModule::DecisionResult IntersectionModule::modifyPathVelocityDetail(
1300
1299
// If there are any vehicles on the attention area when ego entered the intersection on green
1301
1300
// light, do pseudo collision detection because the vehicles are very slow and no collisions may
1302
1301
// be detected. check if ego vehicle entered assigned lanelet
1303
- const bool is_green_solid_on =
1304
- isGreenSolidOn (assigned_lanelet, planner_data_->traffic_light_id_map );
1302
+ const bool is_green_solid_on = isGreenSolidOn (assigned_lanelet);
1305
1303
if (is_green_solid_on) {
1306
1304
if (!initial_green_light_observed_time_) {
1307
1305
const auto assigned_lane_begin_point = assigned_lanelet.centerline ().front ();
@@ -1458,12 +1456,11 @@ IntersectionModule::DecisionResult IntersectionModule::modifyPathVelocityDetail(
1458
1456
}
1459
1457
}
1460
1458
1461
- TrafficPrioritizedLevel IntersectionModule::getTrafficPrioritizedLevel (
1462
- lanelet::ConstLanelet lane, const std::map<int , TrafficSignalStamped> & tl_infos)
1459
+ TrafficPrioritizedLevel IntersectionModule::getTrafficPrioritizedLevel (lanelet::ConstLanelet lane)
1463
1460
{
1464
1461
using TrafficSignalElement = autoware_perception_msgs::msg::TrafficSignalElement;
1465
1462
1466
- std::optional<int > tl_id = std::nullopt;
1463
+ std::optional<lanelet::Id > tl_id = std::nullopt;
1467
1464
for (auto && tl_reg_elem : lane.regulatoryElementsAs <lanelet::TrafficLight>()) {
1468
1465
tl_id = tl_reg_elem->id ();
1469
1466
break ;
@@ -1472,12 +1469,12 @@ TrafficPrioritizedLevel IntersectionModule::getTrafficPrioritizedLevel(
1472
1469
// this lane has no traffic light
1473
1470
return TrafficPrioritizedLevel::NOT_PRIORITIZED;
1474
1471
}
1475
- const auto tl_info_it = tl_infos. find (tl_id. value ());
1476
- if (tl_info_it == tl_infos. end ()) {
1477
- // the info of this traffic light is not available
1472
+ const auto tl_info_opt = planner_data_-> getTrafficSignal (
1473
+ tl_id. value (), true /* traffic light module keeps last observation */ );
1474
+ if (!tl_info_opt) {
1478
1475
return TrafficPrioritizedLevel::NOT_PRIORITIZED;
1479
1476
}
1480
- const auto & tl_info = tl_info_it-> second ;
1477
+ const auto & tl_info = tl_info_opt. value () ;
1481
1478
bool has_amber_signal{false };
1482
1479
for (auto && tl_light : tl_info.signal .elements ) {
1483
1480
if (tl_light.color == TrafficSignalElement::AMBER) {
0 commit comments