Skip to content

Commit d72f6be

Browse files
authored
max accel tweaks
1 parent 6717ce7 commit d72f6be

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

selfdrive/car/toyota/carcontroller.py

+16-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
create_fcw_command
77
from selfdrive.car.toyota.values import Ecu, CAR, STATIC_MSGS, SteerLimitParams
88
from opendbc.can.packer import CANPacker
9+
from selfdrive.config import Conversions as CV
910

1011
VisualAlert = car.CarControl.HUDControl.VisualAlert
1112

@@ -65,8 +66,22 @@ def update(self, enabled, CS, frame, actuators, pcm_cancel_cmd, hud_alert,
6566
else:
6667
apply_accel = actuators.gas - actuators.brake
6768

69+
"""
70+
0 - 13mph: max accel of 1.5
71+
13-50 mph - 1.5m/s2 - 0.5 m/s2 dropping linearly with speed
72+
50 mph + = 0.5
73+
"""
74+
curr_speed_mph = CS.out.vEgo * CV.MS_TO_MPH
75+
new_accel_max = ACCEL_MAX
76+
if curr_speed_mph > 13:
77+
if curr_speed_mph >= 50:
78+
new_accel_max = 0.5
79+
else:
80+
# variable max_aceel between 10 mph and 50 mph
81+
new_accel_max = ACCEL_MAX - (((curr_speed_mph - 13.0)/ 37))
82+
6883
apply_accel, self.accel_steady = accel_hysteresis(apply_accel, self.accel_steady, enabled)
69-
apply_accel = clip(apply_accel * ACCEL_SCALE, ACCEL_MIN, ACCEL_MAX)
84+
apply_accel = clip(apply_accel * ACCEL_SCALE, ACCEL_MIN, new_accel_max)
7085

7186
# steer torque
7287
new_steer = int(round(actuators.steer * SteerLimitParams.STEER_MAX))

0 commit comments

Comments
 (0)