Revert "impreza fingerprint"

This reverts commit 692e34c7f8.
This commit is contained in:
elkoled
2026-01-16 18:56:35 -08:00
parent 692e34c7f8
commit 3fb0d394e7
13 changed files with 55 additions and 122 deletions

View File

@@ -78,6 +78,7 @@ class Cable(EnumBase):
long_obdc_cable = BasePart("long OBD-C cable (9.5 ft)")
usb_a_2_a_cable = BasePart("USB A-A cable")
usbc_otg_cable = BasePart("USB C OTG cable")
usbc_coupler = BasePart("USB-C coupler")
obd_c_cable_2ft = BasePart("OBD-C cable (2 ft)")
@@ -111,7 +112,7 @@ class CarHarness(EnumBase):
fca = BaseCarHarness("FCA connector")
ram = BaseCarHarness("Ram connector")
vw_a = BaseCarHarness("VW A connector")
vw_j533 = BaseCarHarness("VW J533 connector", parts=[Accessory.harness_box, Cable.long_obdc_cable])
vw_j533 = BaseCarHarness("VW J533 connector", parts=[Accessory.harness_box, Cable.long_obdc_cable, Cable.usbc_coupler])
hyundai_a = BaseCarHarness("Hyundai A connector")
hyundai_b = BaseCarHarness("Hyundai B connector")
hyundai_c = BaseCarHarness("Hyundai C connector")
@@ -131,18 +132,18 @@ class CarHarness(EnumBase):
hyundai_q = BaseCarHarness("Hyundai Q connector")
hyundai_r = BaseCarHarness("Hyundai R connector")
custom = BaseCarHarness("Developer connector")
obd_ii = BaseCarHarness("OBD-II connector", parts=[Cable.long_obdc_cable], has_connector=False)
obd_ii = BaseCarHarness("OBD-II connector", parts=[Cable.long_obdc_cable, Cable.usbc_coupler], has_connector=False)
gm = BaseCarHarness("GM connector", parts=[Accessory.harness_box])
gmsdgm = BaseCarHarness("GM SDGM connector", parts=[Accessory.harness_box, Accessory.comma_power, Cable.long_obdc_cable])
nissan_a = BaseCarHarness("Nissan A connector", parts=[Accessory.harness_box, Accessory.comma_power, Cable.long_obdc_cable])
nissan_b = BaseCarHarness("Nissan B connector", parts=[Accessory.harness_box, Accessory.comma_power, Cable.long_obdc_cable])
gmsdgm = BaseCarHarness("GM SDGM connector", parts=[Accessory.harness_box, Accessory.comma_power, Cable.long_obdc_cable, Cable.usbc_coupler])
nissan_a = BaseCarHarness("Nissan A connector", parts=[Accessory.harness_box, Accessory.comma_power, Cable.long_obdc_cable, Cable.usbc_coupler])
nissan_b = BaseCarHarness("Nissan B connector", parts=[Accessory.harness_box, Accessory.comma_power, Cable.long_obdc_cable, Cable.usbc_coupler])
mazda = BaseCarHarness("Mazda connector")
ford_q3 = BaseCarHarness("Ford Q3 connector")
ford_q4 = BaseCarHarness("Ford Q4 connector", parts=[Accessory.harness_box, Accessory.comma_power, Cable.long_obdc_cable])
rivian = BaseCarHarness("Rivian A connector", parts=[Accessory.harness_box, Accessory.comma_power, Cable.long_obdc_cable])
tesla_a = BaseCarHarness("Tesla A connector", parts=[Accessory.harness_box, Cable.long_obdc_cable])
tesla_b = BaseCarHarness("Tesla B connector", parts=[Accessory.harness_box, Cable.long_obdc_cable])
psa_a = BaseCarHarness("PSA A connector", parts=[Accessory.harness_box, Cable.long_obdc_cable])
ford_q4 = BaseCarHarness("Ford Q4 connector", parts=[Accessory.harness_box, Accessory.comma_power, Cable.long_obdc_cable, Cable.usbc_coupler])
rivian = BaseCarHarness("Rivian A connector", parts=[Accessory.harness_box, Accessory.comma_power, Cable.long_obdc_cable, Cable.usbc_coupler])
tesla_a = BaseCarHarness("Tesla A connector", parts=[Accessory.harness_box, Cable.long_obdc_cable, Cable.usbc_coupler])
tesla_b = BaseCarHarness("Tesla B connector", parts=[Accessory.harness_box, Cable.long_obdc_cable, Cable.usbc_coupler])
psa_a = BaseCarHarness("PSA A connector", parts=[Accessory.harness_box, Cable.long_obdc_cable, Cable.usbc_coupler])
class Device(EnumBase):
@@ -393,7 +394,7 @@ class CarDocs:
@dataclass
class ExtraCarDocs(CarDocs):
package: str = "All"
package: str = "Any"
merged: bool = False
support_type: SupportType = SupportType.INCOMPATIBLE
support_link: str | None = "#incompatible"

