@@ -1679,13 +1679,13 @@ bool NormalLaneChange::getLaneChangePaths(
1679
1679
1680
1680
const auto is_safe = std::invoke ([&]() {
1681
1681
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 ,
1683
1683
lane_change_debug_.collision_check_objects );
1684
1684
1685
1685
if (!safety_check_with_normal_rss.is_safe && is_stuck) {
1686
1686
const auto safety_check_with_stuck_rss = isLaneChangePathSafe (
1687
1687
*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 );
1689
1689
return safety_check_with_stuck_rss.is_safe ;
1690
1690
}
1691
1691
@@ -2108,7 +2108,8 @@ bool NormalLaneChange::calcAbortPath()
2108
2108
}
2109
2109
2110
2110
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,
2112
2113
const utils::path_safety_checker::RSSparams & rss_params, const size_t deceleration_sampling_num,
2113
2114
CollisionCheckDebugMap & debug_data) const
2114
2115
{
@@ -2129,29 +2130,28 @@ PathSafetyStatus NormalLaneChange::isLaneChangePathSafe(
2129
2130
return {!is_safe, !is_object_behind_ego};
2130
2131
}
2131
2132
2132
- const double & time_resolution = lane_change_parameters_->prediction_time_resolution ;
2133
2133
const double current_acc = lane_change_path.info .longitudinal_acceleration .lane_changing ;
2134
2134
const double min_acc = std::min (current_acc, common_parameters.min_acc );
2135
2135
const auto sampling_num =
2136
2136
std::abs (min_acc - current_acc) > 1.0E-03 ? deceleration_sampling_num : 1 ;
2137
2137
const double acc_resolution = (min_acc - current_acc) / static_cast <double >(sampling_num);
2138
2138
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 );
2146
2141
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; });
2149
2145
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) {
2151
2152
auto current_debug_data = utils::path_safety_checker::createObjectDebug (obj);
2152
2153
const auto obj_predicted_paths = utils::path_safety_checker::getPredictedPathFromObj (
2153
2154
obj, lane_change_parameters_->use_all_predicted_path );
2154
- auto is_safe = true ;
2155
2155
const auto selected_rss_param =
2156
2156
(obj.initial_twist .twist .linear .x <=
2157
2157
lane_change_parameters_->prepare_segment_ignore_object_velocity_thresh )
@@ -2162,32 +2162,10 @@ PathSafetyStatus NormalLaneChange::isLaneChangePathSafe(
2162
2162
path, ego_predicted_path, obj, obj_path, common_parameters, rss_params, 1.0 ,
2163
2163
get_max_velocity_for_safety_check (), current_debug_data.second );
2164
2164
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 ()) {
2184
2166
utils::path_safety_checker::updateCollisionCheckDebugMap (
2185
2167
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 ;
2191
2169
}
2192
2170
2193
2171
const auto collision_in_current_lanes =
@@ -2210,11 +2188,29 @@ PathSafetyStatus NormalLaneChange::isLaneChangePathSafe(
2210
2188
return is_safe;
2211
2189
};
2212
2190
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 )) {
2215
2212
return {!is_safe, is_object_behind_ego};
2216
- }
2217
- }
2213
+ }
2218
2214
2219
2215
for (const auto & obj : collision_check_objects.leading ) {
2220
2216
if (!check_collision (obj)) {
0 commit comments