@@ -474,6 +474,7 @@ void NormalLaneChange::resetParameters()
474
474
current_lane_change_state_ = LaneChangeStates::Normal;
475
475
abort_path_ = nullptr ;
476
476
status_ = {};
477
+ unsafe_hysteresis_count_ = 0 ;
477
478
lane_change_debug_.reset ();
478
479
479
480
RCLCPP_DEBUG (logger_, " reset all flags and debug information." );
@@ -1665,6 +1666,28 @@ PathSafetyStatus NormalLaneChange::isApprovedPathSafe() const
1665
1666
return safety_status;
1666
1667
}
1667
1668
1669
+ PathSafetyStatus NormalLaneChange::evaluateApprovedPathWithUnsafeHysteresis (
1670
+ PathSafetyStatus approved_path_safety_status)
1671
+ {
1672
+ if (!approved_path_safety_status.is_safe ) {
1673
+ ++unsafe_hysteresis_count_;
1674
+ RCLCPP_DEBUG (
1675
+ logger_, " %s: Increasing hysteresis count to %d." , __func__, unsafe_hysteresis_count_);
1676
+ } else {
1677
+ if (unsafe_hysteresis_count_ > 0 ) {
1678
+ RCLCPP_DEBUG (logger_, " %s: Lane change is now SAFE. Resetting hysteresis count." , __func__);
1679
+ }
1680
+ unsafe_hysteresis_count_ = 0 ;
1681
+ }
1682
+ if (unsafe_hysteresis_count_ > lane_change_parameters_->cancel .unsafe_hysteresis_threshold ) {
1683
+ RCLCPP_DEBUG (
1684
+ logger_, " %s: hysteresis count exceed threshold. lane change is now %s" , __func__,
1685
+ (approved_path_safety_status.is_safe ? " safe" : " UNSAFE" ));
1686
+ return approved_path_safety_status;
1687
+ }
1688
+ return {};
1689
+ }
1690
+
1668
1691
TurnSignalInfo NormalLaneChange::calcTurnSignalInfo () const
1669
1692
{
1670
1693
const auto get_blinker_pose = [](const PathWithLaneId & path, const double length) {
0 commit comments