Skip to content

Commit 40decbe

Browse files
soblinkarishma1911
authored andcommitted
fix((merge_from_private): fixed first attention lanelet calculation (autowarefoundation#6030)
Signed-off-by: Mamoru Sobue <mamoru.sobue@tier4.jp>
1 parent b6c4765 commit 40decbe

File tree

2 files changed

+29
-46
lines changed

2 files changed

+29
-46
lines changed

planning/behavior_velocity_intersection_module/src/scene_merge_from_private_road.cpp

+28-43
Original file line numberDiff line numberDiff line change
@@ -108,27 +108,26 @@ bool MergeFromPrivateRoadModule::modifyPathVelocity(PathWithLaneId * path, StopR
108108
return false;
109109
}
110110

111+
const double baselink2front = planner_data_->vehicle_info_.max_longitudinal_offset_m;
111112
const auto local_footprint = planner_data_->vehicle_info_.createFootprint(0.0, 0.0);
112113
if (!first_conflicting_lanelet_) {
113-
const auto & assigned_lanelet = lanelet_map_ptr->laneletLayer.get(lane_id_);
114-
const auto conflicting_lanelets =
115-
lanelet::utils::getConflictingLanelets(routing_graph_ptr, assigned_lanelet);
114+
const auto conflicting_lanelets = getAttentionLanelets();
116115
first_conflicting_lanelet_ = getFirstConflictingLanelet(
117-
conflicting_lanelets, interpolated_path_info, local_footprint,
118-
planner_data_->vehicle_info_.max_longitudinal_offset_m);
116+
conflicting_lanelets, interpolated_path_info, local_footprint, baselink2front);
119117
}
120118
if (!first_conflicting_lanelet_) {
121119
return false;
122120
}
123121
const auto first_conflicting_lanelet = first_conflicting_lanelet_.value();
124122

125123
const auto first_conflicting_idx_opt = getFirstPointInsidePolygonByFootprint(
126-
first_conflicting_lanelet.polygon3d(), interpolated_path_info, local_footprint,
127-
planner_data_->vehicle_info_.max_longitudinal_offset_m);
124+
first_conflicting_lanelet.polygon3d(), interpolated_path_info, local_footprint, baselink2front);
128125
if (!first_conflicting_idx_opt) {
129126
return false;
130127
}
131-
const auto stopline_idx_ip = first_conflicting_idx_opt.value();
128+
const auto stopline_idx_ip = static_cast<size_t>(std::max<int>(
129+
0, static_cast<int>(first_conflicting_idx_opt.value()) -
130+
static_cast<int>(baselink2front / planner_param_.path_interpolation_ds)));
132131

