Skip to content

Commit 9b3798a

Browse files
tmp
Signed-off-by: Zulfaqar Azmi <zulfaqar.azmi@tier4.jp>
1 parent 379c6c8 commit 9b3798a

File tree

2 files changed

+41
-45
lines changed

2 files changed

+41
-45
lines changed

planning/behavior_path_lane_change_module/src/scene.cpp

+39-43
Original file line numberDiff line numberDiff line change
@@ -1679,13 +1679,13 @@ bool NormalLaneChange::getLaneChangePaths(
16791679

16801680
const auto is_safe = std::invoke([&]() {
16811681
const auto safety_check_with_normal_rss = isLaneChangePathSafe(
1682-
*candidate_path, target_objects, common_data_ptr_->lc_param_ptr->rss_params,
1682+
*candidate_path, target_objects, common_data_ptr_->lc_param_ptr->rss_params, 1,
16831683
lane_change_debug_.collision_check_objects);
16841684

16851685
if (!safety_check_with_normal_rss.is_safe && is_stuck) {
16861686
const auto safety_check_with_stuck_rss = isLaneChangePathSafe(
16871687
*candidate_path, target_objects, common_data_ptr_->lc_param_ptr->rss_params_for_stuck,
1688-
lane_change_debug_.collision_check_objects);
1688+
1, lane_change_debug_.collision_check_objects);
16891689
return safety_check_with_stuck_rss.is_safe;
16901690
}
16911691

@@ -2108,7 +2108,8 @@ bool NormalLaneChange::calcAbortPath()
21082108
}
21092109

21102110
PathSafetyStatus NormalLaneChange::isLaneChangePathSafe(
2111-
const LaneChangePath & lane_change_path, const ExtendedPredictedObjects & collision_check_objects,
2111+
const LaneChangePath & lane_change_path,
2112+
const lane_change::TargetObjects & collision_check_objects,
21122113
const utils::path_safety_checker::RSSparams & rss_params, const size_t deceleration_sampling_num,
21132114
CollisionCheckDebugMap & debug_data) const
21142115
{
@@ -2129,29 +2130,28 @@ PathSafetyStatus NormalLaneChange::isLaneChangePathSafe(
21292130
return {!is_safe, !is_object_behind_ego};
21302131
}
21312132

2132-
const double & time_resolution = lane_change_parameters_->prediction_time_resolution;
21332133
const double current_acc = lane_change_path.info.longitudinal_acceleration.lane_changing;
21342134
const double min_acc = std::min(current_acc, common_parameters.min_acc);
21352135
const auto sampling_num =
21362136
std::abs(min_acc - current_acc) > 1.0E-03 ? deceleration_sampling_num : 1;
21372137
const double acc_resolution = (min_acc - current_acc) / static_cast<double>(sampling_num);
21382138

2139-
double acceleration = current_acc;
2140-
for (size_t i = 0; i < static_cast<size_t>(sampling_num); ++i, acceleration += acc_resolution) {
2141-
const auto ego_predicted_path = utils::lane_change::convertToPredictedPath(
2142-
lane_change_path, current_twist, current_pose, acceleration, common_parameters,
2143-
*lane_change_parameters_, time_resolution);
2144-
const auto debug_predicted_path =
2145-
utils::path_safety_checker::convertToPredictedPath(ego_predicted_path, time_resolution);
2139+
std::vector<double> acceleration_values(sampling_num);
2140+
std::iota(acceleration_values.begin(), acceleration_values.end(), 0);
21462141

2147-
const auto & current_lanes_polygon = common_data_ptr_->lanes_polygon_ptr->current;
2148-
const auto & expanded_target_polygon = common_data_ptr_->lanes_polygon_ptr->expanded_target;
2142+
std::transform(
2143+
acceleration_values.begin(), acceleration_values.end(), acceleration_values.begin(),
2144+
[&](double n) { return current_acc + n * acc_resolution; });
21492145

2150-
const auto check_collision = [&](const ExtendedPredictedObject & obj) {
2146+
const auto time_resolution = lane_change_parameters_->prediction_time_resolution;
2147+
2148+
const auto & current_lanes_polygon = common_data_ptr_->lanes_polygon_ptr->current;
2149+
const auto & expanded_target_polygon = common_data_ptr_->lanes_polygon_ptr->expanded_target;
2150+
2151+
const auto check_collision = [&](const ExtendedPredictedObject & obj, const std::vector<PoseWithVelocityStamped> & ego_predicted_path) {
21512152
auto current_debug_data = utils::path_safety_checker::createObjectDebug(obj);
21522153
const auto obj_predicted_paths = utils::path_safety_checker::getPredictedPathFromObj(
21532154
obj, lane_change_parameters_->use_all_predicted_path);
2154-
auto is_safe = true;
21552155
const auto selected_rss_param =
21562156
(obj.initial_twist.twist.linear.x <=
21572157
lane_change_parameters_->prepare_segment_ignore_object_velocity_thresh)
@@ -2162,32 +2162,10 @@ PathSafetyStatus NormalLaneChange::isLaneChangePathSafe(
21622162
path, ego_predicted_path, obj, obj_path, common_parameters, rss_params, 1.0,
21632163
get_max_velocity_for_safety_check(), current_debug_data.second);
21642164

2165-
if (collided_polygons.empty()) {
2166-
utils::path_safety_checker::updateCollisionCheckDebugMap(
2167-
debug_data, current_debug_data, is_safe);
2168-
continue;
2169-
}
2170-
2171-
const auto collision_in_current_lanes =
2172-
utils::lane_change::isCollidedPolygonsInLanelet(collided_polygons, current_lanes_polygon);
2173-
const auto collision_in_target_lanes = utils::lane_change::isCollidedPolygonsInLanelet(
2174-
collided_polygons, expanded_target_polygon);
2175-
2176-
if (!collision_in_current_lanes && !collision_in_target_lanes) {
2177-
utils::path_safety_checker::updateCollisionCheckDebugMap(
2178-
debug_data, current_debug_data, is_safe);
2179-
continue;
2180-
}
2181-
2182-
is_safe = false;
2183-
path_safety_status.is_safe = false;
2165+
if (collided_polygons.empty()) {
21842166
utils::path_safety_checker::updateCollisionCheckDebugMap(
21852167
debug_data, current_debug_data, is_safe);
2186-
const auto & obj_pose = obj.initial_pose.pose;
2187-
const auto obj_polygon = autoware::universe_utils::toPolygon2d(obj_pose, obj.shape);
2188-
path_safety_status.is_object_coming_from_rear |=
2189-
!utils::path_safety_checker::isTargetObjectFront(
2190-
path, current_pose, common_parameters.vehicle_info, obj_polygon);
2168+
continue;
21912169
}
21922170

21932171
const auto collision_in_current_lanes =
@@ -2210,11 +2188,29 @@ PathSafetyStatus NormalLaneChange::isLaneChangePathSafe(
22102188
return is_safe;
22112189
};
22122190

2213-
for (const auto & obj : collision_check_objects.trailing) {
2214-
if (!check_collision(obj)) {
2191+
const auto check_collision_with_decel_pattern = [&](const utils::path_safety_checker::ExtendedPredictedObjects & objects) {
2192+
return std::none_of(
2193+
acceleration_values.begin(), acceleration_values.end(), [&](const auto acceleration) {
2194+
const auto ego_predicted_path = utils::lane_change::convertToPredictedPath(
2195+
lane_change_path, current_twist, current_pose, acceleration, common_parameters,
2196+
*lane_change_parameters_, time_resolution);
2197+
const auto debug_predicted_path =
2198+
utils::path_safety_checker::convertToPredictedPath(ego_predicted_path, time_resolution);
2199+
2200+
for(const auto & obj : objects){
2201+
if(!check_collision(obj, ego_predicted_path)){
2202+
return false;
2203+
}
2204+
}
2205+
2206+
2207+
});
2208+
};
2209+
2210+
2211+
if (!check_collision_with_decel_pattern(collision_check_objects.trailing)) {
22152212
return {!is_safe, is_object_behind_ego};
2216-
}
2217-
}
2213+
}
22182214

22192215
for (const auto & obj : collision_check_objects.leading) {
22202216
if (!check_collision(obj)) {

planning/behavior_path_lane_change_module/src/utils/utils.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -821,8 +821,8 @@ std::vector<PoseWithVelocityStamped> convertToPredictedPath(
821821
const double velocity = lane_changing_velocity + lane_changing_acceleration * delta_t;
822822
const double length = lane_changing_velocity * delta_t +
823823
0.5 * lane_changing_acceleration * delta_t * delta_t + offset;
824-
const auto pose = autoware::motion_utils::calcInterpolatedPose(
825-
path.points, vehicle_pose_frenet.length + length);
824+
const auto pose =
825+
motion_utils::calcInterpolatedPose(path.points, vehicle_pose_frenet.length + length);
826826
predicted_path.emplace_back(t, pose, velocity);
827827
}
828828

0 commit comments

Comments
 (0)