Skip to content

Commit 5ca325b

Browse files
committed
feat(goal_planner): expand outer collision check margin
Signed-off-by: kosuke55 <kosuke.tnp@gmail.com> margin comment Signed-off-by: kosuke55 <kosuke.tnp@gmail.com> update svg Signed-off-by: kosuke55 <kosuke.tnp@gmail.com>
1 parent da5850e commit 5ca325b

File tree

10 files changed

+357
-123
lines changed

10 files changed

+357
-123
lines changed

planning/behavior_path_planner/autoware_behavior_path_goal_planner_module/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,7 @@ Then there is the concept of soft and hard margins. Although not currently param
375375
| object_recognition_collision_check_soft_margins | [m] | vector[double] | soft margins for collision check when path generation. It is not strictly the distance between footprints, but the maximum distance when ego and objects are oriented. | [5.0, 4.5, 4.0, 3.5, 3.0, 2.5, 2.0, 1.5, 1.0] |
376376
| object_recognition_collision_check_hard_margins | [m] | vector[double] | hard margins for collision check when path generation | [0.6] |
377377
| object_recognition_collision_check_max_extra_stopping_margin | [m] | double | maximum value when adding longitudinal distance margin for collision check considering stopping distance | 1.0 |
378+
| collision_check_outer_margin_factor | [-] | double | factor to extend the collision check margin from the inside margin to the outside in the curved path | 2.0 |
378379
| detection_bound_offset | [m] | double | expand pull over lane with this offset to make detection area for collision check of path generation | 15.0 |
379380

380381
## **safety check**

planning/behavior_path_planner/autoware_behavior_path_goal_planner_module/config/goal_planner.param.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
collision_check_soft_margins: [5.0, 4.5, 4.0, 3.5, 3.0, 2.5, 2.0, 1.5, 1.0] # the maximum margin when ego and objects are oriented.
4343
collision_check_hard_margins: [0.6] # this should be larger than `surround_check_distance` of surround_obstacle_checker
4444
object_recognition_collision_check_max_extra_stopping_margin: 1.0
45+
collision_check_outer_margin_factor: 2.0
4546
th_moving_object_velocity: 1.0
4647
detection_bound_offset: 15.0
4748
outer_road_detection_offset: 1.0

planning/behavior_path_planner/autoware_behavior_path_goal_planner_module/images/goal_planner-collision_check_margin.drawio.svg

+313-95
Loading

planning/behavior_path_planner/autoware_behavior_path_goal_planner_module/include/autoware/behavior_path_goal_planner_module/goal_planner_parameters.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ struct GoalPlannerParameters
8080
std::vector<double> object_recognition_collision_check_soft_margins{};
8181
std::vector<double> object_recognition_collision_check_hard_margins{};
8282
double object_recognition_collision_check_max_extra_stopping_margin{0.0};
83+
double collision_check_outer_margin_factor{0.0};
8384
double th_moving_object_velocity{0.0};
8485
double detection_bound_offset{0.0};
8586
double outer_road_detection_offset{0.0};

planning/behavior_path_planner/autoware_behavior_path_goal_planner_module/include/autoware/behavior_path_goal_planner_module/util.hpp

+19-1
Original file line numberDiff line numberDiff line change
@@ -128,14 +128,32 @@ bool isWithinAreas(
128128
*/
129129
std::vector<lanelet::BasicPolygon2d> getBusStopAreaPolygons(const lanelet::ConstLanelets & lanes);
130130

131+
/**
132+
* @brief check collision between objects and ego path footprints
133+
* @param path ego path to check collision
134+
* @param curvatures curvatures of ego path
135+
* @param static_target_objects static objects to check collision
136+
* @param dynamic_target_objects dynamic objects to check collision
137+
* @param behavior_path_parameters behavior path parameters
138+
* @param collision_check_margin margin to check collision
139+
* @param extract_static_objects flag to extract static objects
140+
* @param maximum_deceleration maximum deceleration
141+
* @param object_recognition_collision_check_max_extra_stopping_margin maximum extra stopping margin
142+
* @param collision_check_outer_margin_factor factor to extend the collision check margin from the
143+
* inside margin to the outside in the curved path
144+
* @param ego_polygons_expanded expanded ego polygons
145+
* @param update_debug_data flag to update debug data
146+
* @return true if collision is detected
147+
*/
131148
bool checkObjectsCollision(
132149
const PathWithLaneId & path, const std::vector<double> & curvatures,
133150
const PredictedObjects & static_target_objects, const PredictedObjects & dynamic_target_objects,
134151
const BehaviorPathPlannerParameters & behavior_path_parameters,
135152
const double collision_check_margin, const bool extract_static_objects,
136153
const double maximum_deceleration,
137154
const double object_recognition_collision_check_max_extra_stopping_margin,
138-
std::vector<Polygon2d> & ego_polygons_expanded, const bool update_debug_data = false);
155+
const double collision_check_outer_margin_factor, std::vector<Polygon2d> & ego_polygons_expanded,
156+
const bool update_debug_data = false);
139157

