mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-07-18 07:42:08 +08:00
toyota
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user