Skip to content

Commit 83f6773

Browse files
authored
Merge branch 'master' into secoc-long
2 parents 4d2a2c8 + 43aa7aa commit 83f6773

File tree

12 files changed

+75
-36
lines changed

12 files changed

+75
-36
lines changed

opendbc/car/gm/carstate.py

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from opendbc.car.common.conversions import Conversions as CV
66
from opendbc.car.common.numpy_fast import mean
77
from opendbc.car.interfaces import CarStateBase
8-
from opendbc.car.gm.values import DBC, AccState, CruiseButtons, STEER_THRESHOLD, SDGM_CAR
8+
from opendbc.car.gm.values import DBC, AccState, CruiseButtons, STEER_THRESHOLD, SDGM_CAR, ALT_ACCS
99

1010
ButtonType = structs.CarState.ButtonEvent.Type
1111
TransmissionType = structs.CarParams.TransmissionType
@@ -123,14 +123,18 @@ def update(self, can_parsers) -> structs.CarState:
123123
ret.cruiseState.enabled = pt_cp.vl["AcceleratorPedal2"]["CruiseState"] != AccState.OFF
124124
ret.cruiseState.standstill = pt_cp.vl["AcceleratorPedal2"]["CruiseState"] == AccState.STANDSTILL
125125
if self.CP.networkLocation == NetworkLocation.fwdCamera:
126-
ret.cruiseState.speed = cam_cp.vl["ASCMActiveCruiseControlStatus"]["ACCSpeedSetpoint"] * CV.KPH_TO_MS
127-
# This FCW signal only works for SDGM cars. CAM cars send FCW on GMLAN but this bit is always 0 for them
128-
ret.stockFcw = cam_cp.vl["ASCMActiveCruiseControlStatus"]["FCWAlert"] != 0
126+
if self.CP.carFingerprint not in ALT_ACCS:
127+
ret.cruiseState.speed = cam_cp.vl["ASCMActiveCruiseControlStatus"]["ACCSpeedSetpoint"] * CV.KPH_TO_MS
128+
# This FCW signal only works for SDGM cars. CAM cars send FCW on GMLAN but this bit is always 0 for them
129+
ret.stockFcw = cam_cp.vl["ASCMActiveCruiseControlStatus"]["FCWAlert"] != 0
130+
if self.CP.pcmCruise:
131+
# openpilot controls nonAdaptive when not pcmCruise
132+
ret.cruiseState.nonAdaptive = cam_cp.vl["ASCMActiveCruiseControlStatus"]["ACCCruiseState"] not in (2, 3)
133+
else:
134+
ret.cruiseState.speed = pt_cp.vl["ECMCruiseControl"]["CruiseSetSpeed"] * CV.KPH_TO_MS
135+
129136
if self.CP.carFingerprint not in SDGM_CAR:
130137
ret.stockAeb = cam_cp.vl["AEBCmd"]["AEBCmdActive"] != 0
131-
# openpilot controls nonAdaptive when not pcmCruise
132-
if self.CP.pcmCruise:
133-
ret.cruiseState.nonAdaptive = cam_cp.vl["ASCMActiveCruiseControlStatus"]["ACCCruiseState"] not in (2, 3)
134138

135139
if self.CP.enableBsm:
136140
ret.leftBlindspot = pt_cp.vl["BCMBlindSpotMonitor"]["LeftBSM"] == 1
@@ -166,24 +170,26 @@ def get_can_parsers(CP):
166170
("ECMAcceleratorPos", 80),
167171
]
168172

173+
if CP.transmissionType == TransmissionType.direct:
174+
pt_messages.append(("EBCMRegenPaddle", 50))
175+
169176
if CP.enableBsm:
170177
pt_messages.append(("BCMBlindSpotMonitor", 10))
171178

