1
0
forked from IQ.Lvbs/IQ.Pilot
Files
IQ.Pilot/iqdbc_repo/iqdbc/car/rivian/interface.py
2026-08-22 23:42:42 -05:00

55 lines
2.1 KiB
Python

from iqdbc.car import get_safety_config, structs
from iqdbc.car.interfaces import CarInterfaceBase
from iqdbc.car.rivian.carcontroller import CarController
from iqdbc.car.rivian.carstate import CarState
from iqdbc.car.rivian.radar_interface import RadarInterface
from iqdbc.car.rivian.values import RivianSafetyFlags
from iqdbc.lvbs.car.rivian.values import RivianFlagsIQ
class CarInterface(CarInterfaceBase):
CarState = CarState
CarController = CarController
RadarInterface = RadarInterface
@staticmethod
def _get_params(ret: structs.CarParams, candidate, fingerprint, car_fw, alpha_long, is_release, docs) -> structs.CarParams:
ret.brand = "rivian"
ret.safetyConfigs = [get_safety_config(structs.CarParams.SafetyModel.rivian)]
ret.steerActuatorDelay = 0.15
ret.steerLimitTimer = 0.4
CarInterfaceBase.configure_torque_tune(candidate, ret.lateralTuning)
ret.steerControlType = structs.CarParams.SteerControlType.torque
ret.radarUnavailable = True
# TODO: pending finding/handling missing set speed
ret.alphaLongitudinalAvailable = False
if alpha_long:
ret.openpilotLongitudinalControl = True
ret.safetyConfigs[0].safetyParam |= RivianSafetyFlags.LONG_CONTROL.value
ret.longitudinalActuatorDelay = 0.35
ret.stopAccel = 0
return ret
@staticmethod
def _get_params_iq(stock_cp: structs.CarParams, ret: structs.IQCarParams, candidate, fingerprint: dict[int, dict[int, int]],
car_fw: list[structs.CarParams.CarFw], alpha_long: bool, is_release_iq: bool, docs: bool) -> structs.IQCarParams:
# Longitudinal harness upgrade advertises msg 0x31a on bus 5; when present it
# unlocks radar, blind-spot and openpilot longitudinal on Rivian.
if 0x31a in fingerprint[5]:
ret.flags |= RivianFlagsIQ.LONGITUDINAL_HARNESS_UPGRADE.value
stock_cp.radarUnavailable = False
stock_cp.enableBsm = True
stock_cp.alphaLongitudinalAvailable = True
if alpha_long and stock_cp.alphaLongitudinalAvailable:
stock_cp.openpilotLongitudinalControl = True
stock_cp.safetyConfigs[0].safetyParam |= RivianSafetyFlags.LONG_CONTROL.value
return ret