Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable LDW for 4 seconds after blinker transition from on to off #112

Merged
merged 1 commit into from
Oct 31, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions selfdrive/car/tesla/carcontroller.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,12 @@ def __init__(self, dbc_name):
self.prev_ldwStatus = 0

self.radarVin_idx = 0


self.LDW_NUMB_PERIOD = 200 # 4 seconds at 50Hz
self.should_ldw = False
self.ldw_numb_frame_start = 0
self.prev_changing_lanes = False

self.isMetric = (self.params.get("IsMetric") == "1")

def reset_traffic_events(self):
Expand Down Expand Up @@ -317,6 +322,17 @@ def update(self, enabled, CS, frame, actuators, \

# Basic highway lane change logic
changing_lanes = CS.right_blinker_on or CS.left_blinker_on

if (frame % 25 == 0):
if (self.prev_changing_lanes and not changing_lanes): #we have a transition from blinkers on to blinkers off, save the frame
self.ldw_numb_frame_start = frame
print("LDW Transition detected, frame (%d)", frame)

# update the previous state of the blinkers (chaning_lanes)
self.prev_changing_lanes = changing_lanes

#Determine if we should have LDW or not
self.should_ldw = (frame > (self.ldw_numb_frame_start + self.LDW_NUMB_PERIOD))

#upodate custom UI buttons and alerts
CS.UE.update_custom_ui()
Expand Down Expand Up @@ -738,7 +754,8 @@ def handlePathPlanSocketForCurvatureOnIC(self, pathPlanSocket, alcaStateData, CS
self.curv0 = self.ALCA.laneChange_direction * self.laneWidth - self.curv0
self.curv0 = clip(self.curv0, -3.5, 3.5)
else:
if CS.enableLdw and (not CS.blinker_on) and (CS.v_ego > 15.6) and (turn_signal_needed == 0):
if self.should_ldw and (CS.enableLdw and (not CS.blinker_on) and (CS.v_ego > 15.6) and (turn_signal_needed == 0)):
self.ldw_numb_frame_start = 0 #reset frame_start for the transition
if pp.lProb > LDW_LANE_PROBAB:
lLaneC0 = -pp.lPoly[3]
if abs(lLaneC0) < LDW_WARNING_2:
Expand Down