172-
# Used to read back last counter sent to PT by camera
179+
cam_messages = []
173180
if CP.networkLocation == NetworkLocation.fwdCamera:
174181
pt_messages += [
175182
("ASCMLKASteeringCmd", 0),
176183
]
177-
178-
if CP.transmissionType == TransmissionType.direct:
179-
pt_messages.append(("EBCMRegenPaddle", 50))
180-
181-
cam_messages = []
182-
if CP.networkLocation == NetworkLocation.fwdCamera:
183184
cam_messages += [
184185
("ASCMLKASteeringCmd", 10),
185-
("ASCMActiveCruiseControlStatus", 25),
186186
]
187+
188+
if CP.carFingerprint in ALT_ACCS:
189+
pt_messages.append(("ECMCruiseControl", 10))
190+
else:
191+
cam_messages.append(("ASCMActiveCruiseControlStatus", 25))
192+
187193
if CP.carFingerprint not in SDGM_CAR:
188194
cam_messages += [
189195
("AEBCmd", 10),

opendbc/car/gm/fingerprints.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@
6666
CAR.CHEVROLET_TRAVERSE: [{
6767
190: 6, 193: 8, 197: 8, 199: 4, 201: 8, 208: 8, 209: 7, 211: 2, 241: 6, 249: 8, 257: 8, 288: 5, 289: 8, 292: 2, 298: 8, 304: 3, 309: 8, 313: 8, 320: 4, 322: 7, 328: 1, 331: 3, 352: 5, 368: 3, 381: 8, 384: 4, 386: 8, 388: 8, 393: 7, 398: 8, 401: 8, 407: 7, 413: 8, 417: 7, 419: 1, 422: 4, 426: 7, 431: 8, 442: 8, 451: 8, 452: 8, 453: 6, 454: 8, 455: 7, 479: 3, 481: 7, 485: 8, 489: 8, 497: 8, 499: 3, 500: 6, 501: 8, 508: 8, 510: 8, 532: 6, 554: 3, 560: 8, 562: 8, 563: 5, 564: 5, 567: 5, 573: 1, 577: 8, 578: 8, 579: 8, 587: 8, 603: 8, 608: 8, 609: 6, 610: 6, 611: 6, 612: 8, 613: 8, 647: 6, 707: 8, 715: 8, 717: 5, 723: 4, 730: 4, 753: 5, 761: 7, 840: 5, 842: 5, 844: 8, 866: 4, 869: 4, 880: 6, 961: 8, 969: 8, 975: 2, 977: 8, 979: 8, 985: 5, 1001: 8, 1005: 6, 1009: 8, 1011: 6, 1013: 5, 1017: 8, 1020: 8, 1033: 7, 1034: 7, 1105: 5, 1217: 8, 1221: 5, 1223: 3, 1225: 7, 1233: 8, 1236: 8, 1249: 8, 1257: 6, 1259: 8, 1261: 7, 1263: 4, 1265: 8, 1267: 1, 1268: 2, 1271: 8, 1279: 4, 1280: 4, 1296: 4, 1300: 8, 1322: 6, 1323: 4, 1328: 4, 1345: 8, 1346: 8, 1347: 8, 1355: 8, 1362: 8, 1417: 8, 1512: 8, 1514: 8, 1601: 8, 1602: 8, 1603: 7, 1609: 8, 1611: 8, 1613: 8, 1618: 8, 1649: 8, 1792: 8, 1793: 8, 1798: 8, 1799: 8, 1810: 8, 1813: 8, 1824: 8, 1825: 8, 1840: 8, 1842: 8, 1856: 8, 1858: 8, 1859: 8, 1860: 8, 1862: 8, 1863: 8, 1871: 8, 1872: 8, 1875: 8, 1879: 8, 1882: 8, 1888: 8, 1889: 8, 1892: 8, 1906: 7, 1907: 7, 1912: 7, 1919: 7, 1920: 7, 1927: 8, 1930: 7, 1937: 8, 1953: 8, 1954: 8, 1955: 8, 1968: 8, 1969: 8, 1971: 8, 1975: 8, 1988: 8, 1990: 8, 2000: 8, 2001: 8, 2004: 8, 2016: 8, 2017: 8, 2018: 8, 2019: 8, 2020: 8, 2024: 8, 2026: 8
6868
}],
69+
CAR.GMC_YUKON: [{
70+
190: 6, 193: 8, 197: 8, 201: 8, 208: 8, 209: 7, 211: 2, 241: 6, 249: 8, 288: 5, 289: 8, 298: 8, 304: 1, 309: 8, 311: 8, 313: 8, 320: 3, 328: 1, 352: 5, 381: 8, 384: 4, 386: 8, 388: 8, 413: 8, 451: 8, 452: 8, 453: 6, 455: 7, 460: 5, 463: 3, 479: 3, 481: 7, 485: 8, 489: 8, 497: 8, 500: 6, 501: 8, 510: 8, 528: 5, 532: 6, 534: 2, 562: 8, 563: 5, 587: 8, 608: 8, 609: 6, 610: 6, 611: 6, 612: 8, 613: 8, 707: 8, 761: 7, 800: 6, 801: 8, 810: 8, 840: 5, 842: 5, 844: 8, 848: 4, 977: 8, 1001: 8, 1017: 8, 1020: 8, 1217: 8, 1221: 5, 1233: 8, 1249: 8, 1265: 8, 1267: 1, 1280: 4, 1300: 8, 1355: 8, 1611: 8
71+
}],
6972
}
7073

