@@ -190,15 +190,15 @@ IntersectionModule::prepareIntersectionData(const bool is_prioritized, PathWithL
190
190
}
191
191
192
192
if (!intersection_lanelets_) {
193
- intersection_lanelets_ =
194
- generateObjectiveLanelets (lanelet_map_ptr, routing_graph_ptr, assigned_lanelet);
193
+ intersection_lanelets_ = generateObjectiveLanelets ();
195
194
}
196
195
auto & intersection_lanelets = intersection_lanelets_.value ();
197
196
debug_data_.attention_area = intersection_lanelets.attention_area ();
198
197
debug_data_.first_attention_area = intersection_lanelets.first_attention_area ();
199
198
debug_data_.second_attention_area = intersection_lanelets.second_attention_area ();
200
199
debug_data_.occlusion_attention_area = intersection_lanelets.occlusion_attention_area ();
201
200
debug_data_.adjacent_area = intersection_lanelets.adjacent_area ();
201
+ debug_data_.yield_area = intersection_lanelets.yield_area ();
202
202
203
203
// ==========================================================================================
204
204
// at the very first time of registration of this module, the path may not be conflicting with
@@ -573,25 +573,18 @@ IntersectionModule::generateIntersectionStopLines(
573
573
return intersection_stoplines;
574
574
}
575
575
576
- intersection::IntersectionLanelets IntersectionModule::generateObjectiveLanelets (
577
- lanelet::LaneletMapConstPtr lanelet_map_ptr, lanelet::routing::RoutingGraphPtr routing_graph_ptr,
578
- const lanelet::ConstLanelet assigned_lanelet) const
576
+ intersection::IntersectionLanelets IntersectionModule::generateObjectiveLanelets () const
579
577
{
578
+ const auto lanelet_map_ptr = planner_data_->route_handler_ ->getLaneletMapPtr ();
579
+ const auto routing_graph_ptr = planner_data_->route_handler_ ->getRoutingGraphPtr ();
580
+ const auto & assigned_lanelet = lanelet_map_ptr->laneletLayer .get (lane_id_);
581
+
580
582
const double detection_area_length = planner_param_.common .attention_area_length ;
581
583
const double occlusion_detection_area_length =
582
584
planner_param_.occlusion .occlusion_attention_area_length ;
583
585
const bool consider_wrong_direction_vehicle =
584
586
planner_param_.collision_detection .consider_wrong_direction_vehicle ;
585
587
586
- // retrieve a stopline associated with a traffic light
587
- bool has_traffic_light = false ;
588
- if (const auto tl_reg_elems = assigned_lanelet.regulatoryElementsAs <lanelet::TrafficLight>();
589
- tl_reg_elems.size () != 0 ) {
590
- const auto tl_reg_elem = tl_reg_elems.front ();
591
- const auto stopline_opt = tl_reg_elem->stopLine ();
592
- if (!!stopline_opt) has_traffic_light = true ;
593
- }
594
-
595
588
// for low priority lane
596
589
// if ego_lane has right of way (i.e. is high priority),
597
590
// ignore yieldLanelets (i.e. low priority lanes)
@@ -644,7 +637,7 @@ intersection::IntersectionLanelets IntersectionModule::generateObjectiveLanelets
644
637
}
645
638
646
639
// exclude yield lanelets and ego lanelets from detection_lanelets
647
- if (turn_direction_ == std::string (" straight" ) && has_traffic_light ) {
640
+ if (turn_direction_ == std::string (" straight" ) && has_traffic_light_ ) {
648
641
// if assigned lanelet is "straight" with traffic light, detection area is not necessary
649
642
} else {
650
643
if (consider_wrong_direction_vehicle) {
@@ -724,6 +717,15 @@ intersection::IntersectionLanelets IntersectionModule::generateObjectiveLanelets
724
717
auto [attention_lanelets, original_attention_lanelet_sequences] =
725
718
util::mergeLaneletsByTopologicalSort (detection_and_preceding_lanelets, routing_graph_ptr);
726
719
720
+ const auto adjacents = planning_utils::getConstLaneletsFromIds (lanelet_map_ptr, associative_ids_);
721
+ // yield
722
+ lanelet::ConstLanelets yield{};
723
+ for (const auto & conflicting : conflicting_ex_ego_lanelets) {
724
+ if (!lanelet::utils::contains (adjacents, conflicting)) {
725
+ yield.push_back (conflicting);
726
+ }
727
+ }
728
+
727
729
intersection::IntersectionLanelets result;
728
730
result.attention_ = std::move (attention_lanelets);
729
731
for (const auto & original_attention_lanelet_seq : original_attention_lanelet_sequences) {
@@ -743,6 +745,7 @@ intersection::IntersectionLanelets IntersectionModule::generateObjectiveLanelets
743
745
}
744
746
result.attention_stoplines_ .push_back (stopline);
745
747
}
748
+
746
749
result.attention_non_preceding_ = std::move (detection_lanelets);
747
750
for (unsigned i = 0 ; i < result.attention_non_preceding_ .size (); ++i) {
748
751
std::optional<lanelet::ConstLineString3d> stopline = std::nullopt;
@@ -752,11 +755,42 @@ intersection::IntersectionLanelets IntersectionModule::generateObjectiveLanelets
752
755
const auto stopline_opt = traffic_light->stopLine ();
753
756
if (!stopline_opt) continue ;
754
757
stopline = stopline_opt.get ();
758
+ break ;
755
759
}
756
760
result.attention_non_preceding_stoplines_ .push_back (stopline);
757
761
}
762
+
763
+ result.yield_ = std::move (yield);
764
+ for (unsigned i = 0 ; i < result.yield_ .size (); ++i) {
765
+ std::optional<lanelet::ConstLineString3d> stopline = std::nullopt;
766
+ const auto & ll = result.yield_ .at (i);
767
+ // ==========================================================================================
768
+ // NOTE: for yield_lanes we should prioritize road_marking stopline over traffic light stopline
769
+ // ==========================================================================================
770
+ const auto traffic_lights = ll.regulatoryElementsAs <lanelet::TrafficLight>();
771
+ for (const auto & traffic_light : traffic_lights) {
772
+ const auto stopline_opt = traffic_light->stopLine ();
773
+ if (!stopline_opt) continue ;
774
+ stopline = stopline_opt.get ();
775
+ break ;
776
+ }
777
+ const auto road_markings = ll.regulatoryElementsAs <lanelet::autoware::RoadMarking>();
778
+ for (const auto & road_marking : road_markings) {
779
+ const std::string type =
780
+ road_marking->roadMarking ().attributeOr (lanelet::AttributeName::Type, " none" );
781
+ if (type == lanelet::AttributeValueString::StopLine) {
782
+ stopline = road_marking->roadMarking ();
783
+ break ;
784
+ }
785
+ }
786
+ if (stopline)
787
+ RCLCPP_INFO (
788
+ logger_, " for yield lane %ld, stopline id is %ld" , ll.id (), stopline.value ().id ());
789
+ result.yield_stoplines_ .push_back (stopline);
790
+ }
791
+
758
792
result.conflicting_ = std::move (conflicting_ex_ego_lanelets);
759
- result.adjacent_ = planning_utils::getConstLaneletsFromIds (lanelet_map_ptr, associative_ids_) ;
793
+ result.adjacent_ = adjacents ;
760
794
// NOTE: occlusion_attention is not inverted here
761
795
// TODO(Mamoru Sobue): apply mergeLaneletsByTopologicalSort for occlusion lanelets as well and
762
796
// then trim part of them based on curvature threshold
@@ -771,6 +805,7 @@ intersection::IntersectionLanelets IntersectionModule::generateObjectiveLanelets
771
805
result.conflicting_area_ = util::getPolygon3dFromLanelets (result.conflicting_ );
772
806
result.adjacent_area_ = util::getPolygon3dFromLanelets (result.adjacent_ );
773
807
result.occlusion_attention_area_ = util::getPolygon3dFromLanelets (result.occlusion_attention_ );
808
+ result.yield_area_ = util::getPolygon3dFromLanelets (result.yield_ );
774
809
return result;
775
810
}
776
811
0 commit comments