Skip to content

Commit ee72e08

Browse files
feat(behavior_path_planner): fix minimum prepare speed (autowarefoundation#3231)
* feat(behavior_path_planner): fix minimum prepare speed Signed-off-by: yutaka <purewater0901@gmail.com> * update Signed-off-by: yutaka <purewater0901@gmail.com> * update Signed-off-by: yutaka <purewater0901@gmail.com> * fix(control_launch): add necessary parameter Signed-off-by: yutaka <purewater0901@gmail.com> * update Signed-off-by: yutaka <purewater0901@gmail.com> --------- Signed-off-by: yutaka <purewater0901@gmail.com>
1 parent 70cf872 commit ee72e08

File tree

1 file changed

+15
-12
lines changed
  • planning/behavior_path_planner/src/util/lane_change

1 file changed

+15
-12
lines changed

planning/behavior_path_planner/src/util/lane_change/util.cpp

+15-12
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,7 @@ std::optional<LaneChangePath> constructCandidatePath(
195195
candidate_path.length.prepare = prepare_distance;
196196
candidate_path.length.lane_changing = lane_change_distance;
197197
candidate_path.duration.prepare = std::invoke([&]() {
198-
const auto duration =
199-
prepare_distance / std::max(lane_change_param.minimum_lane_change_velocity, speed.prepare);
198+
const auto duration = prepare_distance / speed.prepare;
200199
return std::min(duration, lane_change_param.lane_change_prepare_duration);
201200
});
202201
candidate_path.duration.lane_changing = std::invoke([&]() {
@@ -286,12 +285,20 @@ std::pair<bool, bool> getLaneChangePaths(
286285
const auto prepare_duration = parameter.lane_change_prepare_duration;
287286
const auto minimum_prepare_distance = common_parameter.minimum_lane_change_prepare_distance;
288287
const auto minimum_lane_change_velocity = parameter.minimum_lane_change_velocity;
289-
const auto maximum_deceleration = parameter.maximum_deceleration;
290288
const auto lane_change_sampling_num = parameter.lane_change_sampling_num;
291289

292290
// get velocity
293291
const auto current_velocity = twist.linear.x;
294292

293+
// compute maximum_deceleration
294+
const auto maximum_deceleration =
295+
std::invoke([&minimum_lane_change_velocity, &current_velocity, &parameter]() {
296+
const double min_a =
297+
(minimum_lane_change_velocity - current_velocity) / parameter.lane_change_prepare_duration;
298+
return std::clamp(
299+
min_a, -std::abs(parameter.maximum_deceleration), -std::numeric_limits<double>::epsilon());
300+
});
301+
295302
const auto acceleration_resolution = std::abs(maximum_deceleration) / lane_change_sampling_num;
296303

297304
const auto target_distance =
@@ -330,14 +337,10 @@ std::pair<bool, bool> getLaneChangePaths(
330337
LaneChangeTargetObjectIndices dynamic_object_indices;
331338

332339
candidate_paths->reserve(lane_change_sampling_num);
333-
for (double acceleration = 0.0; acceleration >= -maximum_deceleration;
340+
for (double acceleration = 0.0; acceleration >= maximum_deceleration;
334341
acceleration -= acceleration_resolution) {
335-
const double prepare_speed = current_velocity + acceleration * prepare_duration;
336-
337-
// skip if velocity becomes less than zero before starting lane change
338-
if (prepare_speed < 0.0) {
339-
break;
340-
}
342+
const auto prepare_speed =
343+
std::max(current_velocity + acceleration * prepare_duration, minimum_lane_change_velocity);
341344

342345
// get path on original lanes
343346
const double prepare_distance = std::max(
@@ -351,7 +354,7 @@ std::pair<bool, bool> getLaneChangePaths(
351354
#ifdef USE_OLD_ARCHITECTURE
352355
const auto prepare_segment = getPrepareSegment(
353356
route_handler, original_lanelets, arc_position_from_current.length, backward_path_length,
354-
prepare_distance, std::max(prepare_speed, minimum_lane_change_velocity));
357+
prepare_distance, prepare_speed);
355358
#else
356359
const auto prepare_segment = getPrepareSegment(
357360
original_path, original_lanelets, pose, backward_path_length, prepare_distance,
@@ -372,7 +375,7 @@ std::pair<bool, bool> getLaneChangePaths(
372375
lanelet::utils::getLateralDistanceToClosestLanelet(target_lanelets, lane_changing_start_pose);
373376

374377
// we assume constant speed during lane change
375-
const auto lane_changing_speed = std::max(prepare_speed, minimum_lane_change_velocity);
378+
const auto lane_changing_speed = prepare_speed;
376379
const auto lane_changing_distance =
377380
calcLaneChangingDistance(lane_changing_speed, shift_length, common_parameter, parameter);
378381

0 commit comments

Comments
 (0)