@@ -195,8 +195,7 @@ std::optional<LaneChangePath> constructCandidatePath(
195
195
candidate_path.length .prepare = prepare_distance;
196
196
candidate_path.length .lane_changing = lane_change_distance;
197
197
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 ;
200
199
return std::min (duration, lane_change_param.lane_change_prepare_duration );
201
200
});
202
201
candidate_path.duration .lane_changing = std::invoke ([&]() {
@@ -286,12 +285,20 @@ std::pair<bool, bool> getLaneChangePaths(
286
285
const auto prepare_duration = parameter.lane_change_prepare_duration ;
287
286
const auto minimum_prepare_distance = common_parameter.minimum_lane_change_prepare_distance ;
288
287
const auto minimum_lane_change_velocity = parameter.minimum_lane_change_velocity ;
289
- const auto maximum_deceleration = parameter.maximum_deceleration ;
290
288
const auto lane_change_sampling_num = parameter.lane_change_sampling_num ;
291
289
292
290
// get velocity
293
291
const auto current_velocity = twist.linear .x ;
294
292
293
+ // compute maximum_deceleration
294
+ const auto maximum_deceleration =
295
+ std::invoke ([&minimum_lane_change_velocity, ¤t_velocity, ¶meter]() {
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
+
295
302
const auto acceleration_resolution = std::abs (maximum_deceleration) / lane_change_sampling_num;
296
303
297
304
const auto target_distance =
@@ -330,14 +337,10 @@ std::pair<bool, bool> getLaneChangePaths(
330
337
LaneChangeTargetObjectIndices dynamic_object_indices;
331
338
332
339
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;
334
341
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);
341
344
342
345
// get path on original lanes
343
346
const double prepare_distance = std::max (
@@ -351,7 +354,7 @@ std::pair<bool, bool> getLaneChangePaths(
351
354
#ifdef USE_OLD_ARCHITECTURE
352
355
const auto prepare_segment = getPrepareSegment (
353
356
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);
355
358
#else
356
359
const auto prepare_segment = getPrepareSegment (
357
360
original_path, original_lanelets, pose, backward_path_length, prepare_distance,
@@ -372,7 +375,7 @@ std::pair<bool, bool> getLaneChangePaths(
372
375
lanelet::utils::getLateralDistanceToClosestLanelet (target_lanelets, lane_changing_start_pose);
373
376
374
377
// 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;
376
379
const auto lane_changing_distance =
377
380
calcLaneChangingDistance (lane_changing_speed, shift_length, common_parameter, parameter);
378
381
0 commit comments