make CAR class enum, and values.py formatting

car-enums
Shane Smiskol 2022-02-14 13:22:47 -08:00
parent e76ef93a83
commit 04d9817e9d
12 changed files with 86 additions and 31 deletions

View File

@ -1,7 +1,10 @@
from enum import Enum
from selfdrive.car import dbc_dict
from cereal import car
Ecu = car.CarParams.Ecu
class CarControllerParams:
STEER_MAX = 261 # 262 faults
STEER_DELTA_UP = 3 # 3 is stock. 100 is fine. 200 is too much it seems
@ -9,7 +12,7 @@ class CarControllerParams:
STEER_ERROR_MAX = 80
class CAR:
class CAR(Enum):
PACIFICA_2017_HYBRID = "CHRYSLER PACIFICA HYBRID 2017"
PACIFICA_2018_HYBRID = "CHRYSLER PACIFICA HYBRID 2018"
PACIFICA_2019_HYBRID = "CHRYSLER PACIFICA HYBRID 2019"
@ -18,6 +21,7 @@ class CAR:
JEEP_CHEROKEE = "JEEP GRAND CHEROKEE V6 2018" # includes 2017 Trailhawk
JEEP_CHEROKEE_2019 = "JEEP GRAND CHEROKEE 2019" # includes 2020 Trailhawk
# Unique CAN messages:
# Only the hybrids have 270: 8
# Only the gas have 55: 8, 416: 7

View File

@ -1,12 +1,16 @@
from enum import Enum
from selfdrive.car import dbc_dict
from cereal import car
Ecu = car.CarParams.Ecu
MAX_ANGLE = 87. # make sure we never command the extremes (0xfff) which cause latching fault
class CAR:
class CAR(Enum):
FUSION = "FORD FUSION 2018"
DBC = {
CAR.FUSION: dbc_dict('ford_fusion_2018_pt', 'ford_fusion_2018_adas'),
}

View File

@ -1,8 +1,11 @@
from enum import Enum
from cereal import car
from selfdrive.car import dbc_dict
Ecu = car.CarParams.Ecu
class CarControllerParams():
class CarControllerParams:
STEER_MAX = 300 # Safety limit, not LKA max. Trucks use 600.
STEER_STEP = 2 # control frames per command
STEER_DELTA_UP = 7
@ -36,9 +39,11 @@ class CarControllerParams():
BRAKE_LOOKUP_BP = [ACCEL_MIN, -1.]
BRAKE_LOOKUP_V = [MAX_BRAKE, 0.]
STEER_THRESHOLD = 1.0
class CAR:
class CAR(Enum):
HOLDEN_ASTRA = "HOLDEN ASTRA RS-V BK 2017"
VOLT = "CHEVROLET VOLT PREMIER 2017"
CADILLAC_ATS = "CADILLAC ATS Premium Performance 2018"
@ -47,6 +52,7 @@ class CAR:
BUICK_REGAL = "BUICK REGAL ESSENCE 2018"
ESCALADE_ESV = "CADILLAC ESCALADE ESV 2016"
class CruiseButtons:
INIT = 0
UNPRESS = 1
@ -55,12 +61,14 @@ class CruiseButtons:
MAIN = 5
CANCEL = 6
class AccState:
OFF = 0
ACTIVE = 1
FAULTED = 3
STANDSTILL = 4
class CanBus:
POWERTRAIN = 0
OBSTACLE = 1
@ -68,6 +76,7 @@ class CanBus:
SW_GMLAN = 3
LOOPBACK = 128
FINGERPRINTS = {
# Astra BK MY17, ASCM unplugged
CAR.HOLDEN_ASTRA: [{

View File

@ -1,4 +1,4 @@
from enum import IntFlag
from enum import Enum, IntFlag
from cereal import car
from selfdrive.car import dbc_dict
@ -51,6 +51,7 @@ class CruiseButtons:
CANCEL = 2
MAIN = 1
# See dbc files for info on values
VISUAL_HUD = {
VisualAlert.none: 0,
@ -63,7 +64,8 @@ VISUAL_HUD = {
VisualAlert.speedTooHigh: 8
}
class CAR:
class CAR(Enum):
ACCORD = "HONDA ACCORD 2018"
ACCORDH = "HONDA ACCORD HYBRID 2018"
CIVIC = "HONDA CIVIC 2016"
@ -87,6 +89,7 @@ class CAR:
INSIGHT = "HONDA INSIGHT 2019"
HONDA_E = "HONDA E 2020"
FW_VERSIONS = {
CAR.ACCORD: {
(Ecu.programmedFuelInjection, 0x18da10f1, None): [

View File

@ -1,7 +1,10 @@
from enum import Enum
from cereal import car
from selfdrive.car import dbc_dict
Ecu = car.CarParams.Ecu
# Steer torque limits
class CarControllerParams:
ACCEL_MIN = -3.5 # m/s
@ -22,7 +25,8 @@ class CarControllerParams:
self.STEER_DRIVER_MULTIPLIER = 2
self.STEER_DRIVER_FACTOR = 1
class CAR:
class CAR(Enum):
# Hyundai
ELANTRA = "HYUNDAI ELANTRA 2017"
ELANTRA_2021 = "HYUNDAI ELANTRA 2021"
@ -74,6 +78,7 @@ class Buttons:
GAP_DIST = 3
CANCEL = 4
FINGERPRINTS = {
CAR.ELANTRA: [{
66: 8, 67: 8, 68: 8, 127: 8, 273: 8, 274: 8, 275: 8, 339: 8, 356: 4, 399: 8, 512: 6, 544: 8, 593: 8, 608: 8, 688: 5, 790: 8, 809: 8, 897: 8, 832: 8, 899: 8, 902: 8, 903: 8, 905: 8, 909: 8, 916: 8, 1040: 8, 1056: 8, 1057: 8, 1078: 4, 1170: 8, 1265: 4, 1280: 1, 1282: 4, 1287: 4, 1290: 8, 1292: 8, 1294: 8, 1312: 8, 1314: 8, 1322: 8, 1345: 8, 1349: 8, 1351: 8, 1353: 8, 1363: 8, 1366: 8, 1367: 8, 1369: 8, 1407: 8, 1415: 8, 1419: 8, 1425: 2, 1427: 6, 1440: 8, 1456: 4, 1472: 8, 1486: 8, 1487: 8, 1491: 8, 1530: 8, 1532: 5, 2001: 8, 2003: 8, 2004: 8, 2009: 8, 2012: 8, 2016: 8, 2017: 8, 2024: 8, 2025: 8

View File

@ -1,3 +1,5 @@
from enum import Enum
from selfdrive.car import dbc_dict
from cereal import car
Ecu = car.CarParams.Ecu
@ -14,7 +16,8 @@ class CarControllerParams:
STEER_DRIVER_FACTOR = 1 # from dbc
STEER_ERROR_MAX = 350 # max delta between torque cmd and torque motor
class CAR:
class CAR(Enum):
CX5 = "MAZDA CX-5"
CX9 = "MAZDA CX-9"
MAZDA3 = "MAZDA 3"
@ -22,11 +25,13 @@ class CAR:
CX9_2021 = "MAZDA CX-9 2021"
CX5_2022 = "MAZDA CX-5 2022"
class LKAS_LIMITS:
STEER_THRESHOLD = 15
DISABLE_SPEED = 45 # kph
ENABLE_SPEED = 52 # kph
class Buttons:
NONE = 0
SET_PLUS = 1

View File

@ -1,2 +1,5 @@
class CAR:
from enum import Enum
class CAR(Enum):
MOCK = 'mock'

View File

@ -1,3 +1,5 @@
from enum import Enum
from selfdrive.car import dbc_dict
from cereal import car
Ecu = car.CarParams.Ecu
@ -10,7 +12,8 @@ class CarControllerParams:
LKAS_MAX_TORQUE = 1 # A value of 1 is easy to overpower
STEER_THRESHOLD = 1.0
class CAR:
class CAR(Enum):
XTRAIL = "NISSAN X-TRAIL 2017"
LEAF = "NISSAN LEAF 2018"
# Leaf with ADAS ECU found behind instrument cluster instead of glovebox

View File

@ -1,7 +1,10 @@
from enum import Enum
from selfdrive.car import dbc_dict
from cereal import car
Ecu = car.CarParams.Ecu
class CarControllerParams:
def __init__(self, CP):
if CP.carFingerprint == CAR.IMPREZA_2020:
@ -15,7 +18,8 @@ class CarControllerParams:
self.STEER_DRIVER_MULTIPLIER = 10 # weight driver torque heavily
self.STEER_DRIVER_FACTOR = 1 # from dbc
class CAR:
class CAR(Enum):
ASCENT = "SUBARU ASCENT LIMITED 2019"
IMPREZA = "SUBARU IMPREZA LIMITED 2019"
IMPREZA_2020 = "SUBARU IMPREZA SPORT 2020"
@ -25,6 +29,7 @@ class CAR:
OUTBACK_PREGLOBAL = "SUBARU OUTBACK 2015 - 2017"
OUTBACK_PREGLOBAL_2018 = "SUBARU OUTBACK 2018 - 2019"
FINGERPRINTS = {
CAR.IMPREZA: [{
2: 8, 64: 8, 65: 8, 72: 8, 73: 8, 280: 8, 281: 8, 290: 8, 312: 8, 313: 8, 314: 8, 315: 8, 316: 8, 326: 8, 372: 8, 544: 8, 545: 8, 546: 8, 552: 8, 554: 8, 557: 8, 576: 8, 577: 8, 722: 8, 801: 8, 802: 8, 805: 8, 808: 8, 811: 8, 816: 8, 826: 8, 827: 8, 837: 8, 838: 8, 839: 8, 842: 8, 912: 8, 915: 8, 940: 8, 1614: 8, 1617: 8, 1632: 8, 1650: 8, 1657: 8, 1658: 8, 1677: 8, 1697: 8, 1722: 8, 1743: 8, 1759: 8, 1786: 5, 1787: 5, 1788: 8, 1809: 8, 1813: 8, 1817: 8, 1821: 8, 1840: 8, 1848: 8, 1924: 8, 1932: 8, 1952: 8, 1960: 8

View File

@ -1,14 +1,18 @@
from collections import namedtuple
from enum import Enum
from selfdrive.car import dbc_dict
from cereal import car
Button = namedtuple('Button', ['event_type', 'can_addr', 'can_msg', 'values'])
AngleRateLimit = namedtuple('AngleRateLimit', ['speed_points', 'max_angle_diff_points'])
class CAR:
class CAR(Enum):
AP1_MODELS = 'TESLA AP1 MODEL S'
AP2_MODELS = 'TESLA AP2 MODEL S'
FINGERPRINTS = {
CAR.AP2_MODELS: [
{
@ -27,6 +31,7 @@ DBC = {
CAR.AP1_MODELS: dbc_dict('tesla_powertrain', 'tesla_radar', chassis_dbc='tesla_can'),
}
class CANBUS:
# Lateral harness
chassis = 0
@ -38,6 +43,7 @@ class CANBUS:
private = 5
autopilot_powertrain = 6
GEAR_MAP = {
"DI_GEAR_INVALID": car.CarState.GearShifter.unknown,
"DI_GEAR_P": car.CarState.GearShifter.park,
@ -59,6 +65,7 @@ BUTTONS = [
Button(car.CarState.ButtonEvent.Type.resumeCruise, "STW_ACTN_RQ", "SpdCtrlLvr_Stat", [1]),
]
class CarControllerParams:
RATE_LIMIT_UP = AngleRateLimit(speed_points=[0., 5., 15.], max_angle_diff_points=[5., .8, .15])
RATE_LIMIT_DOWN = AngleRateLimit(speed_points=[0., 5., 15.], max_angle_diff_points=[5., 3.5, 0.4])

View File

@ -1,5 +1,5 @@
from collections import defaultdict
from enum import IntFlag
from enum import Enum, IntFlag
from cereal import car
from selfdrive.car import dbc_dict
@ -24,7 +24,7 @@ class ToyotaFlags(IntFlag):
HYBRID = 1
class CAR:
class CAR(Enum):
# Toyota
ALPHARD_TSS2 = "TOYOTA ALPHARD 2020"
AVALON = "TOYOTA AVALON 2016"

View File

@ -1,4 +1,5 @@
from collections import defaultdict
from enum import Enum
from typing import Dict
from cereal import car
@ -9,6 +10,7 @@ NetworkLocation = car.CarParams.NetworkLocation
TransmissionType = car.CarParams.TransmissionType
GearShifter = car.CarState.GearShifter
class CarControllerParams:
HCA_STEP = 2 # HCA_01 message frequency 50Hz
LDW_STEP = 10 # LDW_02 message frequency 10Hz
@ -27,13 +29,16 @@ class CarControllerParams:
STEER_DRIVER_MULTIPLIER = 3 # weight driver torque heavily
STEER_DRIVER_FACTOR = 1 # from dbc
class CANBUS:
pt = 0
cam = 2
class DBC_FILES:
mqb = "vw_mqb_2010" # Used for all cars with MQB-style CAN messaging
DBC = defaultdict(lambda: dbc_dict(DBC_FILES.mqb, None)) # type: Dict[str, Dict[str, str]]
BUTTON_STATES = {
@ -57,12 +62,13 @@ MQB_LDW_MESSAGES = {
"laneAssistDeactivated": 10, # "Lane Assist deactivated." silent with persistent icon afterward
}
# Check the 7th and 8th characters of the VIN before adding a new CAR. If the
# chassis code is already listed below, don't add a new CAR, just add to the
# FW_VERSIONS for that existing CAR.
# Exception: SEAT Leon and SEAT Ateca share a chassis code
class CAR:
class CAR(Enum):
ARTEON_MK1 = "VOLKSWAGEN ARTEON 1ST GEN" # Chassis AN, Mk1 VW Arteon and variants
ATLAS_MK1 = "VOLKSWAGEN ATLAS 1ST GEN" # Chassis CA, Mk1 VW Atlas and Atlas Cross Sport
GOLF_MK7 = "VOLKSWAGEN GOLF 7TH GEN" # Chassis 5G/AU/BA/BE, Mk7 VW Golf and variants
@ -87,6 +93,7 @@ class CAR:
SKODA_SUPERB_MK3 = "SKODA SUPERB 3RD GEN" # Chassis 3V/NP, Mk3 Skoda Superb and variants
SKODA_OCTAVIA_MK3 = "SKODA OCTAVIA 3RD GEN" # Chassis NE, Mk3 Skoda Octavia and variants
# All supported cars should return FW from the engine, srs, eps, and fwdRadar. Cars
# with a manual trans won't return transmission firmware, but all other cars will.
#