mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-12-02 06:13:40 +08:00
Use the correct wheelbase for the 2018 Yukon XL CC
This commit is contained in:
@@ -12,6 +12,7 @@ from opendbc.car.mock.values import CAR as MOCK
|
||||
from opendbc.car.gm.pedal_capability import automatic_bolt_candidate
|
||||
from opendbc.car.gm.discovery import (automatic_trax_candidate, automatic_volt_ascm_candidate, automatic_volt_candidate,
|
||||
normal_bus0_topology as gm_normal_bus0_topology)
|
||||
from opendbc.car.gm.values import CAR as GM
|
||||
from opendbc.car.ford.discovery import (normal_bus0_selection as ford_normal_bus0_selection,
|
||||
normal_bus0_queries as ford_normal_bus0_queries, normal_bus_query_brand)
|
||||
from opendbc.car.volvo.discovery import normal_bus_topology as volvo_normal_bus_topology, v60_bus_topology as volvo_v60_bus_topology
|
||||
@@ -334,6 +335,8 @@ def get_car(can_recv: CanRecvCallable, can_send: CanSendCallable, set_obd_multip
|
||||
|
||||
CarInterface = interfaces[candidate]
|
||||
params_options = {'auto_pedal': False} if source == CarParams.FingerprintSource.fixed and candidate in interface_names['gm'] else {}
|
||||
if candidate == GM.GMC_YUKON_CC:
|
||||
params_options['vin'] = vin
|
||||
CP: CarParams = CarInterface.get_params(candidate, fingerprints, car_fw, alpha_long_allowed, is_release, docs=False, **params_options)
|
||||
CP.carVin = vin
|
||||
CP.carFw = car_fw
|
||||
|
||||
@@ -3,7 +3,7 @@ from opendbc.car import ACCEL_MAX_TAKEOFF
|
||||
from math import fabs, exp
|
||||
import numpy as np
|
||||
|
||||
from opendbc.car import Bus, get_safety_config, structs
|
||||
from opendbc.car import Bus, get_safety_config, scale_rot_inertia, scale_tire_stiffness, structs
|
||||
from opendbc.car.pedal import supported_pedal_detected
|
||||
from opendbc.car.gm.pedal_capability import pedal_candidate
|
||||
from opendbc.car.common.conversions import Conversions as CV
|
||||
@@ -22,6 +22,7 @@ from opendbc.car.gm.values import (volt_cc_pedal_profile, CAR, CarControllerPara
|
||||
from opendbc.car.gm.values import (malibu_hybrid_profile, MALIBU_HYBRID_SOURCES,
|
||||
is_volt_sdgm_accepted_envelope, volt_sdgm_accepted_accel_max)
|
||||
from opendbc.car.interfaces import CarInterfaceBase, TorqueFromLateralAccelCallbackType, LateralAccelFromTorqueCallbackType
|
||||
from opendbc.car.vin import VIN_UNKNOWN, is_valid_vin
|
||||
|
||||
TransmissionType = structs.CarParams.TransmissionType
|
||||
NetworkLocation = structs.CarParams.NetworkLocation
|
||||
@@ -43,9 +44,16 @@ class CarInterface(CarInterfaceBase):
|
||||
structs.CarState.GearShifter.eco, structs.CarState.GearShifter.manumatic)
|
||||
|
||||
@classmethod
|
||||
def get_params(cls, candidate, fingerprint, car_fw, alpha_long, is_release, docs, *, auto_pedal=True):
|
||||
def get_params(cls, candidate, fingerprint, car_fw, alpha_long, is_release, docs, *, auto_pedal=True, vin=VIN_UNKNOWN):
|
||||
selected = pedal_candidate(candidate, fingerprint) if auto_pedal else candidate
|
||||
return super().get_params(selected, fingerprint, car_fw, alpha_long, is_release, docs)
|
||||
ret = super().get_params(selected, fingerprint, car_fw, alpha_long, is_release, docs)
|
||||
# The recorded 2018 Yukon XL SLT uses the same CC profile as the short Yukon.
|
||||
if selected == CAR.GMC_YUKON_CC and is_valid_vin(vin) and vin.startswith('1GKS2GKC') and vin[9] == 'J':
|
||||
ret.wheelbase = 3.302 # GMC 2018 Yukon brochure, 130.0 inches.
|
||||
ret.centerToFront = ret.wheelbase * CAR.GMC_YUKON_CC.config.specs.centerToFrontRatio
|
||||
ret.rotationalInertia = scale_rot_inertia(ret.mass, ret.wheelbase)
|
||||
ret.tireStiffnessFront, ret.tireStiffnessRear = scale_tire_stiffness(ret.mass, ret.wheelbase, ret.centerToFront, ret.tireStiffnessFactor)
|
||||
return ret
|
||||
|
||||
def apply(self, c, now_nanos=None, *, startup_keepalive=False):
|
||||
if startup_keepalive:
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
|
||||
from opendbc.car import car_helpers, gen_empty_fingerprint, scale_rot_inertia, structs
|
||||
from opendbc.car.gm.values import CAR
|
||||
from opendbc.car.vin import VIN_UNKNOWN
|
||||
|
||||
|
||||
@pytest.mark.parametrize('candidate,vin,xl', [
|
||||
(CAR.GMC_YUKON_CC, '1GKS2GKC0JR000001', True),
|
||||
(CAR.GMC_YUKON_CC, '1GKS2BKC0JR000001', False),
|
||||
(CAR.GMC_YUKON_CC, '1GKS2GKC0KR000001', False),
|
||||
(CAR.GMC_YUKON_CC, VIN_UNKNOWN, False),
|
||||
(CAR.GMC_YUKON, '1GKS2GKC0JR000001', False),
|
||||
(CAR.BUICK_LACROSSE_ASCM_19US, '1GKS2GKC0JR000001', False),
|
||||
])
|
||||
def test_manual_profile_retains_its_control_config_with_vin_geometry(candidate, vin, xl):
|
||||
fp = gen_empty_fingerprint()
|
||||
with patch.object(car_helpers, 'fingerprint', return_value=(None, fp, vin, [], structs.CarParams.FingerprintSource.can, True)):
|
||||
cp = car_helpers.get_car(lambda **_: [], lambda _: None, lambda _: None, False, True, forced_candidate=candidate).CP
|
||||
|
||||
assert cp.carFingerprint == candidate and cp.fingerprintSource == structs.CarParams.FingerprintSource.fixed
|
||||
baseline = car_helpers.interfaces[candidate].get_params(candidate, fp, [], False, True, False, auto_pedal=False)
|
||||
assert cp.wheelbase == pytest.approx(3.302 if xl else baseline.wheelbase)
|
||||
assert cp.centerToFront == pytest.approx(cp.wheelbase * candidate.config.specs.centerToFrontRatio)
|
||||
assert cp.rotationalInertia == pytest.approx(scale_rot_inertia(cp.mass, cp.wheelbase))
|
||||
assert cp.lateralTuning.to_dict() == baseline.lateralTuning.to_dict()
|
||||
assert cp.safetyConfigs[0].to_dict() == baseline.safetyConfigs[0].to_dict()
|
||||
assert cp.openpilotLongitudinalControl == baseline.openpilotLongitudinalControl
|
||||
assert cp.steerRatio == baseline.steerRatio
|
||||
+1
-1
@@ -1 +1 @@
|
||||
{"protected_inventory_sha256": "b15302bb63b7e6f516d2f1f96e44811efc3354e38d2a6b3c5a8e04b1208c84b1", "schema_version": 1}
|
||||
{"protected_inventory_sha256": "33a8ecffff4f82dfa2a619f102ea87edb2f00fb0cd9f66e27afa0e8da5288a7c", "schema_version": 1}
|
||||
|
||||
Reference in New Issue
Block a user