140158
// debug
141159
MarkerArray createPullOverAreaMarkerArray(

planning/behavior_path_planner/autoware_behavior_path_goal_planner_module/src/decision_state.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ PathDecisionState PathDecisionStateController::get_next_state(
114114
planner_data->parameters, margin,
115115
/*extract_static_objects=*/false, parameters.maximum_deceleration,
116116
parameters.object_recognition_collision_check_max_extra_stopping_margin,
117-
ego_polygons_expanded, true)) {
117+
parameters.collision_check_outer_margin_factor, ego_polygons_expanded, true)) {
118118
RCLCPP_DEBUG(
119119
logger_, "[DecidingPathStatus]: DECIDING->NOT_DECIDED. path has collision with objects");
120120
next_state.state = PathDecisionState::DecisionKind::NOT_DECIDED;

planning/behavior_path_planner/autoware_behavior_path_goal_planner_module/src/goal_planner_module.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -966,7 +966,7 @@ bool GoalPlannerModule::canReturnToLaneParking(const PullOverContextData & conte
966966
parameters_.object_recognition_collision_check_hard_margins.back(),
967967
/*extract_static_objects=*/false, parameters_.maximum_deceleration,
968968
parameters_.object_recognition_collision_check_max_extra_stopping_margin,
969-
debug_data_.ego_polygons_expanded)) {
969+
parameters_.collision_check_outer_margin_factor, debug_data_.ego_polygons_expanded)) {
970970
return false;
971971
}
972972

@@ -1258,7 +1258,8 @@ std::optional<PullOverPath> GoalPlannerModule::selectPullOverPath(
12581258
context_data.dynamic_target_objects, planner_data_->parameters, collision_check_margin,
12591259
true, parameters_.maximum_deceleration,
12601260
parameters_.object_recognition_collision_check_max_extra_stopping_margin,
1261-
debug_data_.ego_polygons_expanded, true)) {
1261+
parameters_.collision_check_outer_margin_factor, debug_data_.ego_polygons_expanded,
1262+
true)) {
12621263
continue;
12631264
}
12641265
if (
@@ -1933,7 +1934,7 @@ bool FreespaceParkingPlanner::isStuck(
19331934
parameters.object_recognition_collision_check_hard_margins.back(),
19341935
/*extract_static_objects=*/false, parameters.maximum_deceleration,
19351936
parameters.object_recognition_collision_check_max_extra_stopping_margin,
1936-
ego_polygons_expanded)) {
1937+
parameters.collision_check_outer_margin_factor, ego_polygons_expanded)) {
19371938
return true;
19381939
}
19391940

