This commit is contained in:
firestar5683
2026-05-20 20:56:39 -05:00
parent 813507267c
commit 70229486bb
2 changed files with 26 additions and 2 deletions
+6 -2
View File
@@ -38,6 +38,11 @@ def calculate_speed_limit(cp_cam):
return 0
def calculate_interceptor_gas_pressed(cp) -> bool:
interceptor_gas = (cp.vl["GAS_SENSOR"]["INTERCEPTOR_GAS"] + cp.vl["GAS_SENSOR"]["INTERCEPTOR_GAS2"]) / 2
return interceptor_gas > 805
class CarState(CarStateBase):
def __init__(self, CP, FPCP):
super().__init__(CP, FPCP)
@@ -100,8 +105,7 @@ class CarState(CarStateBase):
can_gear = int(cp.vl["GEAR_PACKET_HYBRID"]["GEAR"])
else:
if self.CP.enableGasInterceptorDEPRECATED:
ret.gas = (cp.vl["GAS_SENSOR"]["INTERCEPTOR_GAS"] + cp.vl["GAS_SENSOR"]["INTERCEPTOR_GAS2"]) / 2
ret.gasPressed = ret.gas > 805
ret.gasPressed = calculate_interceptor_gas_pressed(cp)
else:
ret.gasPressed = cp.vl["PCM_CRUISE"]["GAS_RELEASED"] == 0 # TODO: these also have GAS_PEDAL, come back and unify
can_gear = int(cp.vl["GEAR_PACKET"]["GEAR"])
@@ -8,6 +8,7 @@ from opendbc.car.structs import CarParams
from opendbc.car.fw_versions import build_fw_dict
from opendbc.car.toyota import toyotacan
from opendbc.car.toyota.carcontroller import CarController, update_permit_braking
from opendbc.car.toyota.carstate import calculate_interceptor_gas_pressed
from opendbc.car.toyota.fingerprints import FW_VERSIONS
from opendbc.car.toyota.values import CAR, DBC, TSS2_CAR, ANGLE_CONTROL_CAR, RADAR_ACC_CAR, SECOC_CAR, \
FW_QUERY_CONFIG, PLATFORM_CODE_ECUS, FUZZY_EXCLUDED_PLATFORMS, \
@@ -322,3 +323,22 @@ class TestToyotaCarController:
)
assert gas_cmd == 0.0
class TestToyotaCarState:
def test_interceptor_gas_pressed_threshold(self):
cp = SimpleNamespace(vl={
"GAS_SENSOR": {
"INTERCEPTOR_GAS": 900,
"INTERCEPTOR_GAS2": 910,
}
})
assert calculate_interceptor_gas_pressed(cp) is True
cp = SimpleNamespace(vl={
"GAS_SENSOR": {
"INTERCEPTOR_GAS": 700,
"INTERCEPTOR_GAS2": 710,
}
})
assert calculate_interceptor_gas_pressed(cp) is False