Compare commits

...

4 Commits

Author SHA1 Message Date
Jason Wen 12032700c2 No longer faults! 2023-01-07 02:14:17 -05:00
Jason Wen 26a9408671 Don't send SCC14 and FCA stuff 2023-01-07 01:38:40 -05:00
Jason Wen a3d9ad9d28 bump panda 2023-01-06 23:31:31 -05:00
Jason Wen a1704cfed1 HKG: Legacy longitudinal support - init 2023-01-06 23:31:22 -05:00
4 changed files with 75 additions and 36 deletions
+1 -1
Submodule panda updated: 345147fe2b...ba31b388a0
+44 -4
View File
@@ -54,6 +54,12 @@ class CarController:
self.car_fingerprint = CP.carFingerprint
self.last_button_frame = 0
# radar disable for legacy cars
self.counter_init = False
self.radarDisableActivated = False
self.radarDisableResetTimer = 0
self.radarDisableOverlapTimer = 0
def update(self, CC, CS):
actuators = CC.actuators
hud_control = CC.hudControl
@@ -83,15 +89,49 @@ class CarController:
# tester present - w/ no response (keeps relevant ECU disabled)
if self.frame % 100 == 0 and not (self.CP.flags & HyundaiFlags.CANFD_CAMERA_SCC.value) and self.CP.openpilotLongitudinalControl:
# for longitudinal control, either radar or ADAS driving ECU
addr, bus = 0x7d0, 0
if self.CP.flags & HyundaiFlags.CANFD_HDA2.value:
addr, bus = 0x730, 5
can_sends.append([addr, 0, b"\x02\x3E\x80\x00\x00\x00\x00\x00", bus])
#addr, bus = 0x7d0, 0
#if self.CP.flags & HyundaiFlags.CANFD_HDA2.value:
# addr, bus = 0x730, 5
#can_sends.append([addr, 0, b"\x02\x3E\x80\x00\x00\x00\x00\x00", bus])
# for blinkers
if self.CP.flags & HyundaiFlags.ENABLE_BLINKERS:
can_sends.append([0x7b1, 0, b"\x02\x3E\x80\x00\x00\x00\x00\x00", 5])
# # radar disable for legacy cars
if self.CP.openpilotLongitudinalControl:
self.radarDisableOverlapTimer += 1
self.radarDisableResetTimer = 0
if self.radarDisableOverlapTimer >= 30:
self.radarDisableActivated = True
if 200 > self.radarDisableOverlapTimer > 36:
if self.frame % 41 == 0 or self.radarDisableOverlapTimer == 37:
can_sends.append([0x7D0, 0, b"\x02\x10\x03\x00\x00\x00\x00\x00", 0])
elif self.frame % 43 == 0 or self.radarDisableOverlapTimer == 37:
can_sends.append([0x7D0, 0, b"\x03\x28\x03\x01\x00\x00\x00\x00", 0])
elif self.frame % 19 == 0 or self.radarDisableOverlapTimer == 37:
can_sends.append([0x7D0, 0, b"\x02\x10\x85\x00\x00\x00\x00\x00", 0]) # this disables RADAR for
else:
self.counter_init = False
can_sends.append([0x7D0, 0, b"\x02\x10\x90\x00\x00\x00\x00\x00", 0]) # this enables RADAR
can_sends.append([0x7D0, 0, b"\x03\x29\x03\x01\x00\x00\x00\x00", 0])
elif self.radarDisableActivated:
can_sends.append([0x7D0, 0, b"\x02\x10\x90\x00\x00\x00\x00\x00", 0]) # this enables RADAR
can_sends.append([0x7D0, 0, b"\x03\x29\x03\x01\x00\x00\x00\x00", 0])
self.radarDisableOverlapTimer = 0
if self.frame % 50 == 0:
self.radarDisableResetTimer += 1
if self.radarDisableResetTimer > 2:
self.radarDisableActivated = False
self.counter_init = True
else:
self.radarDisableOverlapTimer = 0
self.radarDisableResetTimer = 0
if (self.frame % 50 == 0 or self.radarDisableOverlapTimer == 37) and \
self.CP.openpilotLongitudinalControl and self.radarDisableOverlapTimer >= 30:
can_sends.append([0x7D0, 0, b"\x02\x3E\x00\x00\x00\x00\x00\x00", 0])
# >90 degree steering fault prevention
# Count up to MAX_ANGLE_FRAMES, at which point we need to cut torque to avoid a steering fault
if CC.latActive and abs(CS.out.steeringAngleDeg) >= MAX_ANGLE:
+28 -25
View File
@@ -118,33 +118,36 @@ def create_acc_commands(packer, enabled, accel, upper_jerk, idx, lead_visible, s
"aReqRaw": accel,
"aReqValue": accel, # stock ramps up and down respecting jerk limit until it reaches aReqRaw
"CR_VSM_Alive": idx % 0xF,
"CF_VSM_ConfMode": 1,
"AEB_Status": 2,
}
scc12_dat = packer.make_can_msg("SCC12", 0, scc12_values)[2]
scc12_values["CR_VSM_ChkSum"] = 0x10 - sum(sum(divmod(i, 16)) for i in scc12_dat) % 0x10
commands.append(packer.make_can_msg("SCC12", 0, scc12_values))
scc14_values = {
"ComfortBandUpper": 0.0, # stock usually is 0 but sometimes uses higher values
"ComfortBandLower": 0.0, # stock usually is 0 but sometimes uses higher values
"JerkUpperLimit": upper_jerk, # stock usually is 1.0 but sometimes uses higher values
"JerkLowerLimit": 5.0, # stock usually is 0.5 but sometimes uses higher values
"ACCMode": 2 if enabled and long_override else 1 if enabled else 4, # stock will always be 4 instead of 0 after first disengage
"ObjGap": 2 if lead_visible else 0, # 5: >30, m, 4: 25-30 m, 3: 20-25 m, 2: < 20 m, 0: no lead
}
commands.append(packer.make_can_msg("SCC14", 0, scc14_values))
#scc14_values = {
# "ComfortBandUpper": 0.0, # stock usually is 0 but sometimes uses higher values
# "ComfortBandLower": 0.0, # stock usually is 0 but sometimes uses higher values
# "JerkUpperLimit": upper_jerk, # stock usually is 1.0 but sometimes uses higher values
# "JerkLowerLimit": 5.0, # stock usually is 0.5 but sometimes uses higher values
# "ACCMode": 2 if enabled and long_override else 1 if enabled else 4, # stock will always be 4 instead of 0 after first disengage
# "ObjGap": 2 if lead_visible else 0, # 5: >30, m, 4: 25-30 m, 3: 20-25 m, 2: < 20 m, 0: no lead
#}
#commands.append(packer.make_can_msg("SCC14", 0, scc14_values))
# note that some vehicles most likely have an alternate checksum/counter definition
# https://github.com/commaai/opendbc/commit/9ddcdb22c4929baf310295e832668e6e7fcfa602
fca11_values = {
"CR_FCA_Alive": idx % 0xF,
"PAINT1_Status": 1,
"FCA_DrvSetStatus": 1,
"FCA_Status": 1, # AEB disabled
}
fca11_dat = packer.make_can_msg("FCA11", 0, fca11_values)[2]
fca11_values["CR_FCA_ChkSum"] = hyundai_checksum(fca11_dat[:7])
commands.append(packer.make_can_msg("FCA11", 0, fca11_values))
#fca11_values = {
# "CR_FCA_Alive": idx % 0xF,
# "PAINT1_Status": 1,
# "FCA_DrvSetStatus": 1,
# "FCA_Status": 2, # AEB disabled
# "FCA_TimetoCollision": 2540.,
#}
#fca11_dat = packer.make_can_msg("FCA11", 0, fca11_values)[2]
#fca11_values["CR_FCA_ChkSum"] = hyundai_checksum(fca11_dat[:7])
#commands.append(packer.make_can_msg("FCA11", 0, fca11_values))
return commands
@@ -152,17 +155,17 @@ def create_acc_opt(packer):
commands = []
scc13_values = {
"SCCDrvModeRValue": 2,
"SCCDrvModeRValue": 1,
"SCC_Equip": 1,
"Lead_Veh_Dep_Alert_USM": 2,
"Lead_Veh_Dep_Alert_USM": 0,
}
commands.append(packer.make_can_msg("SCC13", 0, scc13_values))
fca12_values = {
"FCA_DrvSetState": 2,
"FCA_USM": 1, # AEB disabled
}
commands.append(packer.make_can_msg("FCA12", 0, fca12_values))
#fca12_values = {
# "FCA_DrvSetState": 2,
# "FCA_USM": 3, # AEB disabled
#}
#commands.append(packer.make_can_msg("FCA12", 0, fca12_values))
return commands
+2 -6
View File
@@ -225,7 +225,7 @@ class CarInterface(CarInterfaceBase):
else:
ret.longitudinalTuning.kpV = [0.5]
ret.longitudinalTuning.kiV = [0.0]
ret.experimentalLongitudinalAvailable = candidate not in (LEGACY_SAFETY_MODE_CAR | CAMERA_SCC_CAR)
ret.experimentalLongitudinalAvailable = candidate not in CAMERA_SCC_CAR
ret.openpilotLongitudinalControl = experimental_long and ret.experimentalLongitudinalAvailable
ret.pcmCruise = not ret.openpilotLongitudinalControl
@@ -255,11 +255,7 @@ class CarInterface(CarInterfaceBase):
if ret.flags & HyundaiFlags.CANFD_CAMERA_SCC:
ret.safetyConfigs[1].safetyParam |= Panda.FLAG_HYUNDAI_CAMERA_SCC
else:
if candidate in LEGACY_SAFETY_MODE_CAR:
# these cars require a special panda safety mode due to missing counters and checksums in the messages
ret.safetyConfigs = [get_safety_config(car.CarParams.SafetyModel.hyundaiLegacy)]
else:
ret.safetyConfigs = [get_safety_config(car.CarParams.SafetyModel.hyundai, 0)]
ret.safetyConfigs = [get_safety_config(car.CarParams.SafetyModel.hyundai, 0)]
if candidate in CAMERA_SCC_CAR:
ret.safetyConfigs[0].safetyParam |= Panda.FLAG_HYUNDAI_CAMERA_SCC