Skip to content

Commit bfd267e

Browse files
authored
Merge pull request commaai#364 from ShaneSmiskol/0512
unify long tuning as per arne's suggestion.
2 parents e7df968 + 7220078 commit bfd267e

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

selfdrive/car/toyota/interface.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -86,16 +86,16 @@ def get_params(candidate, fingerprint):
8686
ret.stoppingControl = False
8787
ret.startAccel = 0.0
8888

89-
if ret.enableGasInterceptor:
90-
ret.gasMaxBP = [0., 9., 35]
91-
ret.gasMaxV = [0.2, 0.5, 0.7]
92-
ret.longitudinalTuning.kpV = [0.333, 0.364, 0.15] # braking tune from corolla with pedal
93-
ret.longitudinalTuning.kiV = [0.07, 0.05]
94-
else:
89+
#if ret.enableGasInterceptor:
90+
ret.gasMaxBP = [0., 9., 35]
91+
ret.gasMaxV = [0.2, 0.5, 0.7]
92+
ret.longitudinalTuning.kpV = [0.333, 0.364, 0.15] # braking tune from corolla with pedal
93+
ret.longitudinalTuning.kiV = [0.07, 0.05]
94+
'''else:
9595
ret.gasMaxBP = [0.]
9696
ret.gasMaxV = [0.5]
9797
ret.longitudinalTuning.kpV = [1.0, 0.5, 0.3] # braking tune from rav4h
98-
ret.longitudinalTuning.kiV = [0.20, 0.10]
98+
ret.longitudinalTuning.kiV = [0.20, 0.10]'''
9999

100100
ret.steerActuatorDelay = 0.12 # Default delay, Prius has larger delay
101101
if candidate != CAR.PRIUS:

selfdrive/controls/lib/long_mpc.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,11 @@ def get_traffic_level(self): # based on fluctuation of v_lead
9898
lead_vel_diffs = [abs(vel - lead_vels[idx - 1]) for idx, vel in enumerate(lead_vels) if idx != 0]
9999
x = [0.0, 0.21, 0.466, 0.722, 0.856, 0.96, 1.0] # 1 is estimated to be heavy traffic
100100
y = [1.2, 1.19, 1.17, 1.13, 1.09, 1.04, 1.0]
101-
return interp(sum(lead_vel_diffs)/len(lead_vel_diffs), x, y)
101+
traffic_mod = interp(sum(lead_vel_diffs)/len(lead_vel_diffs), x, y)
102+
x = [20.1168, 24.5872] # min speed is 45mph for traffic level mod
103+
y = [0.2, 0.0]
104+
traffic_mod = max(traffic_mod - interp(self.v_ego, x, y), 1.0)
105+
return traffic_mod
102106

103107
def smooth_follow(self): # in m/s
104108
x_vel = [0.0, 4.8, 9.0, 11.3, 13.6, 17.1, 23.1, 29.5, 35.1, 39.8, 42.2] # velocities
@@ -116,9 +120,9 @@ def smooth_follow(self): # in m/s
116120
y = [0, -0.017, -0.053, -0.154, -0.272] # modification values
117121
TR_mod = interp(self.v_lead + self.v_ego, x, y) # quicker acceleration/don't brake when lead is overtaking
118122

119-
x = [-1.49, -1.1, -0.67, 0.0, 0.67, 1.1, 1.49]
123+
'''x = [-1.49, -1.1, -0.67, 0.0, 0.67, 1.1, 1.49]
120124
y = [0.056, 0.032, 0.016, 0.0, -0.016, -0.032, -0.056]
121-
TR_mod += interp(self.get_acceleration(), x, y) # when lead car has been braking over the past 3 seconds, slightly increase TR
125+
TR_mod += interp(self.get_acceleration(), x, y) # when lead car has been braking over the past 3 seconds, slightly increase TR'''
122126

123127
TR += TR_mod
124128
TR *= self.get_traffic_level() # modify TR based on last minute of traffic data

0 commit comments

Comments
 (0)