Skip to content

Commit

Permalink
Disable LDW for 4 seconds after blinker transition from on to off (#112)
Browse files Browse the repository at this point in the history
If we want to change lanes with a blinker tap (3 blink mode), then we need to disable LDW for enough time to allow a smooth manual lane change. 4 seconds as it seems the freq is actually around 50Hz, not 100Hz.
  • Loading branch information
tb205gti authored and BogGyver committed Oct 31, 2019
1 parent c15e9e0 commit 0ef304e
Showing 1 changed file with 19 additions and 2 deletions.
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

0 comments on commit 0ef304e

Please sign in to comment.