7174
FW_VERSIONS: dict[str, dict[tuple, list[bytes]]] = {

opendbc/car/gm/interface.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from opendbc.car.common.basedir import BASEDIR
88
from opendbc.car.common.conversions import Conversions as CV
99
from opendbc.car.gm.radar_interface import RADAR_HEADER_MSG
10-
from opendbc.car.gm.values import CAR, CarControllerParams, EV_CAR, CAMERA_ACC_CAR, SDGM_CAR, CanBus
10+
from opendbc.car.gm.values import CAR, CarControllerParams, EV_CAR, CAMERA_ACC_CAR, SDGM_CAR, ALT_ACCS, CanBus
1111
from opendbc.car.interfaces import CarInterfaceBase, TorqueFromLateralAccelCallbackType, FRICTION_THRESHOLD, LatControlInputs, NanoFFModel
1212

1313
TransmissionType = structs.CarParams.TransmissionType
@@ -113,6 +113,11 @@ def _get_params(ret: structs.CarParams, candidate, fingerprint, car_fw, experime
113113
ret.openpilotLongitudinalControl = True
114114
ret.safetyConfigs[0].safetyParam |= Panda.FLAG_GM_HW_CAM_LONG
115115

116+
if candidate in ALT_ACCS:
117+
ret.experimentalLongitudinalAvailable = False
118+
ret.openpilotLongitudinalControl = False
119+
ret.minEnableSpeed = -1. # engage speed is decided by PCM
120+
116121
else: # ASCM, OBD-II harness
117122
ret.openpilotLongitudinalControl = True
118123
ret.networkLocation = NetworkLocation.gateway
@@ -203,4 +208,9 @@ def _get_params(ret: structs.CarParams, candidate, fingerprint, car_fw, experime
203208
ret.steerActuatorDelay = 0.2
204209
CarInterfaceBase.configure_torque_tune(candidate, ret.lateralTuning)
205210

211+
elif candidate == CAR.GMC_YUKON:
212+
ret.steerActuatorDelay = 0.5
213+
CarInterfaceBase.configure_torque_tune(candidate, ret.lateralTuning)
214+
ret.dashcamOnly = True # Needs steerRatio, tireStiffness, and lat accel factor tuning
215+
206216
return ret

opendbc/car/gm/values.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,10 @@ class CAR(Platforms):
175175
[GMCarDocs("Chevrolet Traverse 2022-23", "RS, Premier, or High Country Trim")],
176176
GMCarSpecs(mass=1955, wheelbase=3.07, steerRatio=17.9, centerToFrontRatio=0.4),
177177
)
178+
GMC_YUKON = GMPlatformConfig(
179+
[GMCarDocs("GMC Yukon 2019-20", "Adaptive Cruise Control (ACC) & LKAS")],
180+
GMCarSpecs(mass=2490, wheelbase=2.94, steerRatio=17.3, centerToFrontRatio=0.5, tireStiffnessFactor=1.0),
181+
)
178182

179183

180184
class CruiseButtons:
@@ -253,7 +257,10 @@ class CanBus:
253257
EV_CAR = {CAR.CHEVROLET_VOLT, CAR.CHEVROLET_VOLT_2019, CAR.CHEVROLET_BOLT_EUV}
254258

255259
# We're integrated at the camera with VOACC on these cars (instead of ASCM w/ OBD-II harness)
256-
CAMERA_ACC_CAR = {CAR.CHEVROLET_BOLT_EUV, CAR.CHEVROLET_SILVERADO, CAR.CHEVROLET_EQUINOX, CAR.CHEVROLET_TRAILBLAZER}
260+
CAMERA_ACC_CAR = {CAR.CHEVROLET_BOLT_EUV, CAR.CHEVROLET_SILVERADO, CAR.CHEVROLET_EQUINOX, CAR.CHEVROLET_TRAILBLAZER, CAR.GMC_YUKON}
261+
262+
# Alt ASCMActiveCruiseControlStatus
263+
ALT_ACCS = {CAR.GMC_YUKON}
257264

258265
# We're integrated at the Safety Data Gateway Module on these cars
259266
SDGM_CAR = {CAR.CADILLAC_XT4, CAR.CHEVROLET_VOLT_2019, CAR.CHEVROLET_TRAVERSE}

opendbc/car/hyundai/carcontroller.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def update(self, CC, CS, now_nanos):
9090
# *** common hyundai stuff ***
9191

9292
# tester present - w/ no response (keeps relevant ECU disabled)
93-
if self.frame % 100 == 0 and not (self.CP.flags & HyundaiFlags.CANFD_CAMERA_SCC.value) and self.CP.openpilotLongitudinalControl:
93+
if self.frame % 100 == 0 and not (self.CP.flags & HyundaiFlags.CANFD_CAMERA_SCC) and self.CP.openpilotLongitudinalControl:
9494
# for longitudinal control, either radar or ADAS driving ECU
9595
addr, bus = 0x7d0, 0
9696
if self.CP.flags & HyundaiFlags.CANFD_HDA2.value:
@@ -147,15 +147,15 @@ def update(self, CC, CS, now_nanos):
147147
use_fca = self.CP.flags & HyundaiFlags.USE_FCA.value
148148
can_sends.extend(hyundaican.create_acc_commands(self.packer, CC.enabled, accel, jerk, int(self.frame / 2),
149149
hud_control, set_speed_in_units, stopping,
150-
CC.cruiseControl.override, use_fca))
150+
CC.cruiseControl.override, use_fca, self.CP))
151151