planning/behavior_path_planner/autoware_behavior_path_goal_planner_module/src/manager.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ GoalPlannerParameters GoalPlannerModuleManager::initGoalPlannerParameters(
113113
p.object_recognition_collision_check_max_extra_stopping_margin =
114114
node->declare_parameter<double>(
115115
ns + "object_recognition_collision_check_max_extra_stopping_margin");
116+
p.collision_check_outer_margin_factor =
117+
node->declare_parameter<double>(ns + "collision_check_outer_margin_factor");
116118
p.th_moving_object_velocity = node->declare_parameter<double>(ns + "th_moving_object_velocity");
117119
p.detection_bound_offset = node->declare_parameter<double>(ns + "detection_bound_offset");
118120
p.outer_road_detection_offset =

planning/behavior_path_planner/autoware_behavior_path_goal_planner_module/src/util.cpp

+10-20
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,7 @@ bool checkObjectsCollision(
309309
const double collision_check_margin, const bool extract_static_objects,
310310
const double maximum_deceleration,
311311
const double object_recognition_collision_check_max_extra_stopping_margin,
312+
const double collision_check_outer_margin_factor,
312313
std::vector<Polygon2d> & debug_ego_polygons_expanded, const bool update_debug_data)
313314
{
314315
if (path.points.size() != curvatures.size()) {
@@ -324,18 +325,6 @@ bool checkObjectsCollision(
324325
return false;
325326
}
326327

327-
// check collision roughly with {min_distance, max_distance} between ego footprint and objects
328-
// footprint
329-
std::pair<bool, bool> has_collision_rough =
330-
utils::path_safety_checker::checkObjectsCollisionRough(
331-
path, target_objects, collision_check_margin, behavior_path_parameters, false);
332-
if (!has_collision_rough.first) {
333-
return false;
334-
}
335-
if (has_collision_rough.second) {
336-
return true;
337-
}
338-
339328
std::vector<Polygon2d> obj_polygons;
340329
for (const auto & object : target_objects.objects) {
341330
obj_polygons.push_back(autoware_utils::to_polygon2d(object));
@@ -352,20 +341,21 @@ bool checkObjectsCollision(
352341
const double extra_stopping_margin = std::min(
353342
std::pow(p.point.longitudinal_velocity_mps, 2) * 0.5 / maximum_deceleration,
354343
object_recognition_collision_check_max_extra_stopping_margin);
355-
356344
// The square is meant to imply centrifugal force, but it is not a very well-founded formula.
357-
// TODO(kosuke55): It is needed to consider better way because there is an inherently
358-
// different conception of the inside and outside margins.
345+
const double curvature = curvatures.at(i);
359346
const double extra_lateral_margin = std::min(
360-
extra_stopping_margin,
361-
std::abs(curvatures.at(i) * std::pow(p.point.longitudinal_velocity_mps, 2)));
362-
347+
extra_stopping_margin, std::abs(curvature * std::pow(p.point.longitudinal_velocity_mps, 2)));
348+
// The outer margin is `collision_check_outer_margin_factor` times larger than the inner margin.
349+
const double sign = curvature > 0.0 ? -1.0 : 1.0;
350+
const auto ego_pose_offset = calc_offset_pose(
351+
p.point.pose, 0.0, sign * (collision_check_outer_margin_factor - 1.0) * extra_lateral_margin,
352+
0.0);
363353
const auto ego_polygon = autoware_utils::to_footprint(
364-
p.point.pose,
354+
ego_pose_offset,
365355
behavior_path_parameters.base_link2front + collision_check_margin + extra_stopping_margin,
366356
behavior_path_parameters.base_link2rear + collision_check_margin,
367357
behavior_path_parameters.vehicle_width + collision_check_margin * 2.0 +
368-
extra_lateral_margin * 2.0);
358+
extra_lateral_margin * (collision_check_outer_margin_factor + 1.0));
369359
ego_polygons_expanded.push_back(ego_polygon);
370360
}
371361

planning/behavior_path_planner/autoware_behavior_path_planner_common/include/autoware/behavior_path_planner_common/utils/path_safety_checker/safety_check.hpp

+5-3
Original file line numberDiff line numberDiff line change
@@ -255,15 +255,17 @@ double calc_obstacle_max_length(const Shape & shape);
255255
* @brief Calculate collision roughly by comparing minimum/maximum distance with margin.
256256
* @param path The path of the ego vehicle.
257257
* @param objects The predicted objects.
258-
* @param margin Distance margin to judge collision.
258+
* @param min_margin_threshold threshold for collision check when the minimum distance between ego
259+
* @param max_margin_threshold threshold for collision check when the maximum distance between ego
259260
* @param parameters The common parameters used in behavior path planner.
260261
* @param use_offset_ego_point If true, the closest point to the object is calculated by
261262
* interpolating the path points.
262263
* @return Collision (rough) between minimum distance and maximum distance
263264
*/
264265
std::pair<bool, bool> checkObjectsCollisionRough(
265-
const PathWithLaneId & path, const PredictedObjects & objects, const double margin,
266-
const BehaviorPathPlannerParameters & parameters, const bool use_offset_ego_point);
266+
const PathWithLaneId & path, const PredictedObjects & objects, const double min_margin_threshold,
267+
const double max_margin_threshold, const BehaviorPathPlannerParameters & parameters,
268+
const bool use_offset_ego_point);
267269

268270
/**
269271
* @brief Calculate the rough distance between the ego vehicle and the objects.

0 commit comments

Comments
 (0)