Dampen longitudinal oscillation on four-byte filter Sienna

This commit is contained in:
firestar5683
2026-11-23 15:49:30 -06:00
parent cf26c720f0
commit 4f07a1ea4a
3 changed files with 34 additions and 2 deletions
@@ -58,7 +58,10 @@ def supports_toyota_auto_hold(CP):
def get_long_tune(CP, params):
prius = prius_longitudinal.enabled(CP)
if prius or CP.flags & ToyotaFlags.TSS2 or dom_defaults.camry_hybrid(CP) or dom_defaults.rav4h_sdsu(CP):
# The generic integral gain amplifies small acceleration requests on the four-byte Sienna filter.
sienna_filter = (CP.carFingerprint == CAR.TOYOTA_SIENNA and not CP.flags & ToyotaFlags.GAS_INTERCEPTOR and
legacy_advert_filter.enabled(CP))
if prius or sienna_filter or CP.flags & ToyotaFlags.TSS2 or dom_defaults.camry_hybrid(CP) or dom_defaults.rav4h_sdsu(CP):
kiBP = [2., 5.]
kiV = [0.5, 0.25]
else:
@@ -0,0 +1,29 @@
import pytest
from opendbc.car import gen_empty_fingerprint, structs
from opendbc.car.toyota import legacy_advert_filter
from opendbc.car.toyota.carcontroller import get_long_tune
from opendbc.car.toyota.fingerprints import FW_VERSIONS
from opendbc.car.toyota.interface import CarInterface
from opendbc.car.toyota.values import CAR, CarControllerParams
@pytest.mark.parametrize('vehicle,dlc,factory_acc,expected', (
(CAR.TOYOTA_SIENNA, 4, False, ([2., 5.], [0.5, 0.25])),
(CAR.TOYOTA_SIENNA, 4, True, ([0., 5., 35.], [3.6, 2.4, 1.5])),
(CAR.TOYOTA_SIENNA, 8, False, ([0., 5., 35.], [3.6, 2.4, 1.5])),
(CAR.TOYOTA_HIGHLANDER, 4, False, ([0., 5., 35.], [3.6, 2.4, 1.5])),
))
def test_sienna_filter_integral_tune(vehicle, dlc, factory_acc, expected):
fp = gen_empty_fingerprint()
fp[0][0x2FF] = dlc
fw = [structs.CarParams.CarFw(ecu=ecu, address=addr, subAddress=sub or 0, fwVersion=versions[0], brand='toyota', bus=0)
for (ecu, addr, sub), versions in FW_VERSIONS[vehicle].items()]
cp = CarInterface.get_params(vehicle, fp, fw, True, False, False)
assert cp.openpilotLongitudinalControl
assert legacy_advert_filter.enabled(cp) == (dlc == 4)
if factory_acc:
assert legacy_advert_filter.prepare_stock(cp)
tune = get_long_tune(cp, CarControllerParams(cp))
assert tune._k_i == expected
assert tune.k_f == 1.
+1 -1
View File
@@ -1 +1 @@
{"protected_inventory_sha256": "77f98ad412b3865bebaf283929c910006755ad37f04e87612cab2711b59ce7aa", "schema_version": 1}
{"protected_inventory_sha256": "9bd980388726a0c0b4c768203134698c01e50d0ecc6844a8a47f59ce4c3796fc", "schema_version": 1}