@@ -426,14 +426,20 @@ void NormalLaneChange::resetParameters()
426
426
427
427
TurnSignalInfo NormalLaneChange::updateOutputTurnSignal ()
428
428
{
429
- TurnSignalInfo turn_signal_info = calcTurnSignalInfo ();
430
- const auto [turn_signal_command, distance_to_vehicle_front] = utils::getPathTurnSignal (
431
- status_.current_lanes , status_.lane_change_path .shifted_path ,
432
- status_.lane_change_path .info .shift_line , getEgoPose (), getEgoTwist ().linear .x ,
433
- planner_data_->parameters );
434
- turn_signal_info.turn_signal .command = turn_signal_command.command ;
435
-
436
- return turn_signal_info;
429
+ const auto & pose = getEgoPose ();
430
+ const auto & current_lanes = status_.current_lanes ;
431
+ const auto & shift_line = status_.lane_change_path .info .shift_line ;
432
+ const auto & shift_path = status_.lane_change_path .shifted_path ;
433
+ const auto current_shift_length = lanelet::utils::getArcCoordinates (current_lanes, pose).distance ;
434
+ constexpr bool is_driving_forward = true ;
435
+ // The getBehaviorTurnSignalInfo method expects the shifted line to be generated off of the ego's
436
+ // current lane, lane change is different, so we set this flag to false.
437
+ constexpr bool egos_lane_is_shifted = false ;
438
+
439
+ const auto [new_signal, is_ignore] = planner_data_->getBehaviorTurnSignalInfo (
440
+ shift_path, shift_line, current_lanes, current_shift_length, is_driving_forward,
441
+ egos_lane_is_shifted);
442
+ return new_signal;
437
443
}
438
444
439
445
lanelet::ConstLanelets NormalLaneChange::getCurrentLanes () const
@@ -1445,53 +1451,26 @@ PathSafetyStatus NormalLaneChange::isApprovedPathSafe() const
1445
1451
return safety_status;
1446
1452
}
1447
1453
1448
- TurnSignalInfo NormalLaneChange::calcTurnSignalInfo ()
1454
+ PathSafetyStatus NormalLaneChange::evaluateApprovedPathWithUnsafeHysteresis (
1455
+ PathSafetyStatus approved_path_safety_status)
1449
1456
{
1450
- const auto get_blinker_pose = [](const PathWithLaneId & path, const double length) {
1451
- double accumulated_length = 0.0 ;
1452
- for (size_t i = 0 ; i < path.points .size () - 1 ; ++i) {
1453
- accumulated_length +=
1454
- tier4_autoware_utils::calcDistance2d (path.points .at (i), path.points .at (i + 1 ));
1455
- if (accumulated_length > length) {
1456
- return path.points .at (i).point .pose ;
1457
- }
1458
- }
1459
-
1460
- return path.points .front ().point .pose ;
1461
- };
1462
-
1463
- const auto & path = status_.lane_change_path ;
1464
- const auto & shifted_path = path.shifted_path .path ;
1465
-
1466
- TurnSignalInfo turn_signal_info{};
1467
-
1468
- // desired start pose = prepare start pose
1469
- turn_signal_info.desired_start_point = std::invoke ([&]() {
1470
- const auto blinker_start_duration = planner_data_->parameters .turn_signal_search_time ;
1471
- const auto diff_time = path.info .duration .prepare - blinker_start_duration;
1472
- if (diff_time < 1e-5 ) {
1473
- return path.path .points .front ().point .pose ;
1457
+ if (!approved_path_safety_status.is_safe ) {
1458
+ ++unsafe_hysteresis_count_;
1459
+ RCLCPP_DEBUG (
1460
+ logger_, " %s: Increasing hysteresis count to %d." , __func__, unsafe_hysteresis_count_);
1461
+ } else {
1462
+ if (unsafe_hysteresis_count_ > 0 ) {
1463
+ RCLCPP_DEBUG (logger_, " %s: Lane change is now SAFE. Resetting hysteresis count." , __func__);
1474
1464
}
1475
-
1476
- const auto current_twist = getEgoTwist ();
1477
- const auto diff_length = std::abs (current_twist.linear .x ) * diff_time;
1478
- return get_blinker_pose (path.path , diff_length);
1479
- });
1480
-
1481
- // desired end pose
1482
- const auto length_ratio =
1483
- std::clamp (lane_change_parameters_->length_ratio_for_turn_signal_deactivation , 0.0 , 1.0 );
1484
- const auto desired_end_length = path.info .length .lane_changing * length_ratio;
1485
- turn_signal_info.desired_end_point = get_blinker_pose (shifted_path, desired_end_length);
1486
-
1487
- // required start pose = lane changing start pose
1488
- turn_signal_info.required_start_point = path.info .shift_line .start ;
1489
-
1490
- // required end pose = in the middle of the lane change
1491
- const auto mid_lane_change_length = path.info .length .lane_changing / 2 ;
1492
- turn_signal_info.required_end_point = get_blinker_pose (shifted_path, mid_lane_change_length);
1493
-
1494
- return turn_signal_info;
1465
+ unsafe_hysteresis_count_ = 0 ;
1466
+ }
1467
+ if (unsafe_hysteresis_count_ > lane_change_parameters_->cancel .unsafe_hysteresis_threshold ) {
1468
+ RCLCPP_DEBUG (
1469
+ logger_, " %s: hysteresis count exceed threshold. lane change is now %s" , __func__,
1470
+ (approved_path_safety_status.is_safe ? " safe" : " UNSAFE" ));
1471
+ return approved_path_safety_status;
1472
+ }
1473
+ return {};
1495
1474
}
1496
1475
1497
1476
bool NormalLaneChange::isValidPath (const PathWithLaneId & path) const
0 commit comments