View File

@@ -37,19 +37,19 @@ class CAR(Platforms):
EXTRA_HONDA = ExtraPlatformConfig(
[
CommunityCarDocs("Acura Integra 2023-25"),
CommunityCarDocs("Acura Integra 2023-25", "All"),
CommunityCarDocs("Acura MDX 2015-16", "Advance Package"),
CommunityCarDocs("Acura MDX 2017-20"),
CommunityCarDocs("Acura MDX 2022-24"),
CommunityCarDocs("Acura RDX 2022-25"),
CommunityCarDocs("Acura MDX 2017-20", "All"),
CommunityCarDocs("Acura MDX 2022-24", "All"),
CommunityCarDocs("Acura RDX 2022-25", "All"),
CommunityCarDocs("Acura RLX 2017", "Advance Package or Technology Package"),
CommunityCarDocs("Acura TLX 2015-17", "Advance Package"),
CommunityCarDocs("Acura TLX 2018-20"),
CommunityCarDocs("Acura TLX 2022-23"),
GMSecurityCarDocs("Acura ZDX 2024"),
CommunityCarDocs("Acura TLX 2018-20", "All"),
CommunityCarDocs("Acura TLX 2022-23", "All"),
GMSecurityCarDocs("Acura ZDX 2024", "All"),
CommunityCarDocs("Honda Accord 2016-17", "Honda Sensing"),
CommunityCarDocs("Honda Clarity 2018-21"),
GMSecurityCarDocs("Honda Prologue 2024-25"),
CommunityCarDocs("Honda Clarity 2018-21", "All"),
GMSecurityCarDocs("Honda Prologue 2024-25", "All"),
],
)
@@ -78,8 +78,8 @@ class CAR(Platforms):
EXTRA_VOLKSWAGEN = ExtraPlatformConfig(
[
FlexRayCarDocs("Audi A4 2016-24"),
FlexRayCarDocs("Audi A5 2016-24"),
FlexRayCarDocs("Audi Q5 2017-24"),
FlexRayCarDocs("Audi A4 2016-24", package="All"),
FlexRayCarDocs("Audi A5 2016-24", package="All"),
FlexRayCarDocs("Audi Q5 2017-24", package="All"),
],
)

View File