152152
# 20 Hz LFA MFA message
153153
if self.frame % 5 == 0 and self.CP.flags & HyundaiFlags.SEND_LFA.value:
154154
can_sends.append(hyundaican.create_lfahda_mfc(self.packer, CC.enabled))
155155

156156
# 5 Hz ACC options
157157
if self.frame % 20 == 0 and self.CP.openpilotLongitudinalControl:
158-
can_sends.extend(hyundaican.create_acc_opt(self.packer))
158+
can_sends.extend(hyundaican.create_acc_opt(self.packer, self.CP))
159159

160160
# 2 Hz front radar options
161161
if self.frame % 50 == 0 and self.CP.openpilotLongitudinalControl:

opendbc/car/hyundai/carstate.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,13 @@ def __init__(self, CP):
3434
"GEAR_SHIFTER"
3535
if CP.flags & HyundaiFlags.CANFD:
3636
self.shifter_values = can_define.dv[self.gear_msg_canfd]["GEAR"]
37+
elif CP.flags & (HyundaiFlags.HYBRID | HyundaiFlags.EV):
38+
self.shifter_values = can_define.dv["ELECT_GEAR"]["Elect_Gear_Shifter"]
3739
elif self.CP.flags & HyundaiFlags.CLUSTER_GEARS:
3840
self.shifter_values = can_define.dv["CLU15"]["CF_Clu_Gear"]
3941
elif self.CP.flags & HyundaiFlags.TCU_GEARS:
4042
self.shifter_values = can_define.dv["TCU12"]["CUR_GR"]
41-
else: # preferred and elect gear methods use same definition
43+
else:
4244
self.shifter_values = can_define.dv["LVR12"]["CF_Lvr_Gear"]
4345

