Skip to content

Commit de3e868

Browse files
committed
feat(intersection): consider abnormal violating vehicles
Signed-off-by: Mamoru Sobue <mamoru.sobue@tier4.jp>
1 parent e6de0f6 commit de3e868

8 files changed

+182
-87
lines changed

planning/behavior_velocity_intersection_module/src/debug.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,13 @@ visualization_msgs::msg::MarkerArray IntersectionModule::createDebugMarkerArray(
291291
&debug_marker_array);
292292
}
293293

294+
if (debug_data_.yield_area) {
295+
appendMarkerArray(
296+
::createLaneletPolygonsMarkerArray(
297+
debug_data_.yield_area.value(), "yield_area", lane_id_, 0.6588235, 0.34509, 0.6588235),
298+
&debug_marker_array);
299+
}
300+
294301
if (debug_data_.ego_lane) {
295302
appendMarkerArray(
296303
::createLaneletPolygonsMarkerArray(

planning/behavior_velocity_intersection_module/src/intersection_lanelets.hpp

+32-19
Original file line numberDiff line numberDiff line change
@@ -52,20 +52,29 @@ struct IntersectionLanelets
5252
{
5353
return is_prioritized_ ? attention_non_preceding_stoplines_ : attention_stoplines_;
5454
}
55+
const lanelet::ConstLanelets & attention_non_preceding() const
56+
{
57+
return attention_non_preceding_;
58+
}
5559
const lanelet::ConstLanelets & conflicting() const { return conflicting_; }
5660
const lanelet::ConstLanelets & adjacent() const { return adjacent_; }
5761
const lanelet::ConstLanelets & occlusion_attention() const
5862
{
5963
return is_prioritized_ ? attention_non_preceding_ : occlusion_attention_;
6064
}
61-
const lanelet::ConstLanelets & attention_non_preceding() const
65+
const lanelet::ConstLanelets & yield() const { return yield_; }
66+
const std::vector<std::optional<lanelet::ConstLineString3d>> & yield_stoplines() const
6267
{
63-
return attention_non_preceding_;
68+
return yield_stoplines_;
6469
}
6570
const std::vector<lanelet::CompoundPolygon3d> & attention_area() const
6671
{
6772
return is_prioritized_ ? attention_non_preceding_area_ : attention_area_;
6873
}
74+
const std::optional<lanelet::CompoundPolygon3d> & first_attention_area() const
75+
{
76+
return first_attention_area_;
77+
}
6978
const std::vector<lanelet::CompoundPolygon3d> & conflicting_area() const
7079
{
7180
return conflicting_area_;
@@ -75,6 +84,7 @@ struct IntersectionLanelets
7584
{
7685
return occlusion_attention_area_;
7786
}
87+
const std::vector<lanelet::CompoundPolygon3d> & yield_area() const { return yield_area_; }
7888
const std::optional<lanelet::ConstLanelet> & first_conflicting_lane() const
7989
{
8090
return first_conflicting_lane_;
@@ -87,10 +97,6 @@ struct IntersectionLanelets
8797
{
8898
return first_attention_lane_;
8999
}
90-
const std::optional<lanelet::CompoundPolygon3d> & first_attention_area() const
91-
{
92-
return first_attention_area_;
93-
}
94100
const std::optional<lanelet::ConstLanelet> & second_attention_lane() const
95101
{
96102
return second_attention_lane_;
@@ -103,48 +109,55 @@ struct IntersectionLanelets
103109
/**
104110
* the set of attention lanelets which is topologically merged
105111
*/
106-
lanelet::ConstLanelets attention_;
107-
std::vector<lanelet::CompoundPolygon3d> attention_area_;
112+
lanelet::ConstLanelets attention_{};
113+
std::vector<lanelet::CompoundPolygon3d> attention_area_{};
108114

109115
/**
110116
* the stop lines for each attention_lanelets associated with traffic lights. At intersection
111117
* without traffic lights, each value is null
112118
*/
113-
std::vector<std::optional<lanelet::ConstLineString3d>> attention_stoplines_;
119+
std::vector<std::optional<lanelet::ConstLineString3d>> attention_stoplines_{};
114120

115121
/**
116122
* the conflicting part of attention lanelets
117123
*/
118-
lanelet::ConstLanelets attention_non_preceding_;
119-
std::vector<lanelet::CompoundPolygon3d> attention_non_preceding_area_;
124+
lanelet::ConstLanelets attention_non_preceding_{};
125+
std::vector<lanelet::CompoundPolygon3d> attention_non_preceding_area_{};
120126

121127
/**
122128
* the stop lines for each attention_non_preceding_
123129
*/
124-
std::vector<std::optional<lanelet::ConstLineString3d>> attention_non_preceding_stoplines_;
130+
std::vector<std::optional<lanelet::ConstLineString3d>> attention_non_preceding_stoplines_{};
125131

126132
/**
127133
* the conflicting lanelets of the objective intersection lanelet
128134
*/
129-
lanelet::ConstLanelets conflicting_;
130-
std::vector<lanelet::CompoundPolygon3d> conflicting_area_;
135+
lanelet::ConstLanelets conflicting_{};
136+
std::vector<lanelet::CompoundPolygon3d> conflicting_area_{};
131137

132138
/**
133139
*
134140
*/
135-
lanelet::ConstLanelets adjacent_;
136-
std::vector<lanelet::CompoundPolygon3d> adjacent_area_;
141+
lanelet::ConstLanelets adjacent_{};
142+
std::vector<lanelet::CompoundPolygon3d> adjacent_area_{};
137143

138144
/**
139145
* the set of attention lanelets for occlusion detection which is topologically merged
140146
*/
141-
lanelet::ConstLanelets occlusion_attention_;
142-
std::vector<lanelet::CompoundPolygon3d> occlusion_attention_area_;
147+
lanelet::ConstLanelets occlusion_attention_{};
148+
std::vector<lanelet::CompoundPolygon3d> occlusion_attention_area_{};
149+
150+
/**
151+
* the set of lanelets that the objective intersection lanelet has RightOfWay over
152+
*/
153+
lanelet::ConstLanelets yield_{};
154+
std::vector<std::optional<lanelet::ConstLineString3d>> yield_stoplines_{};
155+
std::vector<lanelet::CompoundPolygon3d> yield_area_{};
143156

144157
/**
145158
* the vector of sum of each occlusion_attention lanelet
146159
*/
147-
std::vector<double> occlusion_attention_size_;
160+
std::vector<double> occlusion_attention_size_{};
148161

149162
/**
150163
* the first conflicting lanelet which ego path points intersect for the first time

planning/behavior_velocity_intersection_module/src/object_manager.cpp

+29-20
Original file line numberDiff line numberDiff line change
@@ -197,38 +197,47 @@ bool ObjectInfo::before_stopline_by(const double margin) const
197197
}
198198

199199
std::shared_ptr<ObjectInfo> ObjectInfoManager::registerObject(
200-
const unique_identifier_msgs::msg::UUID & uuid, const bool belong_attention_area,
201-
const bool belong_intersection_area, const bool is_parked_vehicle)
200+
const unique_identifier_msgs::msg::UUID & uuid, const bool belong_violating_area,
201+
const bool belong_attention_area, const bool belong_intersection_area,
202+
const bool is_parked_vehicle)
202203
{
203204
if (objects_info_.count(uuid) == 0) {
204205
auto object = std::make_shared<intersection::ObjectInfo>(uuid);
205206
objects_info_[uuid] = object;
206207
}
207208
auto object = objects_info_[uuid];
208-
if (belong_attention_area) {
209-
attention_area_objects_.push_back(object);
210-
} else if (belong_intersection_area) {
211-
intersection_area_objects_.push_back(object);
212-
}
213-
if (is_parked_vehicle) {
214-
parked_objects_.push_back(object);
209+
if (belong_violating_area) {
210+
violating_objects_.push_back(object);
211+
} else {
212+
if (belong_attention_area) {
213+
attention_area_objects_.push_back(object);
214+
} else if (belong_intersection_area) {
215+
intersection_area_objects_.push_back(object);
216+
}
217+
if (is_parked_vehicle) {
218+
parked_objects_.push_back(object);
219+
}
215220
}
216221
return object;
217222
}
218223

219224
void ObjectInfoManager::registerExistingObject(
220-
const unique_identifier_msgs::msg::UUID & uuid, const bool belong_attention_area,
221-
const bool belong_intersection_area, const bool is_parked_vehicle,
222-
std::shared_ptr<intersection::ObjectInfo> object)
225+
const unique_identifier_msgs::msg::UUID & uuid, const bool belong_violating_area,
226+
const bool belong_attention_area, const bool belong_intersection_area,
227+
const bool is_parked_vehicle, std::shared_ptr<intersection::ObjectInfo> object)
223228
{
224229
objects_info_[uuid] = object;
225-
if (belong_attention_area) {
226-
attention_area_objects_.push_back(object);
227-
} else if (belong_intersection_area) {
228-
intersection_area_objects_.push_back(object);
229-
}
230-
if (is_parked_vehicle) {
231-
parked_objects_.push_back(object);
230+
if (belong_violating_area) {
231+
violating_objects_.push_back(object);
232+
} else {
233+
if (belong_attention_area) {
234+
attention_area_objects_.push_back(object);
235+
} else if (belong_intersection_area) {
236+
intersection_area_objects_.push_back(object);
237+
}
238+
if (is_parked_vehicle) {
239+
parked_objects_.push_back(object);
240+
}
232241
}
233242
}
234243

@@ -240,7 +249,7 @@ void ObjectInfoManager::clearObjects()
240249
parked_objects_.clear();
241250
};
242251

243-
std::vector<std::shared_ptr<ObjectInfo>> ObjectInfoManager::allObjects() const
252+
std::vector<std::shared_ptr<ObjectInfo>> ObjectInfoManager::allAttentionObjects() const
244253
{
245254
std::vector<std::shared_ptr<ObjectInfo>> all_objects = attention_area_objects_;
246255
all_objects.insert(

planning/behavior_velocity_intersection_module/src/object_manager.hpp

+17-6
Original file line numberDiff line numberDiff line change
@@ -229,12 +229,12 @@ class ObjectInfoManager
229229
{
230230
public:
231231
std::shared_ptr<ObjectInfo> registerObject(
232-
const unique_identifier_msgs::msg::UUID & uuid, const bool belong_attention_area,
233-
const bool belong_intersection_area, const bool is_parked);
232+
const unique_identifier_msgs::msg::UUID & uuid, const bool belong_violating_area,
233+
const bool belong_attention_area, const bool belong_intersection_area, const bool is_parked);
234234

235235
void registerExistingObject(
236-
const unique_identifier_msgs::msg::UUID & uuid, const bool belong_attention_area,
237-
const bool belong_intersection_area, const bool is_parked,
236+
const unique_identifier_msgs::msg::UUID & uuid, const bool belong_violating_area,
237+
const bool belong_attention_area, const bool belong_intersection_area, const bool is_parked,
238238
std::shared_ptr<intersection::ObjectInfo> object);
239239

240240
void clearObjects();
@@ -244,9 +244,17 @@ class ObjectInfoManager
244244
return attention_area_objects_;
245245
}
246246

247-
const std::vector<std::shared_ptr<ObjectInfo>> & parkedObjects() const { return parked_objects_; }
247+
const std::vector<std::shared_ptr<ObjectInfo>> & parkedAttentionObjects() const
248+
{
249+
return parked_objects_;
250+
}
251+
252+
const std::vector<std::shared_ptr<ObjectInfo>> & violatingObjects() const
253+
{
254+
return violating_objects_;
255+
}
248256

249-
std::vector<std::shared_ptr<ObjectInfo>> allObjects() const;
257+
std::vector<std::shared_ptr<ObjectInfo>> allAttentionObjects() const;
250258

251259
const std::unordered_map<unique_identifier_msgs::msg::UUID, std::shared_ptr<ObjectInfo>> &
252260
getObjectsMap()
@@ -275,6 +283,9 @@ class ObjectInfoManager
275283
//! parked objects on attention_area/intersection_area
276284
std::vector<std::shared_ptr<ObjectInfo>> parked_objects_;
277285

286+
//! objects violating right of way
287+
std::vector<std::shared_ptr<ObjectInfo>> violating_objects_;
288+
278289
std::optional<rclcpp::Time> passed_1st_judge_line_first_time_{std::nullopt};
279290
std::optional<rclcpp::Time> passed_2nd_judge_line_first_time_{std::nullopt};
280291
};

planning/behavior_velocity_intersection_module/src/scene_intersection.hpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ class IntersectionModule : public SceneModuleInterface
224224
std::optional<lanelet::CompoundPolygon3d> ego_lane{std::nullopt};
225225
std::optional<geometry_msgs::msg::Polygon> stuck_vehicle_detect_area{std::nullopt};
226226
std::optional<std::vector<lanelet::CompoundPolygon3d>> yield_stuck_detect_area{std::nullopt};
227+
std::optional<std::vector<lanelet::CompoundPolygon3d>> yield_area{std::nullopt};
227228

228229
std::optional<geometry_msgs::msg::Polygon> candidate_collision_ego_lane_polygon{std::nullopt};
229230
autoware_auto_perception_msgs::msg::PredictedObjects safe_under_traffic_control_targets;
@@ -558,10 +559,7 @@ class IntersectionModule : public SceneModuleInterface
558559
/**
559560
* @brief generate IntersectionLanelets
560561
*/
561-
intersection::IntersectionLanelets generateObjectiveLanelets(
562-
lanelet::LaneletMapConstPtr lanelet_map_ptr,
563-
lanelet::routing::RoutingGraphPtr routing_graph_ptr,
564-
const lanelet::ConstLanelet assigned_lanelet) const;
562+
intersection::IntersectionLanelets generateObjectiveLanelets() const;
565563

566564
/**
567565
* @brief generate PathLanelets

planning/behavior_velocity_intersection_module/src/scene_intersection_collision.cpp

+37-20
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ void IntersectionModule::updateObjectInfoManagerArea()
7474
const auto lanelet_map_ptr = planner_data_->route_handler_->getLaneletMapPtr();
7575
const auto & assigned_lanelet = lanelet_map_ptr->laneletLayer.get(lane_id_);
7676
const auto intersection_area = util::getIntersectionArea(assigned_lanelet, lanelet_map_ptr);
77+
const auto & violating_lanelets = intersection_lanelets.yield();
78+
const auto & violating_stoplines = intersection_lanelets.yield_stoplines();
7779

7880
// ==========================================================================================
7981
// entries that are not observed in this iteration need to be cleared
@@ -104,37 +106,52 @@ void IntersectionModule::updateObjectInfoManagerArea()
104106
if (belong_adjacent_lanelet_id) {
105107
continue;
106108
}
107-
const auto belong_attention_lanelet_id =
108-
checkAngleForTargetLanelets(object_direction, attention_lanelets, is_parked_vehicle);
109-
const auto & obj_pos = predicted_object.kinematics.initial_pose_with_covariance.pose.position;
110-
const bool in_intersection_area = [&]() {
111-
if (!intersection_area) {
112-
return false;
113-
}
114-
return bg::within(
115-
tier4_autoware_utils::Point2d{obj_pos.x, obj_pos.y}, intersection_area.value());
116-
}();
109+
117110
std::optional<lanelet::ConstLanelet> attention_lanelet{std::nullopt};
118111
std::optional<lanelet::ConstLineString3d> stopline{std::nullopt};
119-
if (!belong_attention_lanelet_id && !in_intersection_area) {
120-
continue;
121-
} else if (belong_attention_lanelet_id) {
122-
const auto idx = belong_attention_lanelet_id.value();
123-
attention_lanelet = attention_lanelets.at(idx);
124-
stopline = attention_lanelet_stoplines.at(idx);
112+
113+
const auto belong_violating_lanelet_id = checkAngleForTargetLanelets(
114+
object_direction, violating_lanelets, false /* if is_parked, it is negligible */);
115+
bool is_violating_vehicle{false};
116+
if (belong_violating_lanelet_id) {
117+
const auto idx = belong_violating_lanelet_id.value();
118+
attention_lanelet = violating_lanelets.at(idx);
119+
stopline = violating_stoplines.at(idx);
120+
is_violating_vehicle = true;
121+
}
122+
123+
std::optional<size_t> belong_attention_lanelet_id{std::nullopt};
124+
bool in_intersection_area{false};
125+
if (!is_violating_vehicle) {
126+
belong_attention_lanelet_id =
127+
checkAngleForTargetLanelets(object_direction, attention_lanelets, is_parked_vehicle);
128+
in_intersection_area = [&]() {
129+
const auto & obj_pos =
130+
predicted_object.kinematics.initial_pose_with_covariance.pose.position;
131+
if (!intersection_area) {
132+
return false;
133+
}
134+
return bg::within(
135+
tier4_autoware_utils::Point2d{obj_pos.x, obj_pos.y}, intersection_area.value());
136+
}();
137+
if (belong_attention_lanelet_id) {
138+
const auto idx = belong_attention_lanelet_id.value();
139+
attention_lanelet = attention_lanelets.at(idx);
140+
stopline = attention_lanelet_stoplines.at(idx);
141+
}
125142
}
126143

127144
const auto object_it = old_map.find(predicted_object.object_id);
128145
if (object_it != old_map.end()) {
129146
auto object_info = object_it->second;
130147
object_info_manager_.registerExistingObject(
131-
predicted_object.object_id, belong_attention_lanelet_id.has_value(), in_intersection_area,
132-
is_parked_vehicle, object_info);
148+
predicted_object.object_id, is_violating_vehicle, belong_attention_lanelet_id.has_value(),
149+
in_intersection_area, is_parked_vehicle, object_info);
133150
object_info->initialize(predicted_object, attention_lanelet, stopline);
134151
} else {
135152
auto object_info = object_info_manager_.registerObject(
136-
predicted_object.object_id, belong_attention_lanelet_id.has_value(), in_intersection_area,
137-
is_parked_vehicle);
153+
predicted_object.object_id, is_violating_vehicle, belong_attention_lanelet_id.has_value(),
154+
in_intersection_area, is_parked_vehicle);
138155
object_info->initialize(predicted_object, attention_lanelet, stopline);
139156
}
140157
}

planning/behavior_velocity_intersection_module/src/scene_intersection_occlusion.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ IntersectionModule::OcclusionType IntersectionModule::detectOcclusion(
219219
// re-use attention_mask
220220
attention_mask = cv::Mat(width, height, CV_8UC1, cv::Scalar(0));
221221
// (3.1) draw all cells on attention_mask behind blocking vehicles as not occluded
222-
const auto & blocking_attention_objects = object_info_manager_.parkedObjects();
222+
const auto & blocking_attention_objects = object_info_manager_.parkedAttentionObjects();
223223
for (const auto & blocking_attention_object_info : blocking_attention_objects) {
224224
debug_data_.parked_targets.objects.push_back(
225225
blocking_attention_object_info->predicted_object());
@@ -403,7 +403,7 @@ IntersectionModule::OcclusionType IntersectionModule::detectOcclusion(
403403
LineString2d ego_occlusion_line;
404404
ego_occlusion_line.emplace_back(current_pose.position.x, current_pose.position.y);
405405
ego_occlusion_line.emplace_back(nearest_occlusion_point.point.x, nearest_occlusion_point.point.y);
406-
for (const auto & attention_object_info : object_info_manager_.allObjects()) {
406+
for (const auto & attention_object_info : object_info_manager_.allAttentionObjects()) {
407407
const auto obj_poly =
408408
tier4_autoware_utils::toPolygon2d(attention_object_info->predicted_object());
409409
if (bg::intersects(obj_poly, ego_occlusion_line)) {

0 commit comments

Comments
 (0)