Skip to content

Commit e677db4

Browse files
committed
fix(avoidance): use threshold param
Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>
1 parent bac9dd1 commit e677db4

File tree

1 file changed

+14
-15
lines changed
  • planning/behavior_path_avoidance_module/src

1 file changed

+14
-15
lines changed

planning/behavior_path_avoidance_module/src/utils.cpp

+14-15
Original file line numberDiff line numberDiff line change
@@ -250,37 +250,34 @@ void pushUniqueVector(T & base_vector, const T & additional_vector)
250250
base_vector.insert(base_vector.end(), additional_vector.begin(), additional_vector.end());
251251
}
252252

253-
bool isAvoidShift(const double start_shift_length, const double end_shift_length)
253+
bool isAvoidShift(
254+
const double start_shift_length, const double end_shift_length, const double threshold)
254255
{
255-
constexpr double THRESHOLD = 0.1;
256-
return std::abs(start_shift_length) < THRESHOLD && std::abs(end_shift_length) > THRESHOLD;
256+
return std::abs(start_shift_length) < threshold && std::abs(end_shift_length) > threshold;
257257
}
258258

259259
bool isReturnShift(const double start_shift_length, const double end_shift_length)
260260
{
261-
constexpr double THRESHOLD = 0.1;
262-
return std::abs(start_shift_length) > THRESHOLD && std::abs(end_shift_length) < THRESHOLD;
261+
return std::abs(start_shift_length) > threshold && std::abs(end_shift_length) < threshold;
263262
}
264263

265264
bool isLeftMiddleShift(const double start_shift_length, const double end_shift_length)
266265
{
267-
constexpr double THRESHOLD = 0.1;
268-
return start_shift_length > THRESHOLD && end_shift_length > THRESHOLD;
266+
return start_shift_length > threshold && end_shift_length > threshold;
269267
}
270268

271269
bool isRightMiddleShift(const double start_shift_length, const double end_shift_length)
272270
{
273-
constexpr double THRESHOLD = 0.1;
274-
return start_shift_length < THRESHOLD && end_shift_length < THRESHOLD;
271+
return start_shift_length < threshold && end_shift_length < threshold;
275272
}
276273

277274
bool existShiftSideLane(
278275
const double start_shift_length, const double end_shift_length, const bool no_left_lanes,
279-
const bool no_right_lanes)
276+
const bool no_right_lanes, const double threshold)
280277
{
281278
const auto relative_shift_length = end_shift_length - start_shift_length;
282279

283-
if (isAvoidShift(start_shift_length, end_shift_length)) {
280+
if (isAvoidShift(start_shift_length, end_shift_length, threshold)) {
284281
// Left avoid. But there is no adjacent lane. No need blinker.
285282
if (relative_shift_length > 0.0 && no_left_lanes) {
286283
return false;
@@ -292,7 +289,7 @@ bool existShiftSideLane(
292289
}
293290
}
294291

295-
if (isReturnShift(start_shift_length, end_shift_length)) {
292+
if (isReturnShift(start_shift_length, end_shift_length, threshold)) {
296293
// Right return. But there is no adjacent lane. No need blinker.
297294
if (relative_shift_length > 0.0 && no_right_lanes) {
298295
return false;
@@ -304,7 +301,7 @@ bool existShiftSideLane(
304301
}
305302
}
306303

307-
if (isLeftMiddleShift(start_shift_length, end_shift_length)) {
304+
if (isLeftMiddleShift(start_shift_length, end_shift_length, threshold)) {
308305
// Left avoid. But there is no adjacent lane. No need blinker.
309306
if (relative_shift_length > 0.0 && no_left_lanes) {
310307
return false;
@@ -316,7 +313,7 @@ bool existShiftSideLane(
316313
}
317314
}
318315

319-
if (isRightMiddleShift(start_shift_length, end_shift_length)) {
316+
if (isRightMiddleShift(start_shift_length, end_shift_length, threshold)) {
320317
// Right avoid. But there is no adjacent lane. No need blinker.
321318
if (relative_shift_length < 0.0 && no_right_lanes) {
322319
return false;
@@ -2450,7 +2447,9 @@ std::pair<TurnSignalInfo, bool> calcTurnSignalInfo(
24502447
const auto has_right_lane =
24512448
right_same_direction_lane.has_value() || !right_opposite_lanes.empty();
24522449

2453-
if (!existShiftSideLane(start_shift_length, end_shift_length, !has_left_lane, !has_right_lane)) {
2450+
if (!existShiftSideLane(
2451+
start_shift_length, end_shift_length, !has_left_lane, !has_right_lane,
2452+
p.turn_signal_shift_length_threshold)) {
24542453
return std::make_pair(TurnSignalInfo{}, true);
24552454
}
24562455

0 commit comments

Comments
 (0)