Skip to content

Commit 8936516

Browse files
committed
refactor: merge the 2 condition
Signed-off-by: Shumpei Wakabayashi <shumpei.wakabayashi@tier4.jp>
1 parent a8a7ec0 commit 8936516

File tree

1 file changed

+13
-19
lines changed

1 file changed

+13
-19
lines changed

Diff for: planning/behavior_path_planner_common/src/utils/drivable_area_expansion/static_drivable_area.cpp

+13-19
Original file line numberDiff line numberDiff line change
@@ -1564,8 +1564,10 @@ std::vector<geometry_msgs::msg::Point> postProcess(
15641564
findNearestSegmentIndexFromLateralDistance(tmp_bound, front_pose, M_PI_2);
15651565
const auto start_point =
15661566
calcLongitudinalOffsetStartPoint(tmp_bound, front_pose, front_start_idx, -front_length);
1567+
15671568
// Insert a start point
15681569
processed_bound.push_back(start_point);
1570+
15691571
const auto p_tmp =
15701572
geometry_msgs::build<Pose>().position(start_point).orientation(front_pose.orientation);
15711573
return findNearestSegmentIndexFromLateralDistance(tmp_bound, p_tmp, M_PI_2);
@@ -1585,27 +1587,19 @@ std::vector<geometry_msgs::msg::Point> postProcess(
15851587
return std::make_pair(goal_idx, goal_point);
15861588
}();
15871589

1588-
// Forward driving
1589-
if(start_idx < goal_idx){
1590-
for (size_t i = start_idx + 1; i <= goal_idx; ++i) {
1591-
const auto & next_point = tmp_bound.at(i);
1592-
const double dist = tier4_autoware_utils::calcDistance2d(processed_bound.back(), next_point);
1593-
if (dist > overlap_threshold) {
1594-
processed_bound.push_back(next_point);
1595-
}
1596-
}
1597-
}
1598-
// Backward driving
1599-
else{
1600-
for (size_t i = start_idx - 1; i >= goal_idx; --i) {
1601-
const auto & next_point = tmp_bound.at(i);
1602-
const double dist = tier4_autoware_utils::calcDistance2d(processed_bound.back(), next_point);
1603-
if (dist > overlap_threshold) {
1604-
processed_bound.push_back(next_point);
1605-
}
1590+
// Insert middle points
1591+
size_t step = (start_idx < goal_idx) ? 1 : -1;
1592+
for (size_t i = start_idx + step; i != goal_idx + step; i += step) {
1593+
const auto &next_point = tmp_bound.at(i);
1594+
const double dist = tier4_autoware_utils::calcDistance2d(processed_bound.back(), next_point);
1595+
if (dist > overlap_threshold) {
1596+
processed_bound.push_back(next_point);
16061597
}
16071598
}
1608-
if (tier4_autoware_utils::calcDistance2d(processed_bound.back(), goal_point) > overlap_threshold) {
1599+
1600+
// Insert a goal point
1601+
if (
1602+
tier4_autoware_utils::calcDistance2d(processed_bound.back(), goal_point) > overlap_threshold) {
16091603
processed_bound.push_back(goal_point);
16101604
}
16111605

0 commit comments

Comments
 (0)