@@ -971,14 +971,13 @@ bool GoalPlannerModule::canReturnToLaneParking(const PullOverContextData & conte
971
971
972
972
const auto & path = lane_parking_path.full_path ();
973
973
const auto & curvatures = lane_parking_path.full_path_curvatures ();
974
- if (
975
- parameters_.use_object_recognition &&
976
- goal_planner_utils::checkObjectsCollision (
977
- path, curvatures, context_data.static_target_objects , context_data.dynamic_target_objects ,
978
- planner_data_->parameters , parameters_.object_recognition_collision_check_hard_margins .back (),
979
- /* extract_static_objects=*/ false , parameters_.maximum_deceleration ,
980
- parameters_.object_recognition_collision_check_max_extra_stopping_margin ,
981
- debug_data_.ego_polygons_expanded )) {
974
+ if (goal_planner_utils::checkObjectsCollision (
975
+ path, curvatures, context_data.static_target_objects , context_data.dynamic_target_objects ,
976
+ planner_data_->parameters ,
977
+ parameters_.object_recognition_collision_check_hard_margins .back (),
978
+ /* extract_static_objects=*/ false , parameters_.maximum_deceleration ,
979
+ parameters_.object_recognition_collision_check_max_extra_stopping_margin ,
980
+ debug_data_.ego_polygons_expanded )) {
982
981
return false ;
983
982
}
984
983
@@ -1082,136 +1081,116 @@ void sortPullOverPaths(
1082
1081
};
1083
1082
1084
1083
// if object recognition is enabled, sort by collision check margin
1085
- if (parameters.use_object_recognition ) {
1086
- // STEP2-2: Sort by collision check margins
1087
- const auto [margins, margins_with_zero] =
1088
- std::invoke ([&]() -> std::tuple<std::vector<double >, std::vector<double >> {
1089
- std::vector<double > margins = soft_margins;
1090
- margins.insert (margins.end (), hard_margins.begin (), hard_margins.end ());
1091
- std::vector<double > margins_with_zero = margins;
1092
- margins_with_zero.push_back (0.0 );
1093
- return std::make_tuple (margins, margins_with_zero);
1094
- });
1084
+ // STEP2-2: Sort by collision check margins
1085
+ const auto [margins, margins_with_zero] =
1086
+ std::invoke ([&]() -> std::tuple<std::vector<double >, std::vector<double >> {
1087
+ std::vector<double > margins = soft_margins;
1088
+ margins.insert (margins.end (), hard_margins.begin (), hard_margins.end ());
1089
+ std::vector<double > margins_with_zero = margins;
1090
+ margins_with_zero.push_back (0.0 );
1091
+ return std::make_tuple (margins, margins_with_zero);
1092
+ });
1095
1093
1096
- // Create a map of PullOverPath pointer to largest collision check margin
1097
- std::map<size_t , double > path_id_to_rough_margin_map;
1098
- const auto & target_objects = static_target_objects;
1099
- for (const size_t i : sorted_path_indices) {
1100
- const auto & path = pull_over_path_candidates[i];
1101
- const double distance = utils::path_safety_checker::calculateRoughDistanceToObjects (
1102
- path.parking_path (), target_objects, planner_data->parameters , false , " max" );
1103
- auto it = std::lower_bound (
1104
- margins_with_zero.begin (), margins_with_zero.end (), distance, std::greater<double >());
1105
- if (it == margins_with_zero.end ()) {
1106
- path_id_to_rough_margin_map[path.id ()] = margins_with_zero.back ();
1107
- } else {
1108
- path_id_to_rough_margin_map[path.id ()] = *it;
1109
- }
1094
+ // Create a map of PullOverPath pointer to largest collision check margin
1095
+ std::map<size_t , double > path_id_to_rough_margin_map;
1096
+ const auto & target_objects = static_target_objects;
1097
+ for (const size_t i : sorted_path_indices) {
1098
+ const auto & path = pull_over_path_candidates[i];
1099
+ const double distance = utils::path_safety_checker::calculateRoughDistanceToObjects (
1100
+ path.parking_path (), target_objects, planner_data->parameters , false , " max" );
1101
+ auto it = std::lower_bound (
1102
+ margins_with_zero.begin (), margins_with_zero.end (), distance, std::greater<double >());
1103
+ if (it == margins_with_zero.end ()) {
1104
+ path_id_to_rough_margin_map[path.id ()] = margins_with_zero.back ();
1105
+ } else {
1106
+ path_id_to_rough_margin_map[path.id ()] = *it;
1110
1107
}
1108
+ }
1111
1109
1112
- // sorts in descending order so the item with larger margin comes first
1113
- std::stable_sort (
1114
- std::execution::par, sorted_path_indices.begin (), sorted_path_indices.end (),
1115
- [&](const size_t a_i, const size_t b_i) {
1116
- const auto & a = pull_over_path_candidates[a_i];
1117
- const auto & b = pull_over_path_candidates[b_i];
1118
- if (!isSameNumObjectsToAvoid (a, b)) {
1119
- return false ;
1120
- }
1121
- if (
1122
- std::abs (path_id_to_rough_margin_map[a.id ()] - path_id_to_rough_margin_map[b.id ()]) <
1123
- 0.01 ) {
1124
- return false ;
1125
- }
1126
- return path_id_to_rough_margin_map[a.id ()] > path_id_to_rough_margin_map[b.id ()];
1127
- });
1110
+ // sorts in descending order so the item with larger margin comes first
1111
+ std::stable_sort (
1112
+ std::execution::par, sorted_path_indices.begin (), sorted_path_indices.end (),
1113
+ [&](const size_t a_i, const size_t b_i) {
1114
+ const auto & a = pull_over_path_candidates[a_i];
1115
+ const auto & b = pull_over_path_candidates[b_i];
1116
+ if (!isSameNumObjectsToAvoid (a, b)) {
1117
+ return false ;
1118
+ }
1119
+ if (
1120
+ std::abs (path_id_to_rough_margin_map[a.id ()] - path_id_to_rough_margin_map[b.id ()]) <
1121
+ 0.01 ) {
1122
+ return false ;
1123
+ }
1124
+ return path_id_to_rough_margin_map[a.id ()] > path_id_to_rough_margin_map[b.id ()];
1125
+ });
1126
+
1127
+ // STEP2-3: Sort by curvature
1128
+ // If the curvature is less than the threshold, prioritize the path.
1129
+ const auto isHighCurvature = [&](const PullOverPath & path) -> bool {
1130
+ return path.parking_path_max_curvature () >= parameters.high_curvature_threshold ;
1131
+ };
1132
+
1133
+ const auto isSoftMargin = [&](const PullOverPath & path) -> bool {
1134
+ const double margin = path_id_to_rough_margin_map[path.id ()];
1135
+ return std::any_of (
1136
+ soft_margins.begin (), soft_margins.end (),
1137
+ [margin](const double soft_margin) { return std::abs (margin - soft_margin) < 0.01 ; });
1138
+ };
1139
+ const auto isSameHardMargin = [&](const PullOverPath & a, const PullOverPath & b) -> bool {
1140
+ return !isSoftMargin (a) && !isSoftMargin (b) &&
1141
+ std::abs (path_id_to_rough_margin_map[a.id ()] - path_id_to_rough_margin_map[b.id ()]) <
1142
+ 0.01 ;
1143
+ };
1128
1144
1129
- // STEP2-3: Sort by curvature
1130
- // If the curvature is less than the threshold, prioritize the path.
1131
- const auto isHighCurvature = [&](const PullOverPath & path) -> bool {
1132
- return path.parking_path_max_curvature () >= parameters.high_curvature_threshold ;
1133
- };
1134
-
1135
- const auto isSoftMargin = [&](const PullOverPath & path) -> bool {
1136
- const double margin = path_id_to_rough_margin_map[path.id ()];
1137
- return std::any_of (
1138
- soft_margins.begin (), soft_margins.end (),
1139
- [margin](const double soft_margin) { return std::abs (margin - soft_margin) < 0.01 ; });
1140
- };
1141
- const auto isSameHardMargin = [&](const PullOverPath & a, const PullOverPath & b) -> bool {
1142
- return !isSoftMargin (a) && !isSoftMargin (b) &&
1143
- std::abs (path_id_to_rough_margin_map[a.id ()] - path_id_to_rough_margin_map[b.id ()]) <
1144
- 0.01 ;
1145
- };
1146
-
1147
- // NOTE: this is just partition sort based on curvature threshold within each sub partitions
1145
+ // NOTE: this is just partition sort based on curvature threshold within each sub partitions
1146
+ std::stable_sort (
1147
+ std::execution::par, sorted_path_indices.begin (), sorted_path_indices.end (),
1148
+ [&](const size_t a_i, const size_t b_i) {
1149
+ const auto & a = pull_over_path_candidates[a_i];
1150
+ const auto & b = pull_over_path_candidates[b_i];
1151
+ if (!isSameNumObjectsToAvoid (a, b)) {
1152
+ return false ;
1153
+ }
1154
+
1155
+ // if both are soft margin or both are same hard margin, prioritize the path with lower
1156
+ // curvature.
1157
+ if ((isSoftMargin (a) && isSoftMargin (b)) || isSameHardMargin (a, b)) {
1158
+ return !isHighCurvature (a) && isHighCurvature (b);
1159
+ }
1160
+ // otherwise, keep the order based on the margin.
1161
+ return false ;
1162
+ });
1163
+
1164
+ // STEP2-4: Sort pull_over_path_candidates based on the order in efficient_path_order keeping
1165
+ // the collision check margin and curvature priority.
1166
+ if (parameters.path_priority == " efficient_path" ) {
1148
1167
std::stable_sort (
1149
1168
std::execution::par, sorted_path_indices.begin (), sorted_path_indices.end (),
1150
1169
[&](const size_t a_i, const size_t b_i) {
1170
+ // if any of following conditions are met, sort by path type priority
1171
+ // - both are soft margin
1172
+ // - both are same hard margin
1151
1173
const auto & a = pull_over_path_candidates[a_i];
1152
1174
const auto & b = pull_over_path_candidates[b_i];
1153
1175
if (!isSameNumObjectsToAvoid (a, b)) {
1154
1176
return false ;
1155
1177
}
1156
-
1157
- // if both are soft margin or both are same hard margin, prioritize the path with lower
1158
- // curvature.
1159
1178
if ((isSoftMargin (a) && isSoftMargin (b)) || isSameHardMargin (a, b)) {
1160
- return ! isHighCurvature (a) && isHighCurvature ( b);
1179
+ return comparePathTypePriority (a, b);
1161
1180
}
1162
- // otherwise, keep the order based on the margin .
1181
+ // otherwise, keep the order.
1163
1182
return false ;
1164
1183
});
1165
-
1166
- // STEP2-4: Sort pull_over_path_candidates based on the order in efficient_path_order keeping
1167
- // the collision check margin and curvature priority.
1168
- if (parameters.path_priority == " efficient_path" ) {
1169
- std::stable_sort (
1170
- std::execution::par, sorted_path_indices.begin (), sorted_path_indices.end (),
1171
- [&](const size_t a_i, const size_t b_i) {
1172
- // if any of following conditions are met, sort by path type priority
1173
- // - both are soft margin
1174
- // - both are same hard margin
1175
- const auto & a = pull_over_path_candidates[a_i];
1176
- const auto & b = pull_over_path_candidates[b_i];
1177
- if (!isSameNumObjectsToAvoid (a, b)) {
1178
- return false ;
1179
- }
1180
- if ((isSoftMargin (a) && isSoftMargin (b)) || isSameHardMargin (a, b)) {
1181
- return comparePathTypePriority (a, b);
1182
- }
1183
- // otherwise, keep the order.
1184
- return false ;
1185
- });
1186
- }
1187
-
1188
- // debug print path priority sorted by
1189
- // - efficient_path_order
1190
- // - collision check margin
1191
- // - curvature
1192
- const std::string path_priority_info_str = goal_planner_utils::makePathPriorityDebugMessage (
1193
- sorted_path_indices, pull_over_path_candidates, goal_id_to_index, goal_candidates,
1194
- path_id_to_rough_margin_map, isSoftMargin, isHighCurvature);
1195
- RCLCPP_DEBUG_STREAM (logger, path_priority_info_str);
1196
- } else {
1197
- /* *
1198
- * NOTE: use_object_recognition=false is not recommended. This option will be deprecated in the
1199
- * future. sort by curvature is not implemented yet.
1200
- * Sort pull_over_path_candidates based on the order in efficient_path_order
1201
- */
1202
- if (parameters.path_priority == " efficient_path" ) {
1203
- std::stable_sort (
1204
- std::execution::par, sorted_path_indices.begin (), sorted_path_indices.end (),
1205
- [&](const size_t a_i, const size_t b_i) {
1206
- const auto & a = pull_over_path_candidates[a_i];
1207
- const auto & b = pull_over_path_candidates[b_i];
1208
- if (!isSameNumObjectsToAvoid (a, b)) {
1209
- return false ;
1210
- }
1211
- return comparePathTypePriority (a, b);
1212
- });
1213
- }
1214
1184
}
1185
+
1186
+ // debug print path priority sorted by
1187
+ // - efficient_path_order
1188
+ // - collision check margin
1189
+ // - curvature
1190
+ const std::string path_priority_info_str = goal_planner_utils::makePathPriorityDebugMessage (
1191
+ sorted_path_indices, pull_over_path_candidates, goal_id_to_index, goal_candidates,
1192
+ path_id_to_rough_margin_map, isSoftMargin, isHighCurvature);
1193
+ RCLCPP_DEBUG_STREAM (logger, path_priority_info_str);
1215
1194
}
1216
1195
1217
1196
std::optional<PullOverPath> GoalPlannerModule::selectPullOverPath (
@@ -1285,14 +1264,12 @@ std::optional<PullOverPath> GoalPlannerModule::selectPullOverPath(
1285
1264
const auto & path = pull_over_path_candidates[i];
1286
1265
const PathWithLaneId & parking_path = path.parking_path ();
1287
1266
const auto & parking_path_curvatures = path.parking_path_curvatures ();
1288
- if (
1289
- parameters_.use_object_recognition &&
1290
- goal_planner_utils::checkObjectsCollision (
1291
- parking_path, parking_path_curvatures, context_data.static_target_objects ,
1292
- context_data.dynamic_target_objects , planner_data_->parameters , collision_check_margin,
1293
- true , parameters_.maximum_deceleration ,
1294
- parameters_.object_recognition_collision_check_max_extra_stopping_margin ,
1295
- debug_data_.ego_polygons_expanded , true )) {
1267
+ if (goal_planner_utils::checkObjectsCollision (
1268
+ parking_path, parking_path_curvatures, context_data.static_target_objects ,
1269
+ context_data.dynamic_target_objects , planner_data_->parameters , collision_check_margin,
1270
+ true , parameters_.maximum_deceleration ,
1271
+ parameters_.object_recognition_collision_check_max_extra_stopping_margin ,
1272
+ debug_data_.ego_polygons_expanded , true )) {
1296
1273
continue ;
1297
1274
}
1298
1275
if (
@@ -1859,18 +1836,16 @@ bool FreespaceParkingPlanner::isStuck(
1859
1836
return true ;
1860
1837
}
1861
1838
1862
- if (parameters.use_object_recognition ) {
1863
- const auto & path = req.get_pull_over_path ().value ().getCurrentPath ();
1864
- const auto curvatures = autoware::motion_utils::calcCurvature (path.points );
1865
- std::vector<Polygon2d> ego_polygons_expanded;
1866
- if (goal_planner_utils::checkObjectsCollision (
1867
- path, curvatures, static_target_objects, dynamic_target_objects, planner_data->parameters ,
1868
- parameters.object_recognition_collision_check_hard_margins .back (),
1869
- /* extract_static_objects=*/ false , parameters.maximum_deceleration ,
1870
- parameters.object_recognition_collision_check_max_extra_stopping_margin ,
1871
- ego_polygons_expanded)) {
1872
- return true ;
1873
- }
1839
+ const auto & path = req.get_pull_over_path ().value ().getCurrentPath ();
1840
+ const auto curvatures = autoware::motion_utils::calcCurvature (path.points );
1841
+ std::vector<Polygon2d> ego_polygons_expanded;
1842
+ if (goal_planner_utils::checkObjectsCollision (
1843
+ path, curvatures, static_target_objects, dynamic_target_objects, planner_data->parameters ,
1844
+ parameters.object_recognition_collision_check_hard_margins .back (),
1845
+ /* extract_static_objects=*/ false , parameters.maximum_deceleration ,
1846
+ parameters.object_recognition_collision_check_max_extra_stopping_margin ,
1847
+ ego_polygons_expanded)) {
1848
+ return true ;
1874
1849
}
1875
1850
1876
1851
if (
0 commit comments