4446
self.accelerator_msg_canfd = "ACCELERATOR" if CP.flags & HyundaiFlags.EV else \
@@ -153,7 +155,7 @@ def update(self, can_parsers) -> structs.CarState:
153155

154156
ret.gearShifter = self.parse_gear_shifter(self.shifter_values.get(gear))
155157

156-
if not self.CP.openpilotLongitudinalControl:
158+
if not self.CP.openpilotLongitudinalControl or self.CP.flags & HyundaiFlags.CAMERA_SCC:
157159
aeb_src = "FCA11" if self.CP.flags & HyundaiFlags.USE_FCA.value else "SCC12"
158160
aeb_sig = "FCA_CmdAct" if self.CP.flags & HyundaiFlags.USE_FCA.value else "AEB_CmdAct"
159161
aeb_warning = cp_cruise.vl[aeb_src]["CF_VSM_Warn"] != 0
@@ -372,7 +374,7 @@ def get_can_parsers(self, CP):
372374
("LKAS11", 100)
373375
]
374376

375-
if not CP.openpilotLongitudinalControl and CP.flags & HyundaiFlags.CAMERA_SCC:
377+
if CP.flags & HyundaiFlags.CAMERA_SCC:
376378
cam_messages += [
377379
("SCC11", 50),
378380
("SCC12", 50),

opendbc/car/hyundai/hyundaican.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ def create_lfahda_mfc(packer, enabled):
123123
}
124124
return packer.make_can_msg("LFAHDA_MFC", 0, values)
125125

126-
def create_acc_commands(packer, enabled, accel, upper_jerk, idx, hud_control, set_speed, stopping, long_override, use_fca):
126+
def create_acc_commands(packer, enabled, accel, upper_jerk, idx, hud_control, set_speed, stopping, long_override, use_fca, CP):
127127
commands = []
128128

