version: sunnypilot v2026.002.000 (staging) date: 2026-07-21T07:44:02 master commit: 2c334ede443d7391d27575af8c854a095ba702a8
58 lines
2.2 KiB
Python
58 lines
2.2 KiB
Python
from opendbc.car import get_safety_config, structs
|
|
from opendbc.car.interfaces import CarInterfaceBase
|
|
from opendbc.car.rivian.carcontroller import CarController
|
|
from opendbc.car.rivian.carstate import CarState
|
|
from opendbc.car.rivian.radar_interface import RadarInterface
|
|
from opendbc.car.rivian.values import RivianFlags, RivianSafetyFlags
|
|
from opendbc.sunnypilot.car.rivian.values import RivianFlagsSP
|
|
|
|
|
|
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)]
|
|
|
|
# GEN2 (2025+) doesn't have SCCM_WheelTouch on the bus
|
|
if 0x321 not in fingerprint[0]:
|
|
ret.flags |= RivianFlags.GEN2.value
|
|
|
|
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.vEgoStopping = 0.25
|
|
ret.stopAccel = 0
|
|
|
|
return ret
|
|
|
|
@staticmethod
|
|
def _get_params_sp(stock_cp: structs.CarParams, ret: structs.CarParamsSP, candidate, fingerprint: dict[int, dict[int, int]],
|
|
car_fw: list[structs.CarParams.CarFw], alpha_long: bool, is_release_sp: bool, docs: bool) -> structs.CarParamsSP:
|
|
if 0x131a in fingerprint[1]:
|
|
ret.flags |= RivianFlagsSP.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
|