133132
const auto stopline_idx_opt = util::insertPointIndex(
134133
interpolated_path_info.path.points.at(stopline_idx_ip).point.pose, path,
@@ -139,8 +138,7 @@ bool MergeFromPrivateRoadModule::modifyPathVelocity(PathWithLaneId * path, StopR
139138
}
140139
const auto stopline_idx = stopline_idx_opt.value();
141140

142-
debug_data_.virtual_wall_pose = planning_utils::getAheadPose(
143-
stopline_idx, planner_data_->vehicle_info_.max_longitudinal_offset_m, *path);
141+
debug_data_.virtual_wall_pose = planning_utils::getAheadPose(stopline_idx, baselink2front, *path);
144142
debug_data_.stop_point_pose = path->points.at(stopline_idx).point.pose;
145143

146144
/* set stop speed */
@@ -174,46 +172,33 @@ bool MergeFromPrivateRoadModule::modifyPathVelocity(PathWithLaneId * path, StopR
174172
return true;
175173
}
176174

177-
autoware_auto_planning_msgs::msg::PathWithLaneId
178-
MergeFromPrivateRoadModule::extractPathNearExitOfPrivateRoad(
179-
const autoware_auto_planning_msgs::msg::PathWithLaneId & path, const double extend_length)
175+
lanelet::ConstLanelets MergeFromPrivateRoadModule::getAttentionLanelets() const
180176
{
181-
if (path.points.size() < 2) {
182-
return path;
183-
}
184-
185-
autoware_auto_planning_msgs::msg::PathWithLaneId private_path = path;
186-
private_path.points.clear();
177+
const auto lanelet_map_ptr = planner_data_->route_handler_->getLaneletMapPtr();
178+
const auto routing_graph_ptr = planner_data_->route_handler_->getRoutingGraphPtr();
187179

188-
double sum_dist = 0.0;
189-
bool prev_has_target_lane_id = false;
190-
for (int i = static_cast<int>(path.points.size()) - 2; i >= 0; i--) {
191-
bool has_target_lane_id = false;
192-
for (const auto path_id : path.points.at(i).lane_ids) {
193-
if (path_id == lane_id_) {
194-
has_target_lane_id = true;
180+
const auto & assigned_lanelet = lanelet_map_ptr->laneletLayer.get(lane_id_);
181+
const auto conflicting_lanelets =
182+
lanelet::utils::getConflictingLanelets(routing_graph_ptr, assigned_lanelet);
183+
lanelet::ConstLanelets sibling_lanelets;
184+
for (const auto & previous_lanelet : routing_graph_ptr->previous(assigned_lanelet)) {
185+
sibling_lanelets.push_back(previous_lanelet);
186+
for (const auto & following_lanelet : routing_graph_ptr->following(previous_lanelet)) {
187+
if (lanelet::utils::contains(sibling_lanelets, following_lanelet)) {
188+
continue;
195189
}
190+
sibling_lanelets.push_back(following_lanelet);
196191
}
197-
if (has_target_lane_id) {
198-
// add path point with target lane id
199-
// (lanelet with target lane id is exit of private road)
200-
private_path.points.emplace_back(path.points.at(i));
201-
prev_has_target_lane_id = true;
192+
}
193+
194+
lanelet::ConstLanelets attention_lanelets;
195+
for (const auto & conflicting_lanelet : conflicting_lanelets) {
196+
if (lanelet::utils::contains(sibling_lanelets, conflicting_lanelet)) {
202197
continue;
203198
}
204-
if (prev_has_target_lane_id) {
205-
// extend path to the front
206-
private_path.points.emplace_back(path.points.at(i));
207-
sum_dist += tier4_autoware_utils::calcDistance2d(
208-
path.points.at(i).point.pose, path.points.at(i + 1).point.pose);
209-
if (sum_dist > extend_length) {
210-
break;
211-
}
212-
}
199+
attention_lanelets.push_back(conflicting_lanelet);
213200
}
214-
215-
std::reverse(private_path.points.begin(), private_path.points.end());
216-
return private_path;
201+
return attention_lanelets;
217202
}
218203

219204
} // namespace behavior_velocity_planner

planning/behavior_velocity_intersection_module/src/scene_merge_from_private_road.hpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,12 @@ class MergeFromPrivateRoadModule : public SceneModuleInterface
7373
motion_utils::VirtualWalls createVirtualWalls() override;
7474

7575
const std::set<lanelet::Id> & getAssociativeIds() const { return associative_ids_; }
76+
lanelet::ConstLanelets getAttentionLanelets() const;
7677

7778
private:
7879
const int64_t lane_id_;
7980
const std::set<lanelet::Id> associative_ids_;
8081

81-
autoware_auto_planning_msgs::msg::PathWithLaneId extractPathNearExitOfPrivateRoad(
82-
const autoware_auto_planning_msgs::msg::PathWithLaneId & path, const double extend_length);
83-
8482
// Parameter
8583
PlannerParam planner_param_;
8684
std::optional<lanelet::ConstLanelet> first_conflicting_lanelet_;

0 commit comments

Comments
 (0)