Skip to content

Commit

Permalink
Re-apply "Lexus ES TSS2: improve start from stop response time" (#1303)
Browse files Browse the repository at this point in the history
* Revert "Revert "Lexus ES TSS2: improve start from stop response time" (#1302)"

This reverts commit c696545.

* something like this? check it allows start from stop
  • Loading branch information
sshane authored Sep 28, 2024
1 parent c696545 commit 173ab90
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
15 changes: 12 additions & 3 deletions opendbc/car/toyota/carcontroller.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def __init__(self, dbc_name, CP):
self.distance_button = 0

self.pcm_accel_compensation = 0.0
self.permit_braking = 0.0

self.packer = CANPacker(dbc_name)
self.accel = 0
Expand Down Expand Up @@ -125,9 +126,17 @@ def update(self, CC, CS, now_nanos):

self.pcm_accel_compensation = rate_limit(pcm_accel_compensation, self.pcm_accel_compensation, -0.01, 0.01)
pcm_accel_cmd = actuators.accel - self.pcm_accel_compensation

# 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:
self.permit_braking = True
elif net_acceleration_request > 0.2:
self.permit_braking = False
else:
self.pcm_accel_compensation = 0.0
pcm_accel_cmd = actuators.accel
self.permit_braking = True

pcm_accel_cmd = clip(pcm_accel_cmd, self.params.ACCEL_MIN, self.params.ACCEL_MAX)

Expand Down Expand Up @@ -163,11 +172,11 @@ def update(self, CC, CS, now_nanos):
# internal PCM gas command can get stuck unwinding from negative accel so we apply a generous rate limit
pcm_accel_cmd = min(pcm_accel_cmd, self.accel + ACCEL_WINDUP_LIMIT) if CC.longActive else 0.0

can_sends.append(toyotacan.create_accel_command(self.packer, pcm_accel_cmd, pcm_cancel_cmd, self.standstill_req, lead, CS.acc_type, fcw_alert,
self.distance_button))
can_sends.append(toyotacan.create_accel_command(self.packer, pcm_accel_cmd, pcm_cancel_cmd, self.permit_braking, self.standstill_req, lead,
CS.acc_type, fcw_alert, self.distance_button))
self.accel = pcm_accel_cmd
else:
can_sends.append(toyotacan.create_accel_command(self.packer, 0, pcm_cancel_cmd, False, lead, CS.acc_type, False, self.distance_button))
can_sends.append(toyotacan.create_accel_command(self.packer, 0, pcm_cancel_cmd, True, False, lead, CS.acc_type, False, self.distance_button))

# *** hud ui ***
if self.CP.carFingerprint != CAR.TOYOTA_PRIUS_V:
Expand Down
4 changes: 2 additions & 2 deletions opendbc/car/toyota/toyotacan.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ def create_lta_steer_command(packer, steer_control_type, steer_angle, steer_req,
return packer.make_can_msg("STEERING_LTA", 0, values)


def create_accel_command(packer, accel, pcm_cancel, standstill_req, lead, acc_type, fcw_alert, distance):
def create_accel_command(packer, accel, pcm_cancel, permit_braking, standstill_req, lead, acc_type, fcw_alert, distance):
# TODO: find the exact canceling bit that does not create a chime
values = {
"ACCEL_CMD": accel,
"ACC_TYPE": acc_type,
"DISTANCE": distance,
"MINI_CAR": lead,
"PERMIT_BRAKING": 1,
"PERMIT_BRAKING": permit_braking,
"RELEASE_STANDSTILL": not standstill_req,
"CANCEL_REQ": pcm_cancel,
"ALLOW_LONG_PRESS": 1,
Expand Down

0 comments on commit 173ab90

Please sign in to comment.