@@ -97,7 +97,6 @@ FW_VERSIONS = {
b'\xa2 \x193\x00',
b'\xa2 \x194\x00',
b'\xa2 \x19`\x00',
b'\xa2 5\x00',
],
(Ecu.eps, 0x746, None): [
b'z\xc0\x00\x00',
@@ -107,7 +106,6 @@ FW_VERSIONS = {
b'z\xc0\x0c\x00',
b'\x8a\xc0\x00\x00',
b'\x8a\xc0\x10\x00',
b'\x9a\xc0\x08\x00',
],
(Ecu.fwdCamera, 0x787, None): [
b'\x00\x00c\xf4\x00\x00\x00\x00',
@@ -124,7 +122,6 @@ FW_VERSIONS = {
b'\x00\x00e\x1c\x1f@ \x14',
b'\x00\x00e+\x00\x00\x00\x00',
b'\x00\x00e+\x1f@ \x14',
b'\x00\x00eq\x1f@ "',
],
(Ecu.engine, 0x7e0, None): [
b'\xaa\x00Bu\x07',
@@ -148,7 +145,6 @@ FW_VERSIONS = {
b'\xc5!as\x07',
b'\xc5!dr\x07',
b'\xc5!ds\x07',
b'\xca\x01b0\x07',
],
(Ecu.transmission, 0x7e1, None): [
b'\xe3\xd0\x081\x00',
@@ -167,7 +163,6 @@ FW_VERSIONS = {
b'\xe5\xf5\x04\x00\x00',
b'\xe5\xf5$\x00\x00',
b'\xe5\xf5B\x00\x00',
b'\xe6\xd5\x041\x00',
],
},
CAR.SUBARU_IMPREZA_2020: {

View File

@@ -20,7 +20,7 @@ class CarController(CarControllerBase):
super().__init__(dbc_names, CP)
self.apply_angle_last = 0
self.packer = CANPacker(dbc_names[Bus.party])
self.tesla_can = TeslaCAN(CP, self.packer)
self.tesla_can = TeslaCAN(self.packer)
# Vehicle model used for lateral limiting
self.VM = VehicleModel(get_safety_CP())

View File

@@ -3,7 +3,6 @@ from opendbc.can import CANDefine, CANParser
from opendbc.car import Bus, structs
from opendbc.car.common.conversions import Conversions as CV
from opendbc.car.interfaces import CarStateBase
from opendbc.car.tesla.teslacan import get_steer_ctrl_type
from opendbc.car.tesla.values import DBC, CANBUS, GEAR_MAP, STEER_THRESHOLD, CAR
ButtonType = structs.CarState.ButtonEvent.Type
@@ -106,11 +105,7 @@ class CarState(CarStateBase):
ret.stockAeb = cp_ap_party.vl["DAS_control"]["DAS_aebEvent"] == 1
# LKAS
# On FSD 14+, ANGLE_CONTROL behavior changed to allow user winddown while actuating.
# FSD switched from using ANGLE_CONTROL to LANE_KEEP_ASSIST to likely keep the old steering override disengage logic.
# LKAS switched from LANE_KEEP_ASSIST to ANGLE_CONTROL to likely allow overriding LKAS events smoothly
lkas_ctrl_type = get_steer_ctrl_type(self.CP.flags, 2)
ret.stockLkas = cp_ap_party.vl["DAS_steeringControl"]["DAS_steeringControlType"] == lkas_ctrl_type # LANE_KEEP_ASSIST
ret.stockLkas = cp_ap_party.vl["DAS_steeringControl"]["DAS_steeringControlType"] == 2 # LANE_KEEP_ASSIST
# Stock Autosteer should be off (includes FSD)
if self.CP.carFingerprint in (CAR.TESLA_MODEL_3, CAR.TESLA_MODEL_Y):

View File

@@ -36,8 +36,6 @@ FW_VERSIONS = {
b'TeMYG4_Legacy3Y_0.0.0 (5),Y4P003.03.2',
b'TeMYG4_SingleECU_0.0.0 (28),Y4S002.23.0',
b'TeMYG4_SingleECU_0.0.0 (33),Y4S002.26',
b'TeMYG4_Legacy3Y_0.0.0 (6),Y4003.04.0',
b'TeMYG4_Main_0.0.0 (77),Y4003.05.4',
],
},
CAR.TESLA_MODEL_X: {

View File

@@ -2,7 +2,7 @@ from opendbc.car import get_safety_config, structs
from opendbc.car.interfaces import CarInterfaceBase
from opendbc.car.tesla.carcontroller import CarController
from opendbc.car.tesla.carstate import CarState
from opendbc.car.tesla.values import TeslaSafetyFlags, TeslaFlags, CAR, FSD_14_FW, Ecu
from opendbc.car.tesla.values import TeslaSafetyFlags, CAR
class CarInterface(CarInterfaceBase):
@@ -31,11 +31,6 @@ class CarInterface(CarInterfaceBase):
ret.vEgoStarting = 0.1
ret.stoppingDecelRate = 0.3
fsd_14 = any(fw.ecu == Ecu.eps and fw.fwVersion in FSD_14_FW.get(candidate, []) for fw in car_fw)
if fsd_14:
ret.flags |= TeslaFlags.FSD_14.value
ret.safetyConfigs[0].safetyParam |= TeslaSafetyFlags.FSD_14.value
ret.dashcamOnly = candidate in (CAR.TESLA_MODEL_X,) # dashcam only, pending find invalidLkasSetting signal
ret.dashcamOnly = candidate in (CAR.TESLA_MODEL_X) # dashcam only, pending find invalidLkasSetting signal
return ret

View File

@@ -1,29 +1,16 @@
from opendbc.car.common.conversions import Conversions as CV
from opendbc.car.tesla.values import CANBUS, CarControllerParams, TeslaFlags
def get_steer_ctrl_type(flags: int, ctrl_type: int) -> int:
# Returns the flipped signal value for DAS_steeringControlType on FSD 14
if flags & TeslaFlags.FSD_14:
return {1: 2, 2: 1}.get(ctrl_type, ctrl_type)
else:
return ctrl_type
from opendbc.car.tesla.values import CANBUS, CarControllerParams
class TeslaCAN:
def __init__(self, CP, packer):
self.CP = CP
def __init__(self, packer):
self.packer = packer
def create_steering_control(self, angle, enabled):
# On FSD 14+, ANGLE_CONTROL behavior changed to allow user winddown while actuating.
# with openpilot, after overriding w/ ANGLE_CONTROL the wheel snaps back to the original angle abruptly
# so we now use LANE_KEEP_ASSIST to match stock FSD.
# see carstate.py for more details
values = {
"DAS_steeringAngleRequest": -angle,
"DAS_steeringHapticRequest": 0,
"DAS_steeringControlType": get_steer_ctrl_type(self.CP.flags, 1 if enabled else 0),
"DAS_steeringControlType": 1 if enabled else 0,
}
return self.packer.make_can_msg("DAS_steeringControl", CANBUS.party, values)

View File

@@ -72,14 +72,6 @@ FW_QUERY_CONFIG = FwQueryConfig(
]
)
# Cars with this EPS FW have FSD 14 and use TeslaFlags.FSD_14
FSD_14_FW = {
CAR.TESLA_MODEL_Y: [
b'TeMYG4_Legacy3Y_0.0.0 (6),Y4003.04.0',
b'TeMYG4_Main_0.0.0 (77),Y4003.05.4',
]
}
class CANBUS:
party = 0
@@ -127,12 +119,10 @@ class CarControllerParams:
class TeslaSafetyFlags(IntFlag):
LONG_CONTROL = 1
FSD_14 = 2
class TeslaFlags(IntFlag):
LONG_CONTROL = 1
FSD_14 = 2
DBC = CAR.create_dbc_map()

View File

@@ -182,14 +182,13 @@ class CarController(CarControllerBase):
# if user engages at a stop with foot on brake, PCM starts in a special cruise standstill mode. on resume press,
# brakes can take a while to ramp up causing a lurch forward. prevent resume press until planner wants to move.
# don't use CC.cruiseControl.resume since it is gated on CS.cruiseState.standstill which goes false for 3s after resume press
# whitelist hybrids as they do not have this issue and can stay stopped after resume press
if not self.CP.flags & ToyotaFlags.HYBRID.value:
should_resume = actuators.accel > 0
if should_resume:
self.standstill_req = False
# TODO: hybrids do not have this issue and can stay stopped after resume press, whitelist them
should_resume = actuators.accel > 0
if should_resume:
self.standstill_req = False
if not should_resume and CS.out.cruiseState.standstill:
self.standstill_req = True
if not should_resume and CS.out.cruiseState.standstill:
self.standstill_req = True
self.last_standstill = CS.out.standstill

View File

@@ -3,7 +3,6 @@
#include "opendbc/safety/declarations.h"
static bool tesla_longitudinal = false;
static bool tesla_fsd_14 = false;
static bool tesla_stock_aeb = false;
// Only rising edges while controls are not allowed are considered for these systems:
@@ -92,20 +91,6 @@ static bool tesla_get_quality_flag_valid(const CANPacket_t *msg) {
return valid;
}
static int tesla_get_steer_ctrl_type(const int ctrl_type) {
// Returns ANGLE_CONTROL-equivalent control type for FSD 14
int steer_ctrl_type = ctrl_type;
if (tesla_fsd_14) {
if (ctrl_type == 1) {
steer_ctrl_type = 2;
} else if (ctrl_type == 2) {
steer_ctrl_type = 1;
} else {
}
}
return steer_ctrl_type;
}
static void tesla_rx_hook(const CANPacket_t *msg) {
if (msg->bus == 0U) {
@@ -191,7 +176,7 @@ static void tesla_rx_hook(const CANPacket_t *msg) {
// DAS_steeringControl
if (msg->addr == 0x488U) {
int steering_control_type = msg->data[2] >> 6;
bool tesla_stock_lkas_now = steering_control_type == tesla_get_steer_ctrl_type(2); // "LANE_KEEP_ASSIST"
bool tesla_stock_lkas_now = steering_control_type == 2; // "LANE_KEEP_ASSIST"
// Only consider rising edges while controls are not allowed
if (tesla_stock_lkas_now && !tesla_stock_lkas_prev && !controls_allowed) {
@@ -240,15 +225,14 @@ static bool tesla_tx_hook(const CANPacket_t *msg) {
int raw_angle_can = ((msg->data[0] & 0x7FU) << 8) | msg->data[1];
int desired_angle = raw_angle_can - 16384;
int steer_control_type = msg->data[2] >> 6;
const int angle_ctrl_type = tesla_get_steer_ctrl_type(1);
bool steer_control_enabled = steer_control_type == angle_ctrl_type; // ANGLE_CONTROL
bool steer_control_enabled = steer_control_type == 1; // ANGLE_CONTROL
if (steer_angle_cmd_checks_vm(desired_angle, steer_control_enabled, TESLA_STEERING_LIMITS, TESLA_STEERING_PARAMS)) {
violation = true;
}
bool valid_steer_control_type = (steer_control_type == 0) || // NONE
(steer_control_type == angle_ctrl_type); // ANGLE_CONTROL
(steer_control_type == 1); // ANGLE_CONTROL
if (!valid_steer_control_type) {
violation = true;
}
@@ -344,9 +328,7 @@ static safety_config tesla_init(uint16_t param) {
{0x27D, 0, 3, .check_relay = true, .disable_static_blocking = true}, // APS_eacMonitor
};
const uint16_t TESLA_FLAG_FSD_14 = 2;
tesla_fsd_14 = GET_FLAG(param, TESLA_FLAG_FSD_14);
SAFETY_UNUSED(param);
#ifdef ALLOW_DEBUG
const uint16_t TESLA_FLAG_LONGITUDINAL_CONTROL = 1;
tesla_longitudinal = GET_FLAG(param, TESLA_FLAG_LONGITUDINAL_CONTROL);

View File

@@ -4,8 +4,7 @@ import unittest
import numpy as np
from opendbc.car.lateral import get_max_angle_delta_vm, get_max_angle_vm
from opendbc.car.tesla.teslacan import get_steer_ctrl_type
from opendbc.car.tesla.values import CarControllerParams, TeslaSafetyFlags, TeslaFlags
from opendbc.car.tesla.values import CarControllerParams, TeslaSafetyFlags
from opendbc.car.tesla.carcontroller import get_safety_CP
from opendbc.car.structs import CarParams
from opendbc.car.vehicle_model import VehicleModel
@@ -27,8 +26,6 @@ def round_angle(apply_angle, can_offset=0):
class TestTeslaSafetyBase(common.CarSafetyTest, common.AngleSteeringSafetyTest, common.LongitudinalAccelSafetyTest):
SAFETY_PARAM = 0
RELAY_MALFUNCTION_ADDRS = {0: (MSG_DAS_steeringControl, MSG_APS_eacMonitor)}
FWD_BLACKLISTED_ADDRS = {2: [MSG_DAS_steeringControl, MSG_APS_eacMonitor]}
TX_MSGS = [[MSG_DAS_steeringControl, 0], [MSG_APS_eacMonitor, 0], [MSG_DAS_Control, 0]]
@@ -72,15 +69,7 @@ class TestTeslaSafetyBase(common.CarSafetyTest, common.AngleSteeringSafetyTest,
self.steer_control_types = {d: v for v, d in self.define.dv["DAS_steeringControl"]["DAS_steeringControlType"].items()}
self.safety = libsafety_py.libsafety
self.safety.set_safety_hooks(CarParams.SafetyModel.tesla, self.SAFETY_PARAM)
self.safety.init_tests()
def _angle_cmd_msg(self, angle: float, state: bool | int, increment_timer: bool = True, bus: int = 0):
# If FSD 14, translate steer control type to new flipped definition
if self.safety.get_current_safety_param() & TeslaSafetyFlags.FSD_14:
state = get_steer_ctrl_type(TeslaFlags.FSD_14, int(state))
values = {"DAS_steeringAngleRequest": angle, "DAS_steeringControlType": state}
if increment_timer:
self.safety.set_timer(self.cnt_angle_cmd * int(1e6 / self.LATERAL_FREQUENCY))
@@ -369,6 +358,12 @@ class TestTeslaStockSafety(TestTeslaSafetyBase):
LONGITUDINAL = False
def setUp(self):
super().setUp()
self.safety = libsafety_py.libsafety
self.safety.set_safety_hooks(CarParams.SafetyModel.tesla, 0)
self.safety.init_tests()
def test_cancel(self):
for acc_state in range(16):
self.safety.set_controls_allowed(True)
@@ -400,16 +395,16 @@ class TestTeslaStockSafety(TestTeslaSafetyBase):
self.assertFalse(self._tx(no_aeb_msg))
class TestTeslaFSD14StockSafety(TestTeslaStockSafety):
SAFETY_PARAM = TeslaSafetyFlags.FSD_14
class TestTeslaLongitudinalSafety(TestTeslaSafetyBase):
SAFETY_PARAM = TeslaSafetyFlags.LONG_CONTROL
RELAY_MALFUNCTION_ADDRS = {0: (MSG_DAS_steeringControl, MSG_APS_eacMonitor, MSG_DAS_Control)}
FWD_BLACKLISTED_ADDRS = {2: [MSG_DAS_steeringControl, MSG_APS_eacMonitor, MSG_DAS_Control]}
def setUp(self):
super().setUp()
self.safety = libsafety_py.libsafety
self.safety.set_safety_hooks(CarParams.SafetyModel.tesla, TeslaSafetyFlags.LONG_CONTROL)
self.safety.init_tests()
def test_no_aeb(self):
for aeb_event in range(4):
self.assertEqual(self._tx(self._long_control_msg(10, aeb_event=aeb_event)), aeb_event == 0)
@@ -452,9 +447,5 @@ class TestTeslaLongitudinalSafety(TestTeslaSafetyBase):
self.assertFalse(self._tx(self._long_control_msg(set_speed=0, accel_limits=(-0.1, -0.1))))
class TestTeslaFSD14LongitudinalSafety(TestTeslaLongitudinalSafety):
SAFETY_PARAM = TeslaSafetyFlags.LONG_CONTROL | TeslaSafetyFlags.FSD_14
if __name__ == "__main__":
unittest.main()

View File

@@ -39,7 +39,7 @@ if ! command -v uv &>/dev/null; then
fi
export UV_PROJECT_ENVIRONMENT="$BASEDIR/.venv"
uv sync --all-extras --inexact
uv sync --all-extras
source "$PYTHONPATH/.venv/bin/activate"
$BASEDIR/opendbc/safety/tests/misra/install.sh