129129
scc11_values = {
@@ -169,7 +169,8 @@ def create_acc_commands(packer, enabled, accel, upper_jerk, idx, hud_control, se
169169
commands.append(packer.make_can_msg("SCC14", 0, scc14_values))
170170

171171
# Only send FCA11 on cars where it exists on the bus
172-
if use_fca:
172+
# On Camera SCC cars, FCA11 is not disabled, so we forward stock FCA11 back to the car forward hooks
173+
if use_fca and not (CP.flags & HyundaiFlags.CAMERA_SCC):
173174
# note that some vehicles most likely have an alternate checksum/counter definition
174175
# https://github.com/commaai/opendbc/commit/9ddcdb22c4929baf310295e832668e6e7fcfa602
175176
fca11_values = {
@@ -184,7 +185,7 @@ def create_acc_commands(packer, enabled, accel, upper_jerk, idx, hud_control, se
184185

185186
return commands
186187

187-
def create_acc_opt(packer):
188+
def create_acc_opt(packer, CP):
188189
commands = []
189190

190191
scc13_values = {
@@ -195,11 +196,13 @@ def create_acc_opt(packer):
195196
commands.append(packer.make_can_msg("SCC13", 0, scc13_values))
196197

197198
# TODO: this needs to be detected and conditionally sent on unsupported long cars
198-
fca12_values = {
199-
"FCA_DrvSetState": 2,
200-
"FCA_USM": 1, # AEB disabled
201-
}
202-
commands.append(packer.make_can_msg("FCA12", 0, fca12_values))
199+
# On Camera SCC cars, FCA12 is not disabled, so we forward stock FCA12 back to the car forward hooks
200+
if not (CP.flags & HyundaiFlags.CAMERA_SCC):
201+
fca12_values = {
202+
"FCA_DrvSetState": 2,
203+
"FCA_USM": 1, # AEB disabled
204+
}
205+
commands.append(packer.make_can_msg("FCA12", 0, fca12_values))
203206

204207
return commands
205208

opendbc/car/hyundai/interface.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from panda import Panda
22
from opendbc.car import Bus, get_safety_config, structs
33
from opendbc.car.hyundai.hyundaicanfd import CanBus
4-
from opendbc.car.hyundai.values import HyundaiFlags, CAR, DBC, CAMERA_SCC_CAR, CANFD_RADAR_SCC_CAR, \
4+
from opendbc.car.hyundai.values import HyundaiFlags, CAR, DBC, CANFD_RADAR_SCC_CAR, \
55
CANFD_UNSUPPORTED_LONGITUDINAL_CAR, \
66
UNSUPPORTED_LONGITUDINAL_CAR
77
from opendbc.car.hyundai.radar_interface import RADAR_START_ADDR
@@ -68,7 +68,7 @@ def _get_params(ret: structs.CarParams, candidate, fingerprint, car_fw, experime
6868

6969
else:
7070
# Shared configuration for non CAN-FD cars
71-
ret.experimentalLongitudinalAvailable = candidate not in (UNSUPPORTED_LONGITUDINAL_CAR | CAMERA_SCC_CAR)
71+
ret.experimentalLongitudinalAvailable = candidate not in UNSUPPORTED_LONGITUDINAL_CAR
7272
ret.enableBsm = 0x58b in fingerprint[0]
7373

7474
# Send LFA message on cars with HDA
@@ -128,7 +128,7 @@ def _get_params(ret: structs.CarParams, candidate, fingerprint, car_fw, experime
128128

129129
@staticmethod
130130
def init(CP, can_recv, can_send):
131-
if CP.openpilotLongitudinalControl and not (CP.flags & HyundaiFlags.CANFD_CAMERA_SCC.value):
131+
if CP.openpilotLongitudinalControl and not (CP.flags & (HyundaiFlags.CANFD_CAMERA_SCC | HyundaiFlags.CAMERA_SCC)):
132132
addr, bus = 0x7d0, 0
133133
if CP.flags & HyundaiFlags.CANFD_HDA2.value:
134134
addr, bus = 0x730, CanBus(CP).ECAN

opendbc/car/tests/routes.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ class CarTestRoute(NamedTuple):
7676
CarTestRoute("162796f1469f2f1b/00000005--6f334eda14", GM.CADILLAC_XT4),
7777
CarTestRoute("477dd485611d1e6e/00000009--85fc06e10a", GM.CHEVROLET_VOLT_2019),
7878
CarTestRoute("a40976dc9f28ba62/0000001f--160e210119", GM.CHEVROLET_TRAVERSE),
79+
CarTestRoute("36c62b5da6f08154/00000052--983c17c5b2", GM.GMC_YUKON),
7980

8081
CarTestRoute("0e7a2ba168465df5|2020-10-18--14-14-22", HONDA.ACURA_RDX_3G),
8182
CarTestRoute("a74b011b32b51b56|2020-07-26--17-09-36", HONDA.HONDA_CIVIC),

opendbc/car/torque_data/override.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ legend = ["LAT_ACCEL_FACTOR", "MAX_LAT_ACCEL_MEASURED", "FRICTION"]
5454
"KIA_SPORTAGE_5TH_GEN" = [2.6, 2.6, 0.1]
5555
"GENESIS_GV70_1ST_GEN" = [2.42, 2.42, 0.1]
5656
"GENESIS_GV60_EV_1ST_GEN" = [2.5, 2.5, 0.1]
57+
"GMC_YUKON" = [1.2, 2.5, 0.26]
5758
"KIA_SORENTO_4TH_GEN" = [2.5, 2.5, 0.1]
5859
"KIA_SORENTO_HEV_4TH_GEN" = [2.5, 2.5, 0.1]
5960
"KIA_NIRO_HEV_2ND_GEN" = [2.42, 2.5, 0.12]

0 commit comments

Comments
 (0)