@@ -250,37 +250,34 @@ void pushUniqueVector(T & base_vector, const T & additional_vector)
250
250
base_vector.insert (base_vector.end (), additional_vector.begin (), additional_vector.end ());
251
251
}
252
252
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)
254
255
{
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;
257
257
}
258
258
259
259
bool isReturnShift (const double start_shift_length, const double end_shift_length)
260
260
{
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;
263
262
}
264
263
265
264
bool isLeftMiddleShift (const double start_shift_length, const double end_shift_length)
266
265
{
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;
269
267
}
270
268
271
269
bool isRightMiddleShift (const double start_shift_length, const double end_shift_length)
272
270
{
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;
275
272
}
276
273
277
274
bool existShiftSideLane (
278
275
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 )
280
277
{
281
278
const auto relative_shift_length = end_shift_length - start_shift_length;
282
279
283
- if (isAvoidShift (start_shift_length, end_shift_length)) {
280
+ if (isAvoidShift (start_shift_length, end_shift_length, threshold )) {
284
281
// Left avoid. But there is no adjacent lane. No need blinker.
285
282
if (relative_shift_length > 0.0 && no_left_lanes) {
286
283
return false ;
@@ -292,7 +289,7 @@ bool existShiftSideLane(
292
289
}
293
290
}
294
291
295
- if (isReturnShift (start_shift_length, end_shift_length)) {
292
+ if (isReturnShift (start_shift_length, end_shift_length, threshold )) {
296
293
// Right return. But there is no adjacent lane. No need blinker.
297
294
if (relative_shift_length > 0.0 && no_right_lanes) {
298
295
return false ;
@@ -304,7 +301,7 @@ bool existShiftSideLane(
304
301
}
305
302
}
306
303
307
- if (isLeftMiddleShift (start_shift_length, end_shift_length)) {
304
+ if (isLeftMiddleShift (start_shift_length, end_shift_length, threshold )) {
308
305
// Left avoid. But there is no adjacent lane. No need blinker.
309
306
if (relative_shift_length > 0.0 && no_left_lanes) {
310
307
return false ;
@@ -316,7 +313,7 @@ bool existShiftSideLane(
316
313
}
317
314
}
318
315
319
- if (isRightMiddleShift (start_shift_length, end_shift_length)) {
316
+ if (isRightMiddleShift (start_shift_length, end_shift_length, threshold )) {
320
317
// Right avoid. But there is no adjacent lane. No need blinker.
321
318
if (relative_shift_length < 0.0 && no_right_lanes) {
322
319
return false ;
@@ -2450,7 +2447,9 @@ std::pair<TurnSignalInfo, bool> calcTurnSignalInfo(
2450
2447
const auto has_right_lane =
2451
2448
right_same_direction_lane.has_value () || !right_opposite_lanes.empty ();
2452
2449
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 )) {
2454
2453
return std::make_pair (TurnSignalInfo{}, true );
2455
2454
}
2456
2455
0 commit comments