Skip to content

Commit

Permalink
More conservative braking in city for 1 and 2 bar distance
Browse files Browse the repository at this point in the history
  • Loading branch information
NeonGalaxy75 committed Dec 16, 2018
1 parent ec600aa commit dbae46d
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions selfdrive/controls/lib/planner.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,9 @@ def update(self, CS, lead, v_cruise_setpoint):
if CS.readdistancelines == 1:
# If one bar distance, auto set to 2 bar distance under current conditions to prevent rear ending lead car
if self.street_speed and (self.lead_car_gap_shrinking or self.tailgating):
TR=2.0
TR=2.1
if self.lastTR != 0:
self.libmpc.init(MPC_COST_LONG.TTC, 0.0875, MPC_COST_LONG.ACCELERATION, MPC_COST_LONG.JERK)
self.libmpc.init(MPC_COST_LONG.TTC, 0.0825, MPC_COST_LONG.ACCELERATION, MPC_COST_LONG.JERK)
self.lastTR = 0
else:
TR=0.9 # 10m at 40km/hr
Expand All @@ -267,10 +267,17 @@ def update(self, CS, lead, v_cruise_setpoint):
self.lastTR = CS.readdistancelines

elif CS.readdistancelines == 2:
TR=1.8 # 20m at 40km/hr
if CS.readdistancelines != self.lastTR:
self.libmpc.init(MPC_COST_LONG.TTC, 0.1, MPC_COST_LONG.ACCELERATION, MPC_COST_LONG.JERK)
self.lastTR = CS.readdistancelines
# More conservative braking than comma default
if self.street_speed and (self.lead_car_gap_shrinking or self.tailgating):
TR=2.0
if self.lastTR != 0:
self.libmpc.init(MPC_COST_LONG.TTC, 0.0875, MPC_COST_LONG.ACCELERATION, MPC_COST_LONG.JERK)
self.lastTR = 0
else:
TR=1.8 # 20m at 40km/hr
if CS.readdistancelines != self.lastTR:
self.libmpc.init(MPC_COST_LONG.TTC, 0.1, MPC_COST_LONG.ACCELERATION, MPC_COST_LONG.JERK)
self.lastTR = CS.readdistancelines

elif CS.readdistancelines == 3:
TR=2.7 # 30m at 40km/hr
Expand Down

0 comments on commit dbae46d

Please sign in to comment.