Skip to content

Commit

Permalink
Toyota: set permit braking when stopping (#1447)
Browse files Browse the repository at this point in the history
* we need to brake when stopping always

* stopping
  • Loading branch information
sshane authored Nov 6, 2024
1 parent 6be3d04 commit f090bf6
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions opendbc/car/toyota/carcontroller.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ def __init__(self, dbc_name, CP):

def update(self, CC, CS, now_nanos):
actuators = CC.actuators
stopping = actuators.longControlState == LongCtrlState.stopping
hud_control = CC.hudControl
pcm_cancel_cmd = CC.cruiseControl.cancel
lat_active = CC.latActive and abs(CS.out.steeringTorque) < MAX_USER_TORQUE
Expand Down Expand Up @@ -155,7 +156,7 @@ def update(self, CC, CS, now_nanos):

# let PCM handle stopping for now
pcm_accel_compensation = 0.0
if actuators.longControlState != LongCtrlState.stopping:
if not stopping:
pcm_accel_compensation = 2.0 * (CS.pcm_accel_net - net_acceleration_request)

# prevent compensation windup
Expand All @@ -167,7 +168,7 @@ def update(self, CC, CS, now_nanos):

# Along with rate limiting positive jerk below, this greatly improves gas response time
# Consider the net acceleration request that the PCM should be applying (pitch included)
if net_acceleration_request < 0.1:
if net_acceleration_request < 0.1 or stopping:
self.permit_braking = True
elif net_acceleration_request > 0.2:
self.permit_braking = False
Expand Down

0 comments on commit f090bf6

Please sign in to comment.