forked from IQ.Lvbs/IQ.Pilot
IQ.Pilot Prebuilt Release @ 67fd9c2
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
"""
|
||||
Copyright © IQ.Lvbs, apart of Project Teal Lvbs, All Rights Reserved, licensed under https://konn3kt.com/tos
|
||||
"""
|
||||
19
artifacts/package_runtime/iqdbc/lvbs/car/honda/aol.py
Normal file
19
artifacts/package_runtime/iqdbc/lvbs/car/honda/aol.py
Normal file
@@ -0,0 +1,19 @@
|
||||
"""
|
||||
Copyright © IQ.Lvbs, apart of Project Teal Lvbs, All Rights Reserved, licensed under https://konn3kt.com/tos
|
||||
"""
|
||||
|
||||
from iqdbc.car import structs
|
||||
from iqdbc.car.honda.values import HONDA_BOSCH_RADARLESS
|
||||
|
||||
|
||||
class AolCarController:
|
||||
def __init__(self):
|
||||
self.dashed_lanes = False
|
||||
|
||||
def update(self, CP: structs.CarParams, CC: structs.CarControl, CC_IQ: structs.IQCarControl) -> None:
|
||||
enable_aol = CC_IQ.aol.available
|
||||
|
||||
if enable_aol:
|
||||
self.dashed_lanes = CC_IQ.aol.enabled and not CC.latActive
|
||||
else:
|
||||
self.dashed_lanes = CC.hudControl.lanesVisible if CP.carFingerprint in HONDA_BOSCH_RADARLESS else False
|
||||
@@ -0,0 +1,32 @@
|
||||
"""
|
||||
Copyright © IQ.Lvbs, apart of Project Teal Lvbs, All Rights Reserved, licensed under https://konn3kt.com/tos
|
||||
"""
|
||||
|
||||
import numpy as np
|
||||
|
||||
from iqdbc.car import structs
|
||||
from iqdbc.car.can_definitions import CanData
|
||||
from iqdbc.lvbs.car import create_gas_interceptor_command
|
||||
|
||||
|
||||
class GasInterceptorCarController:
|
||||
def __init__(self, CP: structs.CarParams, CP_IQ: structs.IQCarParams):
|
||||
self.CP = CP
|
||||
self.CP_IQ = CP_IQ
|
||||
|
||||
self.gas = 0.
|
||||
self.interceptor_gas_cmd = 0.
|
||||
|
||||
def update(self, CC: structs.CarControl, CS: structs.CarState, gas: float, brake: float, wind_brake: float,
|
||||
packer, frame: int) -> list[CanData]:
|
||||
can_sends = []
|
||||
|
||||
if self.CP_IQ.enableGasInterceptor:
|
||||
gas_pedal = np.interp(CS.out.vEgo, [0., 10.], [0.4, 1.0])
|
||||
if CC.longActive:
|
||||
self.gas = float(np.clip(gas_pedal * (gas - brake + wind_brake * 3 / 4), 0., 1.))
|
||||
else:
|
||||
self.gas = 0.0
|
||||
can_sends.append(create_gas_interceptor_command(packer, self.gas, frame // 2))
|
||||
|
||||
return can_sends
|
||||
@@ -0,0 +1,37 @@
|
||||
"""
|
||||
Copyright © IQ.Lvbs, apart of Project Teal Lvbs, All Rights Reserved, licensed under https://konn3kt.com/tos
|
||||
"""
|
||||
from enum import StrEnum
|
||||
|
||||
from iqdbc.car import Bus, structs
|
||||
from iqdbc.car.common.conversions import Conversions as CV
|
||||
from iqdbc.car.honda.values import HONDA_BOSCH, HONDA_BOSCH_CANFD, HONDA_BOSCH_RADARLESS
|
||||
from iqdbc.can.parser import CANParser
|
||||
from iqdbc.lvbs.car.honda.iq_values import HondaFlagsIQ
|
||||
|
||||
|
||||
class IQCarState:
|
||||
def __init__(self, CP, CP_IQ):
|
||||
self.CP = CP
|
||||
self.CP_IQ = CP_IQ
|
||||
|
||||
def update(self, ret: structs.CarState, ret_iq: structs.IQCarState, can_parsers: dict[StrEnum, CANParser]) -> None:
|
||||
cp = can_parsers[Bus.pt]
|
||||
cp_cam = can_parsers[Bus.cam]
|
||||
|
||||
if self.CP_IQ.flags & HondaFlagsIQ.HAS_CAMERA_MESSAGES:
|
||||
speed_bus = cp if (self.CP.carFingerprint in (HONDA_BOSCH - HONDA_BOSCH_RADARLESS - HONDA_BOSCH_CANFD)) else cp_cam
|
||||
speed_limit_raw = speed_bus.vl["CAMERA_MESSAGES"]["SPEED_LIMIT_SIGN"] % 32
|
||||
ret_iq.speedLimit = speed_limit_raw * 5.0 * CV.MPH_TO_MS if (1 <= speed_limit_raw <= 17) else 0.0
|
||||
|
||||
if self.CP_IQ.flags & HondaFlagsIQ.NIDEC_HYBRID:
|
||||
ret.accFaulted = bool(cp.vl["HYBRID_BRAKE_ERROR"]["BRAKE_ERROR_1"] or cp.vl["HYBRID_BRAKE_ERROR"]["BRAKE_ERROR_2"])
|
||||
ret.stockAeb = bool(cp_cam.vl["BRAKE_COMMAND"]["AEB_REQ_1"] and cp_cam.vl["BRAKE_COMMAND"]["COMPUTER_BRAKE_HYBRID"] > 1e-5)
|
||||
|
||||
if self.CP_IQ.flags & HondaFlagsIQ.HYBRID_ALT_BRAKEHOLD:
|
||||
ret.brakeHoldActive = cp.vl["BRAKE_HOLD_HYBRID_ALT"]["BRAKE_HOLD_ACTIVE"] == 1
|
||||
|
||||
if self.CP_IQ.enableGasInterceptor:
|
||||
# Same threshold as panda, equivalent to 1e-5 with previous DBC scaling
|
||||
gas = (cp.vl["GAS_SENSOR"]["INTERCEPTOR_GAS"] + cp.vl["GAS_SENSOR"]["INTERCEPTOR_GAS2"]) // 2
|
||||
ret.gasPressed = gas > 492
|
||||
@@ -0,0 +1,56 @@
|
||||
"""
|
||||
Copyright © IQ.Lvbs, apart of Project Teal Lvbs, All Rights Reserved, licensed under https://konn3kt.com/tos
|
||||
"""
|
||||
|
||||
from iqdbc.car.structs import CarParams
|
||||
from iqdbc.car.honda.values import CAR
|
||||
|
||||
Ecu = CarParams.Ecu
|
||||
|
||||
FW_VERSIONS_EXT = {
|
||||
CAR.HONDA_ACCORD: {
|
||||
(Ecu.eps, 0x18da30f1, None): [
|
||||
b'39990-TVA,A150\x00\x00',
|
||||
],
|
||||
},
|
||||
CAR.HONDA_CIVIC: {
|
||||
(Ecu.eps, 0x18da30f1, None): [
|
||||
b'39990-TBA,A030\x00\x00',
|
||||
],
|
||||
},
|
||||
CAR.HONDA_CIVIC_BOSCH: {
|
||||
(Ecu.eps, 0x18da30f1, None): [
|
||||
b'39990-TGG,A020\x00\x00',
|
||||
b'39990-TGG,A120\x00\x00',
|
||||
],
|
||||
},
|
||||
CAR.HONDA_CRV_5G: {
|
||||
(Ecu.eps, 0x18da30f1, None): [
|
||||
b'39990-TLA,A040\x00\x00',
|
||||
],
|
||||
},
|
||||
CAR.HONDA_CLARITY: {
|
||||
(Ecu.shiftByWire, 0x18da0bf1, None): [
|
||||
b'54008-TRW-A910\x00\x00',
|
||||
],
|
||||
(Ecu.vsa, 0x18da28f1, None): [
|
||||
b'57114-TRW-A010\x00\x00',
|
||||
b'57114-TRW-A020\x00\x00',
|
||||
],
|
||||
(Ecu.eps, 0x18da30f1, None): [
|
||||
b'39990-TRW-A020\x00\x00',
|
||||
b'39990-TRW,A020\x00\x00', # modified firmware
|
||||
b'39990,TRW,A020\x00\x00', # extra modified firmware
|
||||
],
|
||||
(Ecu.srs, 0x18da53f1, None): [
|
||||
b'77959-TRW-A210\x00\x00',
|
||||
b'77959-TRW-A220\x00\x00',
|
||||
],
|
||||
(Ecu.gateway, 0x18daeff1, None): [
|
||||
b'38897-TRW-A010\x00\x00',
|
||||
],
|
||||
(Ecu.fwdRadar, 0x18dab0f1, None): [
|
||||
b'36161-TRW-A110\x00\x00',
|
||||
],
|
||||
},
|
||||
}
|
||||
17
artifacts/package_runtime/iqdbc/lvbs/car/honda/iq_values.py
Normal file
17
artifacts/package_runtime/iqdbc/lvbs/car/honda/iq_values.py
Normal file
@@ -0,0 +1,17 @@
|
||||
"""
|
||||
Copyright © IQ.Lvbs, apart of Project Teal Lvbs, All Rights Reserved, licensed under https://konn3kt.com/tos
|
||||
"""
|
||||
|
||||
from enum import IntFlag
|
||||
|
||||
|
||||
class HondaFlagsIQ(IntFlag):
|
||||
NIDEC_HYBRID = 1
|
||||
EPS_MODIFIED = 2
|
||||
HYBRID_ALT_BRAKEHOLD = 4
|
||||
HAS_CAMERA_MESSAGES = 8
|
||||
|
||||
|
||||
class HondaSafetyFlagsIQ:
|
||||
NIDEC_HYBRID = 1
|
||||
GAS_INTERCEPTOR = 2
|
||||
48
artifacts/package_runtime/iqdbc/lvbs/car/honda/test_honda.py
Normal file
48
artifacts/package_runtime/iqdbc/lvbs/car/honda/test_honda.py
Normal file
@@ -0,0 +1,48 @@
|
||||
"""
|
||||
Copyright © IQ.Lvbs, apart of Project Teal Lvbs, All Rights Reserved, licensed under https://konn3kt.com/tos
|
||||
"""
|
||||
from parameterized import parameterized
|
||||
from types import SimpleNamespace
|
||||
|
||||
from iqdbc.can import CANParser
|
||||
from iqdbc.car import Bus, gen_empty_fingerprint
|
||||
from iqdbc.car.structs import CarParams, CarState, IQCarState as IQCarStateStruct
|
||||
from iqdbc.car.car_helpers import interfaces
|
||||
from iqdbc.car.honda.values import CAR
|
||||
from iqdbc.lvbs.car.honda.iq_carstate import IQCarState
|
||||
|
||||
CarFw = CarParams.CarFw
|
||||
|
||||
|
||||
class TestHondaEpsMod:
|
||||
|
||||
@parameterized.expand([(CAR.HONDA_CIVIC, b'39990-TBA,A030\x00\x00'), (CAR.HONDA_CIVIC, b'39990-TBA-A030\x00\x00'),
|
||||
(CAR.HONDA_CLARITY, b'39990-TRW-A020\x00\x00'), (CAR.HONDA_CLARITY, b'39990,TRW,A020\x00\x00')])
|
||||
def test_eps_mod_fingerprint(self, car_name, fw):
|
||||
fingerprint = gen_empty_fingerprint()
|
||||
car_fw = [CarFw(ecu="eps", fwVersion=fw)]
|
||||
|
||||
CarInterface = interfaces[car_name]
|
||||
CP = CarInterface.get_params(car_name, fingerprint, car_fw, False, False, False)
|
||||
_ = CarInterface.get_params_iq(CP, car_name, fingerprint, car_fw, False, False, False)
|
||||
|
||||
assert not CP.dashcamOnly
|
||||
|
||||
|
||||
class TestHondaGasInterceptor:
|
||||
def test_gas_sensor_registration_and_threshold(self):
|
||||
CP = SimpleNamespace()
|
||||
CP_IQ = SimpleNamespace(enableGasInterceptor=True, flags=0)
|
||||
parser = CANParser("acura_ilx_2016_can_generated", [], 0)
|
||||
state = IQCarState(CP, CP_IQ)
|
||||
ret = CarState()
|
||||
ret_iq = IQCarStateStruct()
|
||||
|
||||
state.update(ret, ret_iq, {Bus.pt: parser, Bus.cam: parser})
|
||||
assert "GAS_SENSOR" in parser.vl
|
||||
assert not ret.gasPressed
|
||||
|
||||
parser.vl["GAS_SENSOR"]["INTERCEPTOR_GAS"] = 493
|
||||
parser.vl["GAS_SENSOR"]["INTERCEPTOR_GAS2"] = 493
|
||||
state.update(ret, ret_iq, {Bus.pt: parser, Bus.cam: parser})
|
||||
assert ret.gasPressed
|
||||
Reference in New